[Haskell-cafe] Re: Hashtable woes

Simon Marlow simonmar at microsoft.com
Mon Jan 23 10:40:20 EST 2006


On 23 January 2006 15:09, Chris Kuklewicz wrote:

> That is good to hear.  The benchmark's tests take 1,250,000
> pre-generated 
> strings as the keys.  At the end, the string keys are 18 characters
> long, drawn randomly from a set of 4 characters.  So the hash
> computations are a nontrivial hit. 
> 
> Using -A400m I get 39s down from 55s.  That is the best
> Data.HashTable time I 
> have seen. (Using -A10m and -A100m were a little slower).
> 
> Using my over optimized c-code hashtable I get 12.3 seconds.  The
> associative arrays in OCaml and D are still faster.  So you see why I
> long for GHC 6.6. 
> 
> Is Jan-Willem Maessen's Hash available anywhere?  I could benchmark
> it. 

Jan-Willem's HashTable attached.  It uses unsafeThaw/unsafeFreeze tricks
to avoid the GC overheads, for this you need an up to date GHC due to a
bug in the garbage collector: grab a STABLE snapshot (6.4.1 won't work).
Or remove the unsafeThaw/unsafeFreeze to use it with 6.4.1, and be
prepared to bump the heap size.

In GHC 6.6 the unsafeThaw/unsafeFreeze tricks aren't required, because
the GC is essentially doing it for you - we put a write barrier in the
IOArray implementation.

Cheers,
	Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HashTable.hs
Type: application/octet-stream
Size: 16274 bytes
Desc: HashTable.hs
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060123/9ee082ff/HashTable-0001.obj


More information about the Haskell-Cafe mailing list