[Issue 7243] Compiler should call separate function when allocating a struct on the heap

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 29 11:28:34 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7243



--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> 2012-04-29 11:29:39 PDT ---
Martin Nowak has found a very compelling case for this to be fixed, it is
affecting performance of RedBlackTree.

>From bug 5650:

When in 64-bit mode, each pointer is 8 bytes.  RedBlackNodes have a left,
right, and parent pointer, consuming 24 bytes.  Then it contains the payload,
followed by a byte for the color (red or black).  The basic RedBlackTree!int
case has a payload of int, or 4 bytes.  With alignment padding, this brings the
size of the struct to 32 bytes.

Now, given that array appending needs the extra byte for 'used' length (also
serves as a sentinel to prevent accidentally accessing the subsequent block),
this will be with array padding, 33 bytes, pushing the block required to 64
bytes.

Not only that, but because the struct has pointers, it must zero out those 31
unused bytes.

With his measurements as quoted in bug 5650, fixing this problem resulted in
roughly a 40% runtime reduction.

Can we please get this fixed?  I'll be happy to implement the druntime function
if someone will take care of the compiler part.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list