Repository navigation
Release each iteration's handles in the bench-jsstring NonFlat loops - #8552
Conversation
There was a problem hiding this comment.
Superseded by the review of
d23efd98.
This review, of 264ef900
✅ Approved — Small, targeted change to a benchmark file. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code reviewer: ✅ LGTM
No issues found.
Reviewed commit: 264ef900
264ef90 to
d23efd9
Compare
There was a problem hiding this comment.
Superseded by the review of
073e6b01.
This review, of d23efd98
✅ Approved — This is a small, targeted fix to a benchmark: each iteration's handles are released, which removes the unbounded heap growth. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No issues found.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
No issues found. Each NonFlat loop body is wrapped in js.withinHandleScope. The lambdas return void, so a plain v8::HandleScope is used, and piece is created outside the scope, so it stays valid across iterations.
⚡ Performance: ✅ LGTM
No issues found.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: d23efd98
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8552 +/- ##
==========================================
- Coverage 66.70% 66.70% -0.01%
==========================================
Files 797 797
Lines 204157 204157
Branches 31724 31724
==========================================
- Hits 136192 136189 -3
- Misses 49384 49385 +1
- Partials 18581 18583 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The nine JsString_Utf8Length_*_NonFlat benchmarks build a cons string with 7 to 31 concat calls on every iteration, but the only HandleScope is the one runInIoContext opens around the whole loop. Every cons string, and the flat copy utf8Length makes, stayed reachable until the benchmark returned. For the 8192-char cases that is about 16.6 KB per iteration: after 20000 iterations 325 MB of the V8 heap is still live. On a fast runner Google Benchmark picks around 80000 iterations, V8 reaches its heap limit (1368 MB live, nothing freed) and the test aborts, which is the windows bench-jsstring flake. Forcing 200000 iterations of NonFlat_8192 reproduces it on Linux. In this patch each NonFlat loop body runs in js.withinHandleScope(), so an iteration's strings become garbage when it ends. The timed work is the same. The old times were mostly GC marking the growing heap, so the numbers drop: NonFlat, Linux -c opt before after heap live, 8192, 20000 it 325 MB 1.0 MB Latin1_8192 median 28.6 us 2.59 us Utf16_8192 median 26.4 us 2.88 us Utf16_Invalid_8192 median 33.5 us 12.6 us Latin1_256 median 2.24 us 0.40 us
d23efd9 to
073e6b0
Compare
There was a problem hiding this comment.
Superseded by the review of
d889269f.
This review, of 073e6b01
✅ Approved — This is a small, targeted fix to a benchmark: each iteration's handles are released, which removes the unbounded heap growth. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No issues found.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
No issues found. Each NonFlat loop body is wrapped in js.withinHandleScope. The lambdas return void, so a plain v8::HandleScope is used, and piece is created outside the scope, so it stays valid across iterations.
⚡ Performance: ✅ LGTM
No issues found.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: 073e6b01 — same changes as d23efd98, so this is that commit's review (no new review was run; line numbers are as of d23efd98)
There was a problem hiding this comment.
✅ Approved — This is a small, targeted fix to a benchmark: each iteration's handles are released, which removes the unbounded heap growth. No issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No issues found.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
No issues found. Each NonFlat loop body is wrapped in js.withinHandleScope. The lambdas return void, so a plain v8::HandleScope is used, and piece is created outside the scope, so it stays valid across iterations.
⚡ Performance: ✅ LGTM
No issues found.
📝 Documentation: ✅ LGTM
No issues found.
Reviewed commit: d889269f — same changes as d23efd98, so this is that commit's review (no new review was run; line numbers are as of d23efd98)
The nine
JsString_Utf8Length_*_NonFlatbenchmarks build a cons string with 7 to 31concatcalls on every iteration. The onlyHandleScope, though, is the onerunInIoContextopens around the whole loop. So every cons string, and the flat copyutf8Lengthmakes, stays reachable until the benchmark returns. For the 8192-character cases that's about 16.6 KB per iteration, and after 20000 iterations 325 MB of the V8 heap is still live. On a fast runner Google Benchmark picks around 80000 iterations. V8 then hits its heap limit, with 1368 MB live and nothing freed, and the test aborts. That is the flaky windowsbench-jsstringfailure. Forcing 200000 iterations ofNonFlat_8192reproduces it on Linux too.In this patch each NonFlat loop body runs in
js.withinHandleScope(), so an iteration's strings become garbage when it ends. The timed work is the same. The old times were mostly GC marking the growing heap, so the numbers drop:Measured with
bazel test -c opton Linux. The heap row comes fromGetHeapStatistics()after the loop, and the times are medians of 3 repetitions.