Repository navigation
Commit 5001c32
Do not measure with a per-thread CPU clock under the M:N scheduler
assert_linear_performance() picks CLOCK_THREAD_CPUTIME_ID when it is
available. That clock belongs to the native thread that reads it, and an
M:N thread moves between native threads, so the two reads around one
measurement can come from different native threads and the elapsed time
comes out negative:
Expected 0 to be <= -2.2150775009999997.
Reproduced with RUBY_MN_THREADS=2, 1500 fork/waitpid pairs per run: the
Ruby thread changed native thread 1, 9 and 10 times over three runs, and
the clock went backwards 1, 5 and 6 times, by as much as 0.38s. The
default, =1 and =-1 never moved the main thread and never went backwards.
CLOCK_PROCESS_CPUTIME_ID stayed monotonic across 15 such migrations.
Prefer process CPU time when the M:N scheduler is on. This only changes
which clock the assertion uses; it does not relax the assertion.
ruby/ruby carries the same change as 0e06087548.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent f7ee598 commit 5001c32
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
873 | 873 | | |
874 | 874 | | |
875 | 875 | | |
876 | | - | |
| 876 | + | |
877 | 877 | | |
878 | 878 | | |
879 | | - | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
880 | 885 | | |
881 | 886 | | |
882 | 887 | | |
| |||
0 commit comments