Shootout PiDigits program kinda sucks (and possibly so does GHC)

| 2 Comments | No TrackBacks

So I've been trying to see if I could speed up the pidigits program, and, well, failed. I'm not alone though, Stephen Blackheath and others have tried too, and no one's managed to make things much, if at all faster.

The main problem seems to be that GHC is allocating a lot of RAM, which must be related to the need for Integers. The current program uses up 500+MB by the time it finishes. Not good.

So, I'm putting a call out to see if anyone else can either think of a better way to get the answer than the current entry, or any tips about reducing memory usage. If you come up with anything, I'd love to hear from you.

Cheers, ~ Axman

No TrackBacks

TrackBack URL: http://axman6.homeip.net/cgi-bin/mt/mt-tb.cgi/25

2 Comments

The current entry takes 95s on my machine (compared to the 10s on theirs), but it only takes 3Mb. What am I missing?

[0] wren@xenobia:~/test $ ghc --make -O2 -optc-O3 pidigits.hs -o pidigits
[1 of 1] Compiling Main ( pidigits.hs, pidigits.o )
Linking pidigits ...
[0] wren@xenobia:~/test $ ./pidigits 10000 +RTS -sstderr >/dev/null
./pidigits 10000 +RTS -sstderr
18,720,889,112 bytes allocated in the heap
5,614,688 bytes copied during GC (scavenged)
3,493,808 bytes copied during GC (not scavenged)
327,680 bytes maximum residency (635 sample(s))

34235 collections in generation 0 ( 0.50s)
635 collections in generation 1 ( 0.04s)

3 Mb total memory in use

INIT time 0.00s ( 0.02s elapsed)
MUT time 94.93s ( 97.81s elapsed)
GC time 0.54s ( 0.64s elapsed)
EXIT time 0.00s ( 0.00s elapsed)
Total time 95.47s ( 98.47s elapsed)

%GC time 0.6% (0.7% elapsed)

Alloc rate 197,202,546 bytes per MUT second

Productivity 99.4% of total user, 96.4% of total elapsed

That was using GHC 6.8.2, btw. Maybe this is one of the regressions that GHC 6.10 has...

Leave a comment

February 2009

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.23-en

About this Entry

This page contains a single entry by Alex Mason published on February 12, 2009 1:14 AM.

Other shootout news was the previous entry in this blog.

ASTM: redundant STMish fun is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.