bench: lazily initialize script benchmarks#5190
bench: lazily initialize script benchmarks#5190iammdzaidalam wants to merge 1 commit intoboa-dev:mainfrom
Conversation
Test262 conformance changes
Tested main commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5190 +/- ##
===========================================
+ Coverage 47.24% 59.80% +12.55%
===========================================
Files 476 582 +106
Lines 46892 63414 +16522
===========================================
+ Hits 22154 37923 +15769
- Misses 24738 25491 +753 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| .unwrap_or_else(|| panic!("'main' is not a function in script: {}", path.display())) | ||
| .clone(); | ||
| group.bench_function("Execution", move |b| { | ||
| let prepared = prepared.get_or_insert_with(|| prepare_script_bench(&path)); |
There was a problem hiding this comment.
I don't think we should put the initialization code inside the benchmark, it'll just pollute the results.
There was a problem hiding this comment.
Was about to say. The reason we use the main function is to benchmark specific bits of VM, not the initialization and parsing (and optimization, etc).
There was a problem hiding this comment.
Oh, I was mainly trying to avoid the eager init issue but putting it inside the benchmark isnt the right tradeoff here... thinking of instead filtering before registration so only matching scripts get initialized, and keeping the setup outside bench_function like before
does that sound like the right direction?
Closes #5169
Summary
Defer script benchmark setup until the selected benchmark actually runs.
benches/benches/scripts.rswas eagerly reading, parsing, compiling, and evaluating every script during registration, so filtered runs could still fail on unrelated entries before reaching the requested benchmark.This moves that setup behind the benchmark closure and caches the prepared state per benchmark, so unmatched scripts are no longer initialized.
Changes
PreparedScriptBenchhelper for cached per-benchmark stateContextcreation, runtime registration, parse/compile/evaluate, andmainlookup into lazy setupv8-benchesgroup config unchangedVerification
Ran locally:
cargo fmt --checkcargo check -p boa_benchescargo bench -p boa_benches -- --listcargo bench -p boa_benches -- call-loopAlso temporarily added logging in the lazy init path to verify behavior:
call-looponly initializedbasic/call-loop.jsdeltablueonly initializedv8-benches/deltablue.jsSo filtered runs no longer initialize unrelated scripts first.