|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Fairly major performance regression from v2.2.0-v2.2.2I was doing some hotshot[1] based profiling tonight with some of
the basic performances tests I had written once upon a time and I noticed that while Template.compile() has remained speedy, Template.__init__() has gotten horrifically slow in comparision. . Upon further digging and prodding I found the issue was one that I introduced in 8982ecd . The PATCH follows this email includes the fix, insofar that it causes the dir() call to only execute at module import instead of __init__() (relevant members of Template really aren't likely to change between instantiations of Template). I'm considering backmerging this down into master/maint and creating a v2.2.2.1 with the performance regression fixed, thoughts? Cheers, -R. Tyler Ballance . [1] http://docs.python.org/library/hotshot.html ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
[PATCH] Remove unnecessary dir()/set() calls in Template.__init__()When running cheetah.Tests.Performance.DynamicMethodCompilationTest
with 100000 iterations set, Template.__init__() is the most performance sensitive call. Prior to this commit: ncalls tottime percall cumtime percall filename:lineno(function) 100000 12.558 0.000 15.274 0.000 Template.py:1025(__init__) After this commit: ncalls tottime percall cumtime percall filename:lineno(function) 100000 1.263 0.000 3.541 0.000 Template.py:1025(__init__) That code need not execute every time __init__ is called --- cheetah/Template.py | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cheetah/Template.py b/cheetah/Template.py index 01cf676..c903460 100644 --- a/cheetah/Template.py +++ b/cheetah/Template.py @@ -1213,11 +1213,10 @@ class Template(Servlet): ################################################## ## Setup instance state attributes used during the life of template ## post-compile - reserved_searchlist = dir(self) if searchList: for namespace in searchList: if isinstance(namespace, dict): - intersection = set(reserved_searchlist) & set(namespace.keys()) + intersection = Reserved_SearchList & set(namespace.keys()) warn = False if intersection: warn = True @@ -1832,7 +1831,7 @@ class Template(Servlet): return dic T = Template # Short and sweet for debugging at the >>> prompt. - +Reserved_SearchList = set(dir(Template)) def genParserErrorFromPythonException(source, file, generatedPyCode, exception): -- 1.6.5 ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
Re: [PATCH] Remove unnecessary dir()/set() calls in Template.__init__()On Mon, Oct 12, 2009, R. Tyler Ballance wrote:
> > When running cheetah.Tests.Performance.DynamicMethodCompilationTest > with 100000 iterations set, Template.__init__() is the most performance > sensitive call. This seems like a safe change. I would even go a step further in performance and reducing namespace pollution: Template.Reserved_SearchList = set(dir(Template)) You can then go back to using self.Reserved_SearchList, which should be faster than a global lookup. (I'm only mentioning this because you're using the lookup in a loop.) -- Aahz (aahz@...) <*> http://www.pythoncraft.com/ "To me vi is Zen. To use vi is to practice zen. Every command is a koan. Profound to the user, unintelligible to the uninitiated. You discover truth everytime you use it." --reddy@... ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
|
|
Re: [PATCH] Remove unnecessary dir()/set() calls in Template.__init__()On Tue, 13 Oct 2009, Aahz wrote: > On Mon, Oct 12, 2009, R. Tyler Ballance wrote: > > > > When running cheetah.Tests.Performance.DynamicMethodCompilationTest > > with 100000 iterations set, Template.__init__() is the most performance > > sensitive call. > > This seems like a safe change. I would even go a step further in > performance and reducing namespace pollution: > > Template.Reserved_SearchList = set(dir(Template)) > > You can then go back to using self.Reserved_SearchList, which should be > faster than a global lookup. (I'm only mentioning this because you're > using the lookup in a loop.) (http://github.com/rtyler/cheetah/tree/next) Cheers, -R. Tyler Ballance ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Cheetahtemplate-discuss mailing list Cheetahtemplate-discuss@... https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss |
| Free embeddable forum powered by Nabble | Forum Help |