Andy Lester wrote:
>What exactly is "excessive"? How expensive are your stat calls? Are
>you measuring, or just assuming that "stat calls" = "server grinds to
>a halt"? How much traffic are you getting that stat calls are the
>bottleneck?
Tim Tompkins wrote:
> All of the site code lives on a NetApp and millions of stats (don't forget
> to add in stats for each "included" component) definitely have an
> impact, especially so over NFS.
No doubt, but I think Andy's point was "exactly how much impact?"
> multiple files included to serve a single request. So, if we're talking
> about 4 million hits per day and an average of only 5 components
> comprise the service of a single request, you have 20 million file stats
> for files that generally do not change. This is definitely unnecessary.
Actually, you'll only have half a million stat calls, which according to my
test below is less than a second of machine overhead per day.
perl -MBenchmark -e 'timethis(10_000_000, sub { stat $0 })'
timethis 432000: -1 wallclock secs ( 0.18 usr + 0.28 sys = 0.46 CPU)
@ 939130.43/s (n=432000)
Why? $Template::Provider::STAT_TTL is set to 1 (second) by default. That
means that each file is checked once a second, at most, regardless of how
many page impressions you're getting. That's 86k stat() calls per day
(60*60*24), per template used (which I assumed to be 5 in the calculation
above) = 432,000
And even if you were hitting stat() for every template, for every page, 20
million stat() calls is still only approx. 20 seconds of processor overhead
per day. That's pretty cheap.
You mention that you're mounted across NFS, which will certainly make things
a little slower. But if you're looking to speed thing up, then replicating
the templates to a local filesytem is going to have a much greater impact
than trying to optimise away stat() calls.
So I think Andy's advice is sound: measure what you're doing, and be
sure that you're optimising the right thing.
I personally suspect that tuning out the stat() calls isn't going to save
you a great deal of time, but I could be wrong. So if you want to reduce the
number of stat calls, simply set STAT_TTL to a higher value.
$Template::Provider::STAT_TTL = 60;
HTH
A
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates