[racket] Small and short-lived data structures

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Mon Oct 21 14:43:30 EDT 2013

I encourage you to find some evidence showing that Konrad's assumption
is mistaken, then.

Sam

On Mon, Oct 21, 2013 at 2:38 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> WIth respect, I think this shows nothing :-)
>
>
>
> On Oct 21, 2013, at 2:35 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>
>> On Mon, Oct 21, 2013 at 12:47 PM, Matthias Felleisen
>> <matthias at ccs.neu.edu> wrote:
>>>
>>> In general, it is a mistaken assumption however that even in a
>>> 'managed' language -- such as Java or Racket -- mutation is still
>>> faster than de/allocation of short-lived data structures. If you
>>> choose to go with 'managed' language, you need to adapt your
>>> programming style to the new context.
>>
>> Sadly, this assumption is often right for Racket today, even though we
>> have a pretty good allocator.  Here's a simple benchmark:
>> https://gist.github.com/samth/7088570
>>
>> This just passes multiple arguments between two functions in three
>> ways: with a cons, with multiple values, and by mutating an mcons
>> (plus a direct version with two local variables).  In all cases, it's
>> as fast as I can make it, using unsafe operations where appropriate.
>>
>> Here are some representative timings:
>>
>> [samth at huor:~/sw/plt/racket/collects/racket/match (master) plt] r /tmp/bench.rkt
>> 'direct
>> cpu time: 40 real time: 44 gc time: 0
>> 'cons
>> cpu time: 72 real time: 73 gc time: 12
>> 'values
>> cpu time: 192 real time: 191 gc time: 0
>> 'mcons
>> cpu time: 48 real time: 51 gc time: 0
>>
>> Direct is always fastest, multiple values are very slow, and cons is
>> always slower than mcons.  Even if we ignore GC time, the functional
>> version is still always slower.
>>
>> Sam
>

Posted on the users mailing list.