From 5ed4f431cf6e57f1a7fc601004b7dc6ccf81a143 Mon Sep 17 00:00:00 2001 From: Keyhan Vakil Date: Thu, 4 Aug 2022 21:43:39 -0700 Subject: [PATCH] test: tune down parallelism for some flaky tests These tests seem to timeout quite often. I don't know why, but one possible reason is that they are starting a lot of threads. It seems that tests in `test/parallel` are assumed to only start one thread each, so having 11 threads running at a time feels like a lot. It also seems that these tests fail in a correlated fashion: take a look at [this reliability report][]. The failures all occur on the same build machines on the same PRs. This suggests to me some sort of CPU contention. [this reliability report]: https://github.com/nodejs/reliability/issues/334 On my Linux machine decreasing the parallelism & iterations here reduce the `user` time from ~11.5 seconds to ~2 seconds, depending on the test. I have seen these tests take 30-60 seconds on CI (Alpine in particular). I went back to the diffs that introduced that introduced these changes and verified that they failed at least 90% of the time with the reduced iteration count, which feels sufficient. Refs: https://github.com/nodejs/node/issues/43499 Refs: https://github.com/nodejs/node/issues/43084 PR-URL: https://github.com/nodejs/node/pull/44090 Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca --- test/parallel/test-worker-fshandles-error-on-termination.js | 4 ++-- .../test-worker-fshandles-open-close-on-termination.js | 4 ++-- test/parallel/test-worker-http2-stream-terminate.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-worker-fshandles-error-on-termination.js b/test/parallel/test-worker-fshandles-error-on-termination.js index 72fb969963a2b0..ada99a991bcc97 100644 --- a/test/parallel/test-worker-fshandles-error-on-termination.js +++ b/test/parallel/test-worker-fshandles-error-on-termination.js @@ -6,8 +6,8 @@ const fs = require('fs/promises'); const { scheduler } = require('timers/promises'); const { parentPort, Worker } = require('worker_threads'); -const MAX_ITERATIONS = 20; -const MAX_THREADS = 10; +const MAX_ITERATIONS = 5; +const MAX_THREADS = 6; // Do not use isMainThread so that this test itself can be run inside a Worker. if (!process.env.HAS_STARTED_WORKER) { diff --git a/test/parallel/test-worker-fshandles-open-close-on-termination.js b/test/parallel/test-worker-fshandles-open-close-on-termination.js index 2cbd886b15fe4e..db7c0221fcc1a3 100644 --- a/test/parallel/test-worker-fshandles-open-close-on-termination.js +++ b/test/parallel/test-worker-fshandles-open-close-on-termination.js @@ -6,8 +6,8 @@ const fs = require('fs/promises'); const { scheduler } = require('timers/promises'); const { parentPort, Worker } = require('worker_threads'); -const MAX_ITERATIONS = 20; -const MAX_THREADS = 10; +const MAX_ITERATIONS = 5; +const MAX_THREADS = 6; // Do not use isMainThread so that this test itself can be run inside a Worker. if (!process.env.HAS_STARTED_WORKER) { diff --git a/test/parallel/test-worker-http2-stream-terminate.js b/test/parallel/test-worker-http2-stream-terminate.js index 94e60e773c4b3e..a2a1c020035eac 100644 --- a/test/parallel/test-worker-http2-stream-terminate.js +++ b/test/parallel/test-worker-http2-stream-terminate.js @@ -11,8 +11,8 @@ const { Worker, parentPort } = require('worker_threads'); // stream activity is ongoing, in particular the C++ function // ReportWritesToJSStreamListener::OnStreamAfterReqFinished. -const MAX_ITERATIONS = 20; -const MAX_THREADS = 10; +const MAX_ITERATIONS = 5; +const MAX_THREADS = 6; // Do not use isMainThread so that this test itself can be run inside a Worker. if (!process.env.HAS_STARTED_WORKER) {