[Haskell-cafe] Parsec3 performance issues (in relation to v2)

Neal Alexander wqeqweuqy at hotmail.com
Tue May 13 00:53:56 EDT 2008

Just a heads up - i only have a month or so experience with Haskell, so 
alot of these issues may be my own fault.

Anyway, the log file that i'm parsing uses English grammar, and the 
performance really dropped just by upgrading to Parsec3. I was hoping to 
use the ByteString support to boost the speed of already slow code, but 
had no such luck. It basicly went from "Ugh, this is kinda slow" to 
"Uhhhh i'm gonna go grab a burger and let this melt my CPU" haha.

If anything, its probably all the look-ahead the rules have to do to get 
the context specific stuff right.

Some of the code is here: http://hpaste.org/7578

#1 . Parsec 2:

	total time  =       46.44 secs   (2322 ticks @ 20 ms)
	total alloc = 16,376,179,008 bytes  (excl. profiling overheads)

Parse taking 51.3% time and 65.3% alloc.
#2 . Parsec3
(4 times slower, no code changes):

	total time  =      181.08 secs   (9054 ticks @ 20 ms)
	total alloc = 46,002,859,656 bytes  (excl. profiling overheads)

Text.Parsec.Prim  Taking 84.7% time and 86.0% alloc.
#3 . Parsec3 but with the whole project converted to ByteString:
(8 times slower):

	total time  =      378.22 secs   (18911 ticks @ 20 ms)
	total alloc = 100,051,417,672 bytes  (excl. overheads)

The third parse probably isn't a great indicator, since i reverted some 
rule-set optimizations that were causing errors. Plus i ended up packing 
the parsec String results to ByteStrings to fit in with everything else.

I can post the full profiling info if anyone really cares.

More information about the Haskell-Cafe mailing list