caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Prevalence of duplicate references in the heap
@ 2010-01-03  0:31 Jon Harrop
  0 siblings, 0 replies; only message in thread
From: Jon Harrop @ 2010-01-03  0:31 UTC (permalink / raw)
  To: caml-list


I took an odd design decision with HLVM and made references a struct of 
run-time type, metadata (e.g. array length), pointer to mark state and 
pointer to data. So every reference consumes 4x32=128 bits rather than the 
usual 32 bits but heap-allocated values no longer require a header.

My performance results really surprised me. For example, the "gc" benchmark in 
the HLVM test suite fills a hash table that is represented by an array spine 
containing references to array buckets. Despite having (fat) references 
everywhere, HLVM is 2.2x faster than OCaml on x86.

The main disadvantage of HLVM's approach is probably that every duplicate 
reference now duplicates the header information, wasting 96 bits. However, I 
do not believe references are duplicated in the heap very often. Both trees 
and hash tables contain many references but none are duplicated.

So I'm wondering if anyone has studied the makeup of heaps in idiomatic OCaml 
code and could point me to data on the proportion of the heap typically 
consumed by duplicate references, i.e. how much space is HLVM likely to 
waste?

Many thanks,
-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-01-02 23:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-03  0:31 Prevalence of duplicate references in the heap Jon Harrop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).