Open Bug 2029617 Opened 2 months ago Updated 1 month ago

Improve J2CL benchmark performance

Categories

(Core :: JavaScript: WebAssembly, task, P2)

task

Tracking

()

People

(Reporter: jpages, Assigned: jpages)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files)

Severity: -- → N/A
Priority: -- → P2
See Also: → 1998005

As of right now, 9th April 2026, I have the following scores when benchmarking J2CL in the browsers (link: https://webkit-jetstream-preview.netlify.app/?test=j2cl-box2d-wasm):

  • Firefox nightly 229.40
  • Chrome canary 280

Which is around a 25% performance gap compared to V8. Surprisingly, I can see a lot of variance in the numbers in the browser, but Chrome is still ahead. I can reproduce a similar gap in performance in the shell versions of these benchmarks.

Top wasm functions for SpiderMonkey for this benchmark:

  • wasm-function[167]
  • wasm-function[241]
  • wasm-function[151]
  • wasm-function[29]
  • wasm-function[186]

Some points I have noted during analysis, for these top functions:

  • There are of lot of struct accesses in the top functions -> need to look at struct creations to see if anything could be improved
  • I could also observe quite a lot of spilling, high register pressure in general -> potential RA improvement (likely very hard to do) or LICM, CSE
  • Some arrays usage in the top functions as well, potential for arrays scalar replacement or other optimization (bound-checks elimination for example) around arrays
  • Lot of casts in the top functions
  • There is a call in the inner loop of of function-167 which is not inlined

Numbers for the associated patch:

To reduce variance, I've ran some benchmarks by pinning the task to 4 P cores, on Linux:
taskset -c 1,4 perf stat -r 30 -e instructions,cycles,cache-misses,branches,branch-misses js cli.js --test=j2cl-box2D-wasm

Here is the collected data:

Metric              Before        After         Change
--------------------------------------------------------
JetStream score     190.05        203.51        +7.08%
Wall time           838.57 ms     772.67 ms     -7.86%
perf elapsed        0.873445 s    0.808346 s    -7.45%
Instructions        11.710B       11.427B       -2.41%
Cycles              4.163B        3.918B        -5.89%
IPC                 2.81          2.92          +3.91%
Cache misses        15.93M        16.01M        +0.48%
Branches            1.782B        1.785B        +0.15%
Branch misses       12.24M        12.30M        +0.51%
Branch miss rate    0.6866%       0.6890%       ~0%

I'm currently trying to confirm this in CI. This pass seems to eliminate a lot of loads in the top function-167, from 509 -> 350.

Attached file func167.js

func167.js file is the top function from j2cl extracted from the benchmark, it allows to look at the generated code in a simple way.

Blocks: wasm-gc-perf
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: