Re: [w3c/webcomponents] Support /deep/ in static profile (bugzilla: 28591) (#78)

Blink implemented '>>>' under the experimental web platform features flag.

I tried to get a rough number how fast/slow the native implementation and emulated by JS:
https://gist.github.com/TakayoshiKochi/04fe33f40543ce07bdc53ecdfb6cc2e0

The code creates 64-shadow roots(4x4x4)/2048-leaf elements tree, and search `<span>` elements in it.
For 100 iterations, native implementation ran in ~30ms, while the emulated code required ~900ms
on my local workstation.  So roughly 30x fast.

But it seems (not verified yet) the slowness comes from the fact that querySelectorAll() cannot find shadow hosts and the code has to iterate over all elements. If we had a fast implementation of `querySelectorAll(':shadowhost')`, the emulation could be much faster.

I added class for each shadow host and used the class in querySelectorAll to match them, then
https://gist.github.com/TakayoshiKochi/a4385510e4f483a02dd0027eb215cfe1
the emulated code ran in ~120ms, which got much speedup, but is still 4x slower than native.

My takeaway (only in terms of performance) is that the native implementation gives enough speedup against polyfilled JS code.  If a very fast lookup method for finding shadow hosts is invented, a generic polyfill might be tolerable, otherwise too slow to use.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/78#issuecomment-264403496

Received on Friday, 2 December 2016 08:49:42 UTC