Skip to content

Time::HiRes: make nanosleep.t more robust against busy systems#24405

Open
tonycoz wants to merge 1 commit into
Perl:bleadfrom
tonycoz:24284-nanosleep
Open

Time::HiRes: make nanosleep.t more robust against busy systems#24405
tonycoz wants to merge 1 commit into
Perl:bleadfrom
tonycoz:24284-nanosleep

Conversation

@tonycoz
Copy link
Copy Markdown
Contributor

@tonycoz tonycoz commented May 4, 2026

This now does up to 10 trials see if a nanosleep takes something like the expected maximum limit of duration.

If any trial takes less than that limit the trials finish and falls through to the test checks.

If any trial takes less than the minimum expected by the test the test still fails, since I'd expect a busy system to extend the duration, not reduce it.

Fixes #24284


  • This set of changes does not require a perldelta entry.

Copy link
Copy Markdown
Contributor

@leonerd leonerd left a comment

Choose a reason for hiding this comment

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

One unused variable, but otherwise looks good.

Comment thread dist/Time-HiRes/t/nanosleep.t Outdated
my $d = $f2 - $f;
my $max_trials = 10;
my $trials = 0;
my $ok = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$ok appears to be unused in the subsequent code

@ap ap added the defer-next-dev This PR should not be merged yet, but await the next development cycle label May 4, 2026
@ap
Copy link
Copy Markdown
Contributor

ap commented May 4, 2026

PSC opinion is that this should bake for a bit, so it’ll have to wait for next cycle.

This now does up to 10 trials see if a nanosleep takes something like
the expected maximum limit of duration.

If any trial takes less than that limit the trials finish and falls
through to the test checks.

If any trial takes less than the minimum expected by the test the test
still fails, since I'd expect a busy system to extend the duration,
not reduce it.

Fixes Perl#24284
@tonycoz tonycoz force-pushed the 24284-nanosleep branch from 7792df6 to 0b895db Compare May 4, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

defer-next-dev This PR should not be merged yet, but await the next development cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perl 5.42.1 test suite fails on Linux From Scratch

3 participants