js-temporal / temporal-polyfill

Polyfill for Temporal (under construction)
ISC License
530 stars 28 forks source link

Speed up Test262 by using more threads #165

Closed justingrant closed 2 years ago

justingrant commented 2 years ago

On my Mac (2021 M1 Max 10-core MBP), setting threads to 2x the number of CPU cores resulted in a 35%-40% speedup when running Test262. More than 2x didn't seem to help.

I also bumped up the max thread limit to 32 to better take advantage of monster build/test machines that some lucky people (not me!) may have access to.

In CI, setting a minimum # of threads to 4 (previously was 1 thread) increases CI perf by 30%-40%. More than 4 didn't seem to help. CI, because it's on unpredictable resources, is harder to definitely prove increased perf, but I re-ran the CI test runs several times and got consistent results so I do feel comfortable that this PR provides a significant speedup. We can always revert if I just happened to be testing at a lucky time.

For non-Mac machines with 5+ cores, I left the thread calculation is unchanged because I didn't have a local Linux machine to test with and I didn't want to regress anyone's perf.

justingrant commented 2 years ago

FWIW, the latest test run (a few hours after my previous runs) still shows good speedup. Previous: https://github.com/js-temporal/temporal-polyfill/runs/7143762564 - 10m 52s This PR: https://github.com/js-temporal/temporal-polyfill/runs/7227471019 - 6m 42s

If we're happy with this change, then I can port it over to proposal-temporal too.

12wrigja commented 2 years ago

🎉 Nice speedups!