Re: [pygccxml-development] Another performance tweak
Brought to you by:
mbaas,
roman_yakovenko
From: Allen B. <al...@vr...> - 2006-08-26 20:43:45
|
Roman Yakovenko wrote: > On 8/26/06, Allen Bierbaum <al...@vr...> wrote: > >> I just found some more tweaks. > > > Cool. I just committed a set of changes that will allow us to keep > under control > cache results of different algorithms. I still have to write unit > tests. These > changes allow you to continue grate work. Please take a look on them, > what > do you think? Not quite how I would have done it, but it looks like it should work. It may eliminate an extra attribute lookup I had to do so that could increase the performance even more. >> - Caching the results of type_traits.remove_alias improved performance >> by 20% > > > Yes, this algorithms is used every where. Please don't commit this > change, I'd like > to think about it. I see next problem here: there are a lot of types, > so the cache > memory size could go out of control. Can you find out how many memory > Py++ takes with\without the cache? I can try to take a look at this. I don't have an easy way to do it right now but I will try later. > >> - (danger) Having create_identifier just return the exact same string >> passed as full_name improved performance another 20%. >> >> This last one was interesting because what I found was that (at least in >> my project) create_identifier was called about 16,000 times and it >> always returned the same value passed in. This could be just because of >> how my project works (no namespace aliases that I know of) and is >> probably not portable. >> >> But, one very strange thing is why is this method being called for names >> like "boost::python::arg" and "boost::python::default_call_policies"? >> As far as I understand how py++ is working, these symbols are always >> going to be valid. So why waste the time calling an expensive method if >> we already know the outcome? > > > :-) It seems that you missed the point. Py++ has few cool features. > > mb = module_builder_t( ... ) > mb.build_code_creator(...) > mb.code_creator.add_namespace_alias( "bpl", "::boost::python" ) > or > mb.code_creator.add_namespace_usage( "::boost::python" ) > > See what happens. > > The short version is that you can add to the code creators tree the > namespace > usage and aliase and Py++ will generate code that takes into account > them. > > create_identfier function is responsible for creating such identifier. > > It is safe to add such optimization, but similar work should be done. > If you never call add_namespace_usage or add_namespace_alias, then will create_identifier ever need to do anything? Maybe we could make an optimization that keeps a global flag around and just skips the work in this method if you never set any namespace information. What do you think? -Allen |