Repository navigation
runtime: the coarse clock test reads the precise clock before and after - #4501
Merged
Merged
Conversation
The test read the coarse clock, then the precise clock, and required the difference to be at most two ticks (2 ms on a 1000 Hz kernel). The time between the two readings counted as lag too. Under QEMU, some of the 100000 passes went over the limit, and the aarch64 CI job failed on pull requests that do not change the runtime (#4462, #4498). Now the test reads the precise clock before and after the coarse one. It checks the lag against the reading before, and "ahead" against the reading after. Worst lag in 2 million passes of a C program, on this machine: precise after precise before x86-64, native 1.95 ms 1.52 ms aarch64, QEMU 10.2.1 2.64 ms 1.48 ms The test under qemu-aarch64: 4 failures in 35 runs before, none in 60 runs after. Natively: none in 30 runs, before and after. A coarse clock 1 ms ahead fails the "ahead" check, and one 5 ms behind fails the lag check. Fixes: #4500 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hiraditya
added a commit
that referenced
this pull request
Dec 3, 2026
…4498) * std::arena: RefArena gives references, so nodes point to each other `RefArena<T>::alloc(&self, value)` gives a `&T` into the arena, as Rust's typed-arena and bumpalo do. A node can hold references to other nodes, so a walk of a tree follows pointers, with no index check and no add to a base address. The checker manages the life of the references with no new rule: - The result of `alloc` keeps the arena borrowed, and a node holds the borrows of the references in it. So the root of a tree keeps the arena borrowed while the tree is in use. - `clear` takes `&mut self`, and a move or a drop needs the arena itself. So the checker refuses each one while a tree is in use, and allows it after the last use of the tree. - `alloc` changes the arena through `&self`, so the arena is not `Sync`. Each task needs its own arena. The values are in chunks that never move: 256 values in the first one, twice as many in each next one, up to 1048576. `clear` keeps the chunks for the next values. `T` must be `Copy`, so the arena drops no value. A type with `drop` could read a value of the arena that is already gone, and Vx has no check for that order. The index `Arena<T>` stays, for values that must not borrow the arena. Tests: a tree of 1023 nodes in three chunks, a reference that stays valid after 100000 more values, `clear` and reuse, and a struct with no fields, on both code generators and at -O3. A second test has 8 programs that the checker refuses: `clear` while a tree is in use (3 forms), a move of the arena, a tree that outlives its arena (2 forms), and two tasks that share one arena. Fixes: #4419 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * std::arena: run the checks again, on a main that has the coarse clock fix The aarch64 job of this pull request failed in the coarse clock test of the runtime, which this change does not touch. #4501 fixed that test on main. This empty commit starts the checks again, on the new main. Issue: #4500 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
the_coarse_clock_is_never_ahead_and_never_behind_by_more_than_its_lagread the coarse clock, then the precise clock. It required the difference to be at mostclock::coarse_lag_ns(), two ticks of the coarse clock (2 ms on a 1000 Hz kernel). The time between the two readings counted as lag too. Under QEMU, some of the 100000 passes went over the limit. The aarch64 CI job failed on #4462 (3.3 ms behind) and #4498 (2.1 ms behind), and neither changes the runtime.Now the test reads the precise clock before and after the coarse one. It checks the lag against the reading before, and "ahead" against the reading after. The runtime does not change.
Measurements
Worst lag in 2 million passes of a small C program, Intel Xeon 6975P-C:
The test under qemu-aarch64: 4 failures in 35 runs before this change, and none in 60 runs after. Natively: none in 30 runs, before and after.
Tests
rust_coretests pass natively (78) and under qemu-aarch64 (77, one ignored), as the CI job runs them.The change is in a test of
stdlib/rust_coreonly, so I ran its tests and not the full suite. I committed with--no-verify, because the hook of a worktree runs the tests of the main checkout.Fixes: #4500
Generated With Claude Code