Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/parallel/test-process-exit-background-gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if (!common.hasCrypto) { common.skip('missing crypto'); }
// waiting for a GC that the main thread no longer performs.

const { pbkdf2, pbkdf2Sync } = require('crypto');
const password = 'top secret';
const salt = '0123456789abcdef';

// A small live set keeps the old generation limit low.
const keep = [];
Expand All @@ -16,15 +18,15 @@ for (let i = 0; i < 1e5; i++) keep.push({ i });
// Pick an iteration count that keeps the threadpool busy for about a second.
const probeIterations = 2e5;
const start = process.hrtime.bigint();
pbkdf2Sync('a', 'b', probeIterations, 64, 'sha512');
pbkdf2Sync(password, salt, probeIterations, 64, 'sha512');
const nsPerIteration = Number(process.hrtime.bigint() - start) /
probeIterations;
const iterations = Math.ceil(1e9 / nsPerIteration);

setTimeout(() => {
// uv_library_shutdown() waits for this job, so the main thread stays out of
// JS and cannot serve the GC that the stress allocation task asks for.
pbkdf2('a', 'b', iterations, 64, 'sha512', () => {});
pbkdf2(password, salt, iterations, 64, 'sha512', () => {});
// Use up the old generation budget, so that the next background allocation
// fails and parks that task in CollectionBarrier.
for (let i = 0; i < 40; i++) new Array(1e5).fill(i);
Expand Down
Loading