Skip to content

test: avoid timer race in event loop delay test - #64728

Merged
trivikr merged 1 commit into
nodejs:mainfrom
trivikr:test-performance-eventloopdelay
Aug 18, 2026
Merged

test: avoid timer race in event loop delay test#64728
trivikr merged 1 commit into
nodejs:mainfrom
trivikr:test-performance-eventloopdelay

Conversation

@trivikr

@trivikr trivikr commented Jul 25, 2026

Copy link
Copy Markdown
Member

Refs: https://github.com/nodejs/reliability/issues?q=sort%3Aupdated-desc%20test-performance-eventloopdelay

Problem

The test enables the histogram and checks it from a 20 ms timer.

On slow or contended systems, that timer can expire before the first complete event loop iteration.
The timer then disables the histogram before its uv_check callback records a sample.

Previous fixes addressed related but distinct failures:

The failing samplePerIteration checks were added later by #62935 and still depend on elapsed time.

Solution

Drive a known number of event loop iterations using setImmediate before disabling and checking each histogram.

The default-resolution and large-resolution checks share one iteration chain, removing the duplicated timing logic.


Assisted-by: codex:gpt-5.6-sol

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jul 25, 2026
@trivikr trivikr added the flaky-test Issues and PRs related to the tests with unstable failures on the CI. label Jul 25, 2026
@trivikr

trivikr commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

@trivikr
trivikr marked this pull request as ready for review July 25, 2026 21:40
@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.15%. Comparing base (8b9f89f) to head (92ee8b7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64728      +/-   ##
==========================================
- Coverage   91.85%   90.15%   -1.71%     
==========================================
  Files         400      752     +352     
  Lines      178855   251884   +73029     
  Branches    27331    47368   +20037     
==========================================
+ Hits       164292   227078   +62786     
- Misses      14234    16164    +1930     
- Partials      329     8642    +8313     

see 485 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 26, 2026
@trivikr
trivikr force-pushed the test-performance-eventloopdelay branch from c040df1 to f862517 Compare August 12, 2026 15:49
@trivikr trivikr added the review wanted PRs that need reviews. label Aug 15, 2026
@trivikr
trivikr requested a review from panva August 17, 2026 01:10
@panva panva removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 17, 2026
@nodejs-github-bot

This comment was marked as outdated.

@panva

panva commented Aug 17, 2026

Copy link
Copy Markdown
Member

Stress tests on

Both of these are passing stress tests over main, not over this PR

@panva panva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but please stress test the PR head.

@trivikr trivikr removed the review wanted PRs that need reviews. label Aug 17, 2026
@trivikr

This comment was marked as resolved.

@trivikr

trivikr commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

An expired timer can run before the first complete event loop
iteration, disabling the histogram before it records any samples.

Drive a known number of iterations with setImmediate before checking
the histograms, and share the chain between resolution variants.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: nodejs#64728
Refs: https://github.com/nodejs/reliability/issues?q=sort%3Aupdated-desc%20test-performance-eventloopdelay
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
@trivikr
trivikr force-pushed the test-performance-eventloopdelay branch from f862517 to 92ee8b7 Compare August 18, 2026 00:21
@trivikr
trivikr merged commit 92ee8b7 into nodejs:main Aug 18, 2026
19 checks passed
@trivikr

trivikr commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

Landed in 92ee8b7

@trivikr
trivikr deleted the test-performance-eventloopdelay branch August 18, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flaky-test Issues and PRs related to the tests with unstable failures on the CI. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants