Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug
Link to entry on the feature dashboard
n/a [This change is relatively minor.]
ContactsSpecThe document accessor is documented in the HTML5 spec.The WebIDL spec demands that attributes (as interface members) are implemented as JavaScript accessors.SummaryRe-implement the 'document' accessor on the global object for improved spec compliance.Motivation(s)Presently, the'document' accessor on the global object is implemented as a data property. This violates the combined HTML5 + WebIDL (chapter 3, "In ECMAScript, the attributes on the IDL interfaces will be exposed as accessor properties [...]"). This was originally done because the 'document' attribute is accessed very frequently and the accessor mechanism noticeably slows this down.We intend to implement a new mechanism, where the value of the document is stored on a hidden data property on the window object, and teach V8 to transparently access that data property when the accessor is called. The 'true' accessor is still available and fully functional, which allows for full spec compliance without performance cost. Additionally, it will enable us to remove the 'ForceSet' APi call from V8, which was used solely to implement the old behaviour.
Interoperability and Compatibility RiskThis change should increase spec compliance and bring us more in line with other browsers (which have implemented the spec all along).Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug
Link to entry on the feature dashboard
n/a [This change is relatively minor.]
non-owner LGTMOn Tue, Sep 20, 2016 at 6:07 PM, 'Daniel Vogelheim' via blink-dev <blin...@chromium.org> wrote:ContactsSpecThe document accessor is documented in the HTML5 spec.The WebIDL spec demands that attributes (as interface members) are implemented as JavaScript accessors.SummaryRe-implement the 'document' accessor on the global object for improved spec compliance.Motivation(s)Presently, the'document' accessor on the global object is implemented as a data property. This violates the combined HTML5 + WebIDL (chapter 3, "In ECMAScript, the attributes on the IDL interfaces will be exposed as accessor properties [...]"). This was originally done because the 'document' attribute is accessed very frequently and the accessor mechanism noticeably slows this down.We intend to implement a new mechanism, where the value of the document is stored on a hidden data property on the window object, and teach V8 to transparently access that data property when the accessor is called. The 'true' accessor is still available and fully functional, which allows for full spec compliance without performance cost. Additionally, it will enable us to remove the 'ForceSet' APi call from V8, which was used solely to implement the old behaviour.Also let me add that the new mechanism provides a way for V8 bindings to "cache" return values of DOM attribute getters (not limited to window.document) on the V8 side. This means that V8 can access DOM attribute getters without leaving JIT code, which will speed up the binding layer a lot.
On Tue, Sep 20, 2016 at 10:22 AM, Kentaro Hara <har...@chromium.org> wrote:Motivation(s)Presently, the'document' accessor on the global object is implemented as a data property. This violates the combined HTML5 + WebIDL (chapter 3, "In ECMAScript, the attributes on the IDL interfaces will be exposed as accessor properties [...]"). This was originally done because the 'document' attribute is accessed very frequently and the accessor mechanism noticeably slows this down.We intend to implement a new mechanism, where the value of the document is stored on a hidden data property on the window object, and teach V8 to transparently access that data property when the accessor is called. The 'true' accessor is still available and fully functional, which allows for full spec compliance without performance cost. Additionally, it will enable us to remove the 'ForceSet' APi call from V8, which was used solely to implement the old behaviour.Also let me add that the new mechanism provides a way for V8 bindings to "cache" return values of DOM attribute getters (not limited to window.document) on the V8 side. This means that V8 can access DOM attribute getters without leaving JIT code, which will speed up the binding layer a lot.Does this require manual setup on our side, or will v8 just do this for all bindings now?
the thing about document what makes it special is that it's being accessed a lot. To get acceptable performance, we decided to violate the spec and make it a data property. Now a constant data property can't be changed, however, document changes its value during navigations, and so we added an API that allows for changing a value even if it's an constant.I'm not sure whether we can move all other methods - e.g. for an accessor that returns a different value basically on every call, it wouldn't make sense. Firefox has a number of annotations in its IDL files which are used to decide which optimizations to use. Looking at Edge, there appears to be only a special case for document, which is in alignment with our measurements - for all other attributes, using the getter everytime doesn't have a measurable real-world impact.
On Tue, Sep 20, 2016 at 11:47 AM, Jochen Eisinger <joc...@chromium.org> wrote:the thing about document what makes it special is that it's being accessed a lot. To get acceptable performance, we decided to violate the spec and make it a data property. Now a constant data property can't be changed, however, document changes its value during navigations, and so we added an API that allows for changing a value even if it's an constant.I'm not sure whether we can move all other methods - e.g. for an accessor that returns a different value basically on every call, it wouldn't make sense. Firefox has a number of annotations in its IDL files which are used to decide which optimizations to use. Looking at Edge, there appears to be only a special case for document, which is in alignment with our measurements - for all other attributes, using the getter everytime doesn't have a measurable real-world impact.fwiw this is not my observation, element.style spends a fair amount of time inside .style, we can get 5-10% by doing:var style = element.style;style.foo = ...;style.bar = ...;etc.
On Tue, Sep 20, 2016 at 12:51 PM Elliott Sprehn <esp...@chromium.org> wrote:On Tue, Sep 20, 2016 at 11:47 AM, Jochen Eisinger <joc...@chromium.org> wrote:the thing about document what makes it special is that it's being accessed a lot. To get acceptable performance, we decided to violate the spec and make it a data property. Now a constant data property can't be changed, however, document changes its value during navigations, and so we added an API that allows for changing a value even if it's an constant.I'm not sure whether we can move all other methods - e.g. for an accessor that returns a different value basically on every call, it wouldn't make sense. Firefox has a number of annotations in its IDL files which are used to decide which optimizations to use. Looking at Edge, there appears to be only a special case for document, which is in alignment with our measurements - for all other attributes, using the getter everytime doesn't have a measurable real-world impact.fwiw this is not my observation, element.style spends a fair amount of time inside .style, we can get 5-10% by doing:var style = element.style;style.foo = ...;style.bar = ...;etc.5-10% of overall pageload time on a non-benchmark website?
Do we have a mix in terms of observable behavior? I didn't test much, but document looked just like other attributes on window.
On Tue, Sep 20, 2016 at 11:53 AM, Jochen Eisinger <joc...@chromium.org> wrote:On Tue, Sep 20, 2016 at 12:51 PM Elliott Sprehn <esp...@chromium.org> wrote:On Tue, Sep 20, 2016 at 11:47 AM, Jochen Eisinger <joc...@chromium.org> wrote:the thing about document what makes it special is that it's being accessed a lot. To get acceptable performance, we decided to violate the spec and make it a data property. Now a constant data property can't be changed, however, document changes its value during navigations, and so we added an API that allows for changing a value even if it's an constant.I'm not sure whether we can move all other methods - e.g. for an accessor that returns a different value basically on every call, it wouldn't make sense. Firefox has a number of annotations in its IDL files which are used to decide which optimizations to use. Looking at Edge, there appears to be only a special case for document, which is in alignment with our measurements - for all other attributes, using the getter everytime doesn't have a measurable real-world impact.fwiw this is not my observation, element.style spends a fair amount of time inside .style, we can get 5-10% by doing:var style = element.style;style.foo = ...;style.bar = ...;etc.5-10% of overall pageload time on a non-benchmark website?JS performance is about a lot more than just page load. :) ex. view creation or running animations. Style is particularly bad since it's accessed in big blocks, ex.that kind of code is very common the web, where you assign many style properties in a row, if you do it for a large number of elements (ex. inline styles in react) the cost adds up. My numbers were from looking at Animometer in a profiler.Using .classList, .attributes, and other stable object APIs all have high overhead (over other browsers) due to the bindings.Fwiw I'm actually not sure why we keep a ptr to the .style, .classList or the .attributes object in the ElementRareData, couldn't we keep the ptr to it in the JS heap and not increase memory usage and get the perf improvement?
On Tue, Sep 20, 2016 at 12:56 PM Philip Jägenstedt <foo...@chromium.org> wrote:Do we have a mix in terms of observable behavior? I didn't test much, but document looked just like other attributes on window.ah, right. Yes, the idea is to eventually move them all (to match what the rest of the DOM looks like) https://bugs.chromium.org/p/chromium/issues/detail?id=475556
On Tue, Sep 20, 2016 at 1:07 PM Elliott Sprehn <esp...@chromium.org> wrote:On Tue, Sep 20, 2016 at 11:53 AM, Jochen Eisinger <joc...@chromium.org> wrote:On Tue, Sep 20, 2016 at 12:51 PM Elliott Sprehn <esp...@chromium.org> wrote:On Tue, Sep 20, 2016 at 11:47 AM, Jochen Eisinger <joc...@chromium.org> wrote:the thing about document what makes it special is that it's being accessed a lot. To get acceptable performance, we decided to violate the spec and make it a data property. Now a constant data property can't be changed, however, document changes its value during navigations, and so we added an API that allows for changing a value even if it's an constant.I'm not sure whether we can move all other methods - e.g. for an accessor that returns a different value basically on every call, it wouldn't make sense. Firefox has a number of annotations in its IDL files which are used to decide which optimizations to use. Looking at Edge, there appears to be only a special case for document, which is in alignment with our measurements - for all other attributes, using the getter everytime doesn't have a measurable real-world impact.fwiw this is not my observation, element.style spends a fair amount of time inside .style, we can get 5-10% by doing:var style = element.style;style.foo = ...;style.bar = ...;etc.5-10% of overall pageload time on a non-benchmark website?JS performance is about a lot more than just page load. :) ex. view creation or running animations. Style is particularly bad since it's accessed in big blocks, ex.that kind of code is very common the web, where you assign many style properties in a row, if you do it for a large number of elements (ex. inline styles in react) the cost adds up. My numbers were from looking at Animometer in a profiler.Using .classList, .attributes, and other stable object APIs all have high overhead (over other browsers) due to the bindings.Fwiw I'm actually not sure why we keep a ptr to the .style, .classList or the .attributes object in the ElementRareData, couldn't we keep the ptr to it in the JS heap and not increase memory usage and get the perf improvement?Yeah, I mean, I'm not saying that this isn't possible. I just don't think it makes sense to apply this pattern across the board. With this specific change for document, the value needs to be pushed to v8 every time it changes. For something that changes frequently, that would be prohibitively expensive.For getters that really always return the same value, we could just cache the result in v8 after calling once (as we already do for data properties)
On Tue, Sep 20, 2016 at 8:09 PM, Jochen Eisinger <joc...@chromium.org> wrote:On Tue, Sep 20, 2016 at 12:56 PM Philip Jägenstedt <foo...@chromium.org> wrote:Do we have a mix in terms of observable behavior? I didn't test much, but document looked just like other attributes on window.ah, right. Yes, the idea is to eventually move them all (to match what the rest of the DOM looks like) https://bugs.chromium.org/p/chromium/issues/detail?id=475556Right. yukishiino@ tried to move almost all Window's attributes to the prototype chain, but the CL was reverted due to an unexpected performance regression. (Maybe the trick we're discussing here is helpful to mitigate the performance regression.)
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
document is on the instance because of [Unforgeable].
Per https://software.hixie.ch/utilities/js/live-dom-viewer/saved/4487 it looks like location also changes on navigation, but presumably it's different from document?
There're a lot of discussions going on this thread :) Let me try to sum up.1) Currently Window's attributes are implemented as data properties. We should move them to accessor properties per the spec.2) yukishiino@'s CL tried to move them to accessor properties but was reverted due to performance regressions.
There're a lot of discussions going on this thread :) Let me try to sum up.1) Currently Window's attributes are implemented as data properties. We should move them to accessor properties per the spec.2) yukishiino@'s CL tried to move them to accessor properties but was reverted due to performance regressions.3) This Intent-to-ship is proposing to move only window.document to an accessor property in a way that doesn't regress performance (=attribute caching).3) is clearly moving things forward, so this Intent-to-ship LGTM. Once it lands, we should try to move all the remaining Window's attributes to accessor properties (probably by relanding yukishiino@'s CL using the attribute caching).Does it make sense?