Hi Nicholas,

Thanks a lot for letting us know about your findings! I noticed your
discussions on the Mozilla bug tracker the other day and filed
http://code.google.com/p/v8/issues/detail?id=690.

Cheers,
Kasper

On Mon, May 3, 2010 at 7:15 AM, Nicholas Nethercote
<[email protected]> wrote:
> Hi,
>
> I was looking at v8-splay.js from the V8 benchmarks recently.  It's an
> awful benchmark.  It contains this function:
>
> function GeneratePayloadTree(depth, key) {
>  if (depth == 0) {
>    return {
>      array  : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
>      string : 'String for key ' + key + ' in leaf node'
>    };
>  } else {
>    return {
>      left:  GeneratePayloadTree(depth - 1, key),
>      right: GeneratePayloadTree(depth - 1, key)
>    };
>  }
> }
>
> This function is called many times with 'depth' set to 5 and 'key' set
> to a randomly-generated double.  With these parameters it creates the
> same string "String for key <whatever> in leaf node" 32 times, once
> per leaf call.  This involves a double-to-string conversion and then
> two string concatenations.
>
> The benchmark has this comment at the top:
>
> // This benchmark is based on a JavaScript log processing module used
> // by the V8 profiler to generate execution time profiles for runs of
> // JavaScript applications, and it effectively measures how fast the
> // JavaScript engine is at allocating nodes and reclaiming the memory
> // used for old nodes. Because of the way splay trees work, the engine
> // also has to deal with a lot of changes to the large tree object
> // graph.
>
> This isn't true.  Because GeneratePayloadTree() is so stupid, the
> benchmark is actually primarily measuring the speed of
> double-to-string conversions.  The following trivial change is all
> that's required to make the benchmark less stupid:
>
> Index: tests/v8-v4/v8-splay.js
> ===================================================================
> --- tests/v8-v4/v8-splay.js     (revision 58474)
> +++ tests/v8-v4/v8-splay.js     (working copy)
> @@ -45,7 +45,7 @@
>   if (depth == 0) {
>     return {
>       array  : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
> -      string : 'String for key ' + key + ' in leaf node'
> +      string : key
>     };
>   } else {
>     return {
> @@ -69,7 +69,7 @@
>   do {
>     key = GenerateKey();
>   } while (splayTree.find(key) != null);
> -  splayTree.insert(key, GeneratePayloadTree(kSplayTreePayloadDepth, key));
> +  splayTree.insert(key, GeneratePayloadTree(kSplayTreePayloadDepth, 'String 
> for
>  key ' + key + ' in leaf node'));
>   return key;
>  }
>
> I tested with Mozilla's TraceMonkey JS engine, it ran about 2.8x
> faster with this change in place.
>
> Any chance this change could make it into the next version of V8?  I'm
> happy to file a bug if someone can tell me where.
>
> N
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to