[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: highlighting-kate is sometimes too heavy



+++ Joachim Breitner [Mar 06 10 18:15 ]:
> Hi,
> 
> Am Samstag, den 06.03.2010, 18:02 +0100 schrieb Joachim Breitner:
> > Both these modules have large lists of keywords. Can you see if maybe
> > some little restructuring in your code generator can produce code that
> > ghc6 handles more easily? This would help us a lot.
> 
> ok, I looked a bit into the issue. The problem seems to be that ghc
> wants to inline the list of words passed to pKeyword. If I replace this
> list of words by one large string, wrapped in "words", the module
> compiles much faster. I’m considering applying this change in Debian for
> now, as a work-around.
> 
> Looking at your code, you use the list only as a lookup. Wouldn’t it
> massively speed up your code (and probably fix the compile times as
> well) if you replace any occurence of
> 
> > [..]
> >  pKeyword arg1 list >>= withAttribute "Something"
> > [..]
> 
> by two global bindings (to benefit from sharing)
> >
> > something_word_set = Data.Set.fromList list
> > something_word_set_upper = Data.Set.fromList (map (map toUpper) list)
> >
> > [..]
> >  pKeyword arg1 something_word_set something_word_set_upper
> >                                         >>= withAttribute "Something"
> > [..]
> 
> And maybe, depending on whether ghc wants to inline the fromList call,
> apply a trick similar to the one above to avoid the inlining.

Joachim,

I've used both your suggestions (using Set instead of list for
keywords, and using the trick with "words" to keep ghc from
inlining), and produced a new version, 0.2.6.1, which is now
on HackageDB.

A comparison:
                                    old       new
compile time inc. executable        5:45      3:39
time to highlight a 102K file       1:69      1:59
size of Highlight executable       10.5M      5.7M

Great improvements all around!  Thanks!  I hope this version
can be packaged for debian.

John


Reply to: