Skip to content

[WIP] WASM: share empty child arrays - #1910

Open
peaBerberian wants to merge 1 commit into
devfrom
wasm-lazy-child-arrays
Open

peaBerberian wants to merge 1 commit into
devfrom
wasm-lazy-child-arrays

Conversation

@peaBerberian

Copy link
Copy Markdown
Collaborator

Preamble (repeated for the current wave of WASM PRs)

I'm doing several PR related to our optional WebAssembly DASH parser.

This parser was initially specifically optimized for DASH MPD with huge <SegmentTimeline> elements (several MB) for some of Canal+'s own contents.

Testing it lately, it is still the main scenario where it clearly shines against our default JS parser.
Since that time however, the DASH spec and DASH packagers have evolved a lot and those bigger MPDs are now very rarely encountered. At Canal+, this led us back to advise the usage of our simpler default JS parser to applications. Yet we still continued maintaining in a best-effort way our WASM parser, as we know some external applications continue to rely on it.

It's been a few years since we've really dived deeply into it however, and with the new tools at our disposal now (notably LLMs, particularly adapted here as we've two pieces of code - the JS and WASM parsers - which are supposed to give the same output), there's some areas for a few quick wins in terms of conformance, in terms of testing against regressions, and in terms of performance.

What this PR does

Reuse the same "empty" array reference. As we might have a lot of it in our parser. (actually allocate a new array for non-empty).

We'll see in CI if there's a point

@peaBerberian peaBerberian added work-in-progress This Pull Request or issue is not finished yet WASM Relative to our WebAssembly code labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown

✅ Automated performance checks have passed on commit 5887cb48171b016402bd14ad2eed713a9bc694f7 with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
DASH JS parser - regular manifest (20 parses) 29.57ms -> 29.69ms (corrected: 0.076ms, A/A bias: -0.193ms, z: 0.12028) 29.70ms -> 29.70ms (corrected: 0.075ms, A/A bias: -0.175ms, z: 0.11547)
DASH WASM parser - regular manifest (20 parses) 16.43ms -> 15.25ms (corrected: 1.350ms, A/A bias: -0.168ms, z: 0.10585) 14.50ms -> 14.90ms (corrected: -0.225ms, A/A bias: -0.075ms, z: 0.49075)
DASH JS parser - many AdaptationSets (20 parses) 15.90ms -> 15.50ms (corrected: 0.258ms, A/A bias: 0.137ms, z: 0.34641) 15.20ms -> 15.05ms (corrected: 0.075ms, A/A bias: 0.025ms, z: 0.60622)
DASH WASM parser - many AdaptationSets (20 parses) 17.04ms -> 16.46ms (corrected: 0.662ms, A/A bias: -0.078ms, z: 2.35751) 16.50ms -> 15.90ms (corrected: 0.600ms, A/A bias: 0.025ms, z: 3.72872)
DASH JS parser - short SegmentTimeline (100 parses) 4.24ms -> 4.39ms (corrected: -0.173ms, A/A bias: 0.023ms, z: 3.03590) 4.00ms -> 4.30ms (corrected: -0.275ms, A/A bias: 0.000ms, z: 3.04071)
DASH WASM parser - short SegmentTimeline (100 parses) 3.61ms -> 3.57ms (corrected: 0.034ms, A/A bias: 0.007ms, z: 0.94782) 3.40ms -> 3.40ms (corrected: -0.100ms, A/A bias: 0.050ms, z: 1.70799)
DASH JS parser - medium SegmentTimeline (4 parses) 5.55ms -> 5.62ms (corrected: -0.065ms, A/A bias: -0.013ms, z: 1.03442) 5.40ms -> 5.50ms (corrected: -0.050ms, A/A bias: 0.000ms, z: 1.50111)
DASH WASM parser - medium SegmentTimeline (4 parses) 3.13ms -> 3.07ms (corrected: 0.092ms, A/A bias: -0.039ms, z: 0.98631) 3.10ms -> 3.00ms (corrected: 0.025ms, A/A bias: 0.000ms, z: 1.43856)
DASH JS parser - eight-hour SegmentTimeline (1 parse) 60.17ms -> 60.14ms (corrected: 1.633ms, A/A bias: -1.598ms, z: 0.24056) 55.55ms -> 56.75ms (corrected: -1.625ms, A/A bias: -0.825ms, z: 0.24056)
DASH WASM parser - eight-hour SegmentTimeline (1 parse) 32.62ms -> 31.64ms (corrected: 1.311ms, A/A bias: -0.330ms, z: 0.26943) 28.80ms -> 29.20ms (corrected: -0.075ms, A/A bias: -0.050ms, z: 0.26943)
loading 22.98ms -> 20.39ms (corrected: 2.580ms, A/A bias: 0.011ms, z: 0.10585) 16.70ms -> 16.80ms (corrected: 0.025ms, A/A bias: -0.025ms, z: 0.43301)
seeking 516.13ms -> 548.52ms (corrected: -59.997ms, A/A bias: 27.608ms, z: 1.37602) 1004.60ms -> 1004.90ms (corrected: -0.525ms, A/A bias: 0.350ms, z: 1.02480)
audio-track-reload 22.54ms -> 22.63ms (corrected: 0.123ms, A/A bias: -0.212ms, z: 0.09141) 22.30ms -> 22.60ms (corrected: 0.025ms, A/A bias: -0.025ms, z: 0.13953)
loading over active content 13.39ms -> 12.77ms (corrected: 0.790ms, A/A bias: -0.176ms, z: 0.68320) 12.60ms -> 12.60ms (corrected: 0.075ms, A/A bias: -0.100ms, z: 0.68320)
large multi-period manifest 51.83ms -> 51.75ms (corrected: 0.051ms, A/A bias: 0.036ms, z: 0.08660) 50.30ms -> 51.45ms (corrected: 0.350ms, A/A bias: -0.325ms, z: 0.08660)
cold loading multithread 37.96ms -> 37.38ms (corrected: 3.206ms, A/A bias: -2.627ms, z: 2.65581) 37.20ms -> 36.75ms (corrected: 0.475ms, A/A bias: -0.075ms, z: 2.87713)
seeking multithread 881.50ms -> 841.65ms (corrected: 4.709ms, A/A bias: 35.138ms, z: 0.05774) 1005.60ms -> 1005.50ms (corrected: -0.025ms, A/A bias: 0.225ms, z: 0.89489)
audio-track-reload multithread 22.88ms -> 22.68ms (corrected: 0.302ms, A/A bias: -0.103ms, z: 1.05366) 22.70ms -> 22.40ms (corrected: 0.325ms, A/A bias: -0.050ms, z: 2.03997)
hot loading multithread 14.41ms -> 14.22ms (corrected: 0.296ms, A/A bias: -0.107ms, z: 2.12657) 14.20ms -> 14.10ms (corrected: 0.325ms, A/A bias: -0.150ms, z: 2.29497)

@github-actions

Copy link
Copy Markdown

✅ Automated performance checks have passed on commit af9230eda33df8059fbd2efff651bc3ef0169888 with the base branch dev.

Details

Performance tests 1st run output

No significative change in performance for tests:

Name Mean Median
DASH JS parser - regular manifest (20 parses) 41.82ms -> 42.05ms (corrected: 0.148ms, A/A bias: -0.375ms, z: 0.25981) 40.70ms -> 39.40ms (corrected: -0.350ms, A/A bias: 0.175ms, z: 0.26943)
DASH WASM parser - regular manifest (20 parses) 19.44ms -> 19.84ms (corrected: -0.878ms, A/A bias: 0.481ms, z: 1.45300) 17.40ms -> 17.80ms (corrected: -0.600ms, A/A bias: 0.100ms, z: 1.51554)
DASH JS parser - many AdaptationSets (20 parses) 24.89ms -> 24.71ms (corrected: 0.163ms, A/A bias: 0.021ms, z: 0.71207) 23.80ms -> 23.70ms (corrected: 0.150ms, A/A bias: -0.025ms, z: 0.41377)
DASH WASM parser - many AdaptationSets (20 parses) 17.95ms -> 17.94ms (corrected: 0.003ms, A/A bias: 0.009ms, z: 0.13472) 16.70ms -> 16.80ms (corrected: 0.125ms, A/A bias: -0.075ms, z: 0.07217)
DASH JS parser - short SegmentTimeline (100 parses) 6.84ms -> 7.02ms (corrected: -0.170ms, A/A bias: -0.006ms, z: 1.48668) 6.60ms -> 6.80ms (corrected: -0.100ms, A/A bias: -0.050ms, z: 2.19393)
DASH WASM parser - short SegmentTimeline (100 parses) 5.62ms -> 5.59ms (corrected: 0.016ms, A/A bias: 0.009ms, z: 0.19726) 5.40ms -> 5.40ms (corrected: 0.000ms, A/A bias: 0.000ms, z: 0.64471)
DASH JS parser - medium SegmentTimeline (4 parses) 9.08ms -> 8.94ms (corrected: 0.151ms, A/A bias: -0.009ms, z: 0.92376) 8.80ms -> 8.70ms (corrected: 0.000ms, A/A bias: 0.025ms, z: 0.68801)
DASH WASM parser - medium SegmentTimeline (4 parses) 5.24ms -> 5.34ms (corrected: -0.135ms, A/A bias: 0.031ms, z: 2.14101) 5.20ms -> 5.30ms (corrected: -0.100ms, A/A bias: 0.000ms, z: 0.91895)
DASH JS parser - eight-hour SegmentTimeline (1 parse) 88.39ms -> 91.09ms (corrected: -2.548ms, A/A bias: -0.152ms, z: 0.66876) 82.95ms -> 85.80ms (corrected: -8.075ms, A/A bias: 1.725ms, z: 0.66876)
DASH WASM parser - eight-hour SegmentTimeline (1 parse) 51.88ms -> 52.04ms (corrected: 0.316ms, A/A bias: -0.471ms, z: 0.17321) 46.70ms -> 46.50ms (corrected: -0.125ms, A/A bias: -0.800ms, z: 0.17321)
loading 27.28ms -> 27.10ms (corrected: -0.957ms, A/A bias: 1.133ms, z: 0.25981) 22.40ms -> 22.30ms (corrected: 0.025ms, A/A bias: 0.125ms, z: 0.25500)
seeking 134.08ms -> 141.88ms (corrected: -12.836ms, A/A bias: 5.038ms, z: 0.92376) 11.40ms -> 11.90ms (corrected: -1.050ms, A/A bias: 0.350ms, z: 2.55477)
audio-track-reload 34.12ms -> 34.14ms (corrected: -0.047ms, A/A bias: 0.021ms, z: 0.27905) 33.50ms -> 33.95ms (corrected: 0.125ms, A/A bias: -0.250ms, z: 0.15877)
loading over active content 20.49ms -> 20.59ms (corrected: -0.222ms, A/A bias: 0.129ms, z: 0.32717) 19.35ms -> 19.65ms (corrected: -1.150ms, A/A bias: 1.050ms, z: 0.32717)
large multi-period manifest 80.22ms -> 79.88ms (corrected: -0.459ms, A/A bias: 0.795ms, z: 0.18283) 73.95ms -> 73.30ms (corrected: 4.825ms, A/A bias: 0.150ms, z: 0.18283)
cold loading multithread 52.70ms -> 52.02ms (corrected: 0.496ms, A/A bias: 0.184ms, z: 1.13546) 51.70ms -> 51.00ms (corrected: 0.625ms, A/A bias: -0.000ms, z: 3.47854)
seeking multithread 73.90ms -> 116.43ms (corrected: -80.035ms, A/A bias: 37.507ms, z: 2.56921) 13.50ms -> 13.70ms (corrected: -0.325ms, A/A bias: 0.175ms, z: 2.07846)
audio-track-reload multithread 31.12ms -> 31.08ms (corrected: 0.537ms, A/A bias: -0.500ms, z: 1.44338) 30.30ms -> 30.30ms (corrected: 0.175ms, A/A bias: -0.250ms, z: 0.45226)
hot loading multithread 21.29ms -> 21.19ms (corrected: -0.272ms, A/A bias: 0.376ms, z: 0.62546) 20.40ms -> 20.40ms (corrected: -0.100ms, A/A bias: 0.075ms, z: 0.72169)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WASM Relative to our WebAssembly code work-in-progress This Pull Request or issue is not finished yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant