Bug 245817

Summary: Prototype streaming for declarative shadow DOM
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: DOMAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=245556
Bug Depends on:    
Bug Blocks: 148695    
Attachments:
Description Flags
perf test
none
standalone perf test none

Description Ryosuke Niwa 2022-09-29 00:28:38 PDT
Add an even-more-experimental streaming version of declarative shadow DOM.
Comment 1 Ryosuke Niwa 2022-09-29 00:35:57 PDT
Pull request: https://github.com/WebKit/WebKit/pull/4822
Comment 2 EWS 2022-09-29 19:38:33 PDT
Committed 255020@main (c0bda7319ffb): <https://commits.webkit.org/255020@main>

Reviewed commits have been landed. Closing PR #4822 and removing active labels.
Comment 3 Radar WebKit Bug Importer 2022-09-29 19:39:18 PDT
<rdar://problem/100593236>
Comment 4 Ryosuke Niwa 2022-10-04 01:11:14 PDT
Created attachment 462782 [details]
perf test
Comment 5 Ryosuke Niwa 2022-10-04 01:16:35 PDT
Using the attached performance test, I've observed the following numbers on my 14" M1 Max MacBookPro.

First, using polyfill for declarative shadow DOM, we observe that:

:Time -> [221, 210.0000000000001, 210, 218, 215, 218.99999999999977, 217.99999999999977, 233, 214, 208, 218, 232, 206, 210, 204.00000000000045, 207.00000000000045, 227, 192, 205, 215] ms
    mean: 214.1 ms
    median: 214.5 ms
    stdev: 9.840303803611327 ms
    min: 192 ms
    max: 233 ms


Using native declarative shadow DOM without streaming (i.e. same as Blink's implementation), we observe that:

:Time -> [163, 174, 198, 158, 157, 157.00000000000023, 158, 180, 157, 156, 158, 168, 159, 162.00000000000045, 158.00000000000045, 158, 169, 158.00000000000045, 160, 163.00000000000045] ms
    mean: 163.5500000000001 ms
    median: 158.50000000000023 ms
    stdev: 10.318481120377072 ms
    min: 156 ms
    max: 198 ms

This mean is 23.6% faster than polyfill.

Finally, using native declarative shadow DOM with streaming (i.e. shadow root is attached at the start tag instead of the end tag), we observe that:

:Time -> [142, 152.00000000000006, 167.99999999999994, 150, 142.0000000000001, 144.9999999999999, 177, 155, 147, 166, 144, 142, 142, 147, 185, 142, 143, 162.99999999999955, 141, 143] ms
    mean: 151.8 ms
    median: 145.99999999999994 ms
    stdev: 13.069047402163593 ms
    min: 141 ms
    max: 185 ms

This mean is 29.1% faster than polyfill and 7% faster than non-streaming version.
Comment 6 Ryosuke Niwa 2022-10-04 01:20:51 PDT
Created attachment 462783 [details]
standalone perf test