Startup time is regressing

FUJIWARA Katsunori fujiwara at ascade.co.jp
Fri Nov 12 05:34:45 CST 2010


Hi, Martin.

At Wed, 10 Nov 2010 10:32:43 +0100,
Martin Geisler wrote:
> 
> FUJIWARA Katsunori <fujiwara at ascade.co.jp> writes:
> 
> > I confirmed that defining the sub class of textwrap.TextWrapper causes
> > regression, as Martin says.
> >
> >> I just looked at the textwrap module, and the TextWrapper class is
> >> fairly short -- lots of comments but little code. I suggest we borrow
> >> the code, fix it to handle wide characters and take out the unneeded
> >> parts such as handling double-space after periods. Then put the whole
> >> thing in i18n.
> >
> > I also confirmed that both ways shown below can prevent startup time
> > from regressing.
> >
> >     1. move sub class definition from util.py to other file
> >
> >     2. define sub class on-demand like:
> >
> >         ====================
> >         MBTextWrapper = None
> >
> >         def wrap(...)
> >
> >             global MBTextWrapper
> >             if not MBTextWrapper:
> >                 class MBTextWrapper(textwrap.TextWrapper):
> >                       ....
> >
> >             wrapper = MBTextWrapper()
> >
> >         ====================
> >
> > I think (1) is better for its simplicity.
> 
> Yes, I agree with using (1).
> 
> I just tried to move the MBTextwrap class to i18n and copy the code from
> the textwrap class into i18n too. I then combined the two classes so
> that there is only a single i18n.MBTextWrapper class left.
> 
> I could not see any significant performance difference -- this is
> without the patch:
> 
> % HGRCPATH= hg --config extensions.perf=contrib/perf.py perfstartup
> ! wall 0.025350 comb 0.000000 user 0.000000 sys 0.000000 (best of 118)
> 
> and this is with the patch
> 
> % HGRCPATH= hg --config extensions.perf=contrib/perf.py perfstartup
> ! wall 0.024969 comb 0.000000 user 0.000000 sys 0.000000 (best of 120)
> 
> So on my machine (Core i7, normal harddisk) the speedup is about 4
> milliseconds. The patch is below, so you can see if I've made a silly
> mistake :)

This patch seems to merge original TextWrapper and our
util.MBTextWrapper well !

BTW, does this code inclusion cause license problem ? 

--------------------
[FUJIWARA Katsunori]      fujiwara at ascade.co.jp(foozy at lares.dti.ne.jp)



More information about the Mercurial-devel mailing list