[darcs-users] [patch337] handle whitespace lexing more intelligen... (and 16 more)

Jason Dagit bugs at darcs.net
Tue Aug 10 02:57:12 UTC 2010


New submission from Jason Dagit <aoeu at oregonstate.edu>:

Hello,

This is my attempt to improve the performance now that my refactor was
accepted.

The majority of these patches happened as a natural part of me staring
at the code thinking of how to optimize it.  Which is to say, if the
code was ugly and I had to stare at it I fet compelled to tidy it up.

This refactor comes with really only 3 optimizations:

Sun Aug  8 19:04:46 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up skipNewline

Sun Aug  8 19:04:57 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up linesStartingWith

Sun Aug  8 19:05:39 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * optimize char parser

The main one is the last one, "optimize char parser".  What I can't
tell is how much this stuff helps.

As for why is my new parser slower than the old one?  I tracked one
culprit down to the removal of maybeWork.  That patch changed the
linesStartingWith parser among other things so I've included what I
hope is a faster version of that function.  I removed the reversed
list building in favor of killing the tail call optimization.

Is there a way to know if this was a bad idea?  On the surface, it
avoids one O(n) operation, namely reverse.  It also removes the tail
recursion opportunity, but Haskell is a lazy language so it's hard to
predict, in my opinion, what the outcome will be.  My benchmarking
show that it took just as much memory either way and the runtime
didn't seem to change either.

In summary, take the three patches mentioned above for the performance
win, and take the rest if you're okay with it.

Thanks,
Jason

17 patches for repository http://darcs.net:

Sun Aug  8 13:05:33 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * handle whitespace lexing more intelligently in Read.hs

Sun Aug  8 13:11:40 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * improve interface of peekforw and bracketedFL

Sun Aug  8 16:34:24 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up readPatchInfo

Sun Aug  8 16:34:41 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * improve string parser

Sun Aug  8 17:18:09 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * remove unused word8 parser

Sun Aug  8 17:18:50 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up anyChar parser

Sun Aug  8 19:04:15 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * reorder alternatives in readPrim to optimize for the critical path

Sun Aug  8 19:04:46 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up skipNewline

Sun Aug  8 19:04:57 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up linesStartingWith

Sun Aug  8 19:05:39 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * optimize char parser

Sun Aug  8 19:05:47 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * remove unneeded export

Sun Aug  8 19:15:22 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up readPatches

Sun Aug  8 19:21:15 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * remove unused import

Sun Aug  8 19:21:45 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up peekforc

Sun Aug  8 19:34:45 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * fix the haddocks in ReadMonads.hs

Sun Aug  8 19:44:22 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up Real.hs and refactor space lexing

Sun Aug  8 20:28:21 PDT 2010  Jason Dagit <dagit at codersbase.com>
  * tidy up Info.hs
  The comment about break no longer applies as break is no longer used.
  Using choice instead of (<|>) keeps linesStartingWithEndingWith a
  little prettier.

----------
files: handle-whitespace-lexing-more-intelligently-in-read_hs.dpatch, unnamed
messages: 12079
nosy: dagit
status: needs-review
title: handle whitespace lexing more intelligen... (and 16 more)

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch337>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: handle-whitespace-lexing-more-intelligently-in-read_hs.dpatch
Type: text/x-darcs-patch
Size: 132649 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20100810/c16d9173/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unnamed
Type: application/octet-stream
Size: 5 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20100810/c16d9173/attachment-0001.obj>


More information about the darcs-users mailing list