Skip to content

Commit fb940ca

Browse files
authored
[test] Fix flake in test_dlopen_binary_not_retained (#28041)
In V8, `--concurrent-array-buffer-sweeping` is enabled by default, so a single synchronous `gc()` call spawns a background `SweepingJob` and returns before `ArrayBufferSweeper::FinalizeAndDelete` frees dead `ArrayBuffer` backing stores and updates `process.memoryUsage().arrayBuffers`. Under CPU contention on CI bots, the main thread can read `process.memoryUsage().arrayBuffers` before the background sweep job completes. Call `gc()` twice before each measurement so that the start of the second `gc()` (`ArrayBufferSweeper::EnsureFinished()`) waits for the first `gc()`'s background sweep job to finish. See: #28002
1 parent 7ce1535 commit fb940ca

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎test/test_other.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7325,6 +7325,10 @@ def test_dlopen_binary_not_retained(self):
73257325

73267326
int main() {
73277327
EM_ASM({
7328+
// Call gc() twice because V8 sweeps ArrayBuffer backing stores
7329+
// concurrently on a background thread; the start of the second gc()
7330+
// waits for the first gc()'s ArrayBufferSweeper job to finish.
7331+
gc();
73287332
gc();
73297333
globalThis.before = process.memoryUsage().arrayBuffers;
73307334
});
@@ -7333,6 +7337,7 @@ def test_dlopen_binary_not_retained(self):
73337337
int (*side_fn)(int) = dlsym(h, "side_fn");
73347338
assert(side_fn && side_fn(1) == 2);
73357339
int retained_mb = EM_ASM_INT({
7340+
gc();
73367341
gc();
73377342
return (process.memoryUsage().arrayBuffers - globalThis.before) >> 20;
73387343
});

0 commit comments

Comments
 (0)