Comment #30 on issue 164 by charles.kendrick: Wrong order in Object properties interation
http://code.google.com/p/v8/issues/detail?id=164

Precisely, this is an "optimization" used to score better in synthetic benchmarks, while real-world performance will actually be degraded.

And not just performance. Say you are dynamically providing the set of options for a drop-down list in JavaScript. Essentially all Ajax widget kits have such an API, and usage is generally:

   selectControl.setOptions({
      storedValue1 : "displayValue1",
      storedValue2 : "displayValue2",
      storedValue3 : "displayValue3"
   })

Now we're going to be telling all of customers and users "If you want to support the Chrome browser, you must change your code to":

   selectControl.setOptions(
      ["storedValue1",
       "storedValue2",
       "storedValue3"],
      ["displayValue1",
       "displayValue2",
       "displayValue3"]
   })

This:

1. is awkward and unnatural, it doesn't correspond to how a list of options is specified in HTML

2. involves *double* the number of GC-tracked objects (6 strings and 2 Arrays vs one Object and 3 Strings - slots don't GC)

3. requires code to track, store and update two objects to represent an ordered Map instead of just one

So let's please connect the dots here - we've got several optimization experts talking about how this provides a great speed boost *for Arrays*, and several application developers pointing out that if it's applied *to Objects* it breaks existing applications and will degrade performance in the real world.

Solution: be order-preserving for Object, not order-preserving for Arrays.

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

Reply via email to