Status: New
Owner: ----

New issue 3610 by [email protected]: Extremely reduced performance in properties with variable keys
https://code.google.com/p/v8/issues/detail?id=3610

Assigning an property to an object with a variable key
    myHash[myVariable] = 'value' # case A
recently started performing much worse than without a variable
    myHash.myKey = 'value' # case B
It seems that, when the performance of B was purposely improved,
the performance of A was accidentally drastically reduced.

In this example: http://jsperf.com/bindings-assignments,
the performance of B doubled from Chrome 37 to 40,
but the performance of A got 10 times worse.

Example code:

    // What we actually want to do
    function setBindings(templateTriple, triple) {
      var bindings = {};
      bindings[templateTriple.subject]   = triple.subject;
      bindings[templateTriple.predicate] = triple.predicate;
      bindings[templateTriple.object]    = triple.object;
      return bindings;
    }

    // Non-functional alternative
    function setBindingsWithoutVars(templateTriple, triple) {
      var bindings = {};
      bindings['?a'] = triple.subject;
      bindings['?b'] = triple.predicate;
      bindings['?c'] = triple.object;
      return bindings;
    }

    // Non-functional alternative
    function setBindingsInitFields(templateTriple, triple) {
      var bindings = { '?a': '', '?b': '', '?c': '' };
      bindings[templateTriple.subject]   = triple.subject;
      bindings[templateTriple.predicate] = triple.predicate;
      bindings[templateTriple.object]    = triple.object;
      return bindings;
    }

Example invocations:

setBindings({ subject: '?a', predicate: '?b', object: '?c' },
            { subject: 'x',  predicate: 'y',  object: 'z'  });

setBindingsWithoutVars({ subject: '?a', predicate: '?b', object: '?c' },
                       { subject: 'x',  predicate: 'y',  object: 'z' });

setBindingsInitFields({ subject: '?a', predicate: '?b', object: '?c' },
                       { subject: 'x',  predicate: 'y',  object: 'z' });

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to