Re: Importing Cheetah.Template.Template unusually slow?
"R. Tyler Ballance" <[email protected]> Wed, 27 Jan 2010 15:25:58 -0800
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 28 Jan 2010, Matthew Beauregard wrote: > On 28/01/2010, at 5:02 AM, R. Tyler Ballance wrote: > > > > > On Wed, 27 Jan 2010, Matthew Beauregard wrote: > > > >> Hi, > >> > >> I was trying to speed up my CGI, and I worked out that the lion's share of execution time was taken up by the Cheetah import. Is 0.7s unusually slow? Where should I start in trying to speed it up? > > > > What version are Cheetah are you running? I'm also curious if your machine > > isn't generating a Template.pyc for Template.py, causing the interpreter to > > generate new byte-code for every request. > > Hi Tyler, > > It's version 2.4.1, and the installer generated the pyc: > > -rwxr-xr-x 1 root admin 84747 27 Jan 21:37 /Library/Python/2.6/site-packages/Cheetah-2.4.1-py2.6-macosx-10.6-universal.egg/Cheetah/Template.py > -rw-r--r-- 1 root admin 71104 27 Jan 21:37 /Library/Python/2.6/site-packages/Cheetah-2.4.1-py2.6-macosx-10.6-universal.egg/Cheetah/Template.pyc > > > I did some other comparisons, all for Cheetah 2.4.1: > OSX 10.6, system python 2.6.1: 0.7s > OSX 10.5, system python 2.5.1: 0.7s > OSX 10.6, macports python 2.6.4: 0.1s > Ubuntu Hardy, python 2.5: 0.1s > > So I guess I'd have to blame some interaction between Cheetah and Apple's framework python. I'm not sure what to do next. Interesting, I wonder what differes in the Apple build of Python. > > > > It's also worth mentioning that in a CGI environment you are going to have some > > bit of slow-down with imports to begin with, you can mitigate this by making > > sure that a new instance of the interpreter isn't started for each requests, > > allowing a single instance service thousands of requests (mod_python has some > > options for this IIRC) > > That'd be a massive job at this point, I think the project is welded to CGI. But that 0.7s import accounts for something like 80% of the average execution time, solving it would be a big win. Let me ponder on this for a while, at first glance there's not really a whole lot of performance improvements that "leap out" at me when I look at the module-level code in Template.py. Cheers, -R. Tyler Ballance -------------------------------------- Jabber: [email protected] GitHub: http://github.com/rtyler Twitter: http://twitter.com/agentdero Blog: http://unethicalblogger.com ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc
(application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAktgy4YACgkQFCbH3D9R4W+ZfACeNCGPX0922YXpCubGIfb1kuF3 T3YAn2+Fqx8HIZiZb2QU6P32W4TTEt8q =g29i -----END PGP SIGNATURE-----