[racket] Is struct allocation really more expensive than vector allocation?

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Wed Jan 14 16:08:45 EST 2015

Back when that recommendation was added (late 2012, IIRC), struct
allocation was much more expensive (~3x, IIRC) than vector allocation,
so that recommendation made sense.

Since then, Matthew has improve struct allocation performance
significantly, so the difference is only noticeable in extreme cases,
and even then, the difference is less than it used to be.

For an example where it still makes a difference (~20%, when I measured
last summer), look at the binarytrees benchmark, in the
racket-benchmarks package.

So, in general, that recommendation is less relevant than it used to be.
It should only show up in hot code (or in verbose mode), so I don't
think it's a major distraction for Optimzation Coach users.

Vincent



At Wed, 14 Jan 2015 12:09:39 -0800,
Alexis King wrote:
> 
> When using the optimization coach, it sometimes gives me this message:
> 
> > This struct constructor is used in hot code. Allocating structs is expensive, consider using vectors instead. To keep the same interface, consider defining macro wrappers around the vector operations that have the same name as the struct constructor and accessors.
> 
> 
> Is this really all that accurate? In some simple tests I’ve done, I haven’t found struct allocation to be any more expensive than vector allocation of equivalent size. What are the situations in which this holds to be true?
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users


Posted on the users mailing list.