Repository navigation
cpu: revert to the upstream wall clock and restore ci_clock (#98) - #113
Merged
Merged
Conversation
belikh
force-pushed
the
convergence/ci-clock
branch
from
October 26, 2026 06:28
d54777e to
295752b
Compare
CP0 Count is host-Instant-derived again in normal builds, and the Compare interrupt is armed as an hptimer one-shot. This reverts the fork's cycle-derived-by-default clock (e8b264e) and deletes the ordered guest-time timer queue (800f785, src/cpu/guest_timer.rs) with its Machine field, PIT registration and drain calls. The 8254 PIT returns to upstream's Instant channels, keeping the read-back and latch-release work that landed as upstream techomancer#323. --features ci_clock is a real feature again: Count is derived from hot.cycles at 10 ns per retired instruction, Compare is a count_fire_cycle threshold checked by the per-instruction preamble and by idle parking, and the feature is recorded in snapshot provenance so a restore into the other clock model is refused. The CPU state description is version 3 with a `clock` field. A version-2 fork payload migrates to the running build's clock, drops the retired queue and gets a fresh Compare deadline from the CP0 load path. Idle-pace (#83) is kept against the wall clock: a parked CPU advances hot.cycles for cross-thread readers, wakes on any pending line, and paces a masked pending interrupt. A park that wakes on a line the guest cannot take backs off for about 20 ms: the wall clock no longer makes Count advance with hot.cycles, so parking an instruction-counted delay loop capped boot at one batch per slice. The snapshot determinism validator now releases the stopped-CPU Count latch for its inline passes, so it can tell the two clock models apart instead of comparing two identically frozen Counts. Measured on callisto (x86_64, 16 cores): - determinism, bare Count-read loop, validate -n 1000000: default deterministic false (cp0_count A=0xe071974 B=0xe071a0e), ci_clock true. - boot to IRIX 6.5 login, R4400: wall 45 s (three runs), ci_clock 45 s. - guest sleep 30: wall 33 s host, ci_clock 108 s host (interface only). - bench suite, R4400, three runs: wall 42.8 MIPS, ci_clock 41.5 MIPS, both 100% accuracy.
HACKING, FEATURES, STORAGE, the GUI README, the IOC 8254 guide and the CHANGELOG now describe the host wall clock as the default and `ci_clock` as the deterministic validator build. The CHANGELOG entry calls out the user-visible clock change and the snapshot rules. Update the agent notes that the revert invalidates: Count is wallclock-derived again in default builds, the PIT is host-timed again, the idle-pause deadline measurement is superseded, and the jitv2 design's determinism claims are limited to Count/Compare. Add a note for the validator's live-Count rule and an update to the idle-pause PROM-boot note with the cold-boot measurements. Mark the reversion plan done and the divergence-policy item resolved.
belikh
force-pushed
the
convergence/ci-clock
branch
from
October 26, 2026 06:46
295752b to
c7f8b5b
Compare
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.
What changed
The fork's cycle-derived default clock is reverted to upstream's host wall clock, and
--features ci_clockis a real feature again. This resolves the largest remaining divergence inclanker/plans/divergence-policy.md(#98; upstream decision on techomancer#322).User-visible: a normal build once more runs guest time in step with host time. A guest that runs faster or slower than an R4400 still sees the same seconds pass. Deterministic runs (snapshots, replays, the validator) now need
--features ci_clock; that build intentionally lets guest wall-clock drift from host time.Instantanchor at the configured rate; Compare is anhptimerone-shot.src/cpu/mips_core.rs,mips_exec.rs,cop0paths and the step preamble follow upstream.src/cpu/guest_timer.rsis deleted with itsMachinefield, PIT registration and batch-drain calls. The 8254 PIT returns to upstream'sInstant-based channels, keeping upstream pit: implement the 8254 read-back command and release single-byte latches techomancer/iris#323's read-back and latch-release.ci_clockgets upstream's implementation: Count fromhot.cyclesat 10 ns each, Compare ascount_fire_cycle, idle-park exit at the threshold, and snapshot feature gating.hot.cyclesno longer advances Count and an instruction-counted delay loop would otherwise run at one batch per slice. This tookci_clock,idle-pausecold boot from 176 s to 45 s.StateDesc. The CPU payload is v3 with aclockfield (wall/cycles); a v2 fork payload migrates to the running build's clock, drops the retired queue and gets a fresh Compare deadline from the CP0 load path. A v3 payload from the other clock model is refused.Storage/BlockNode, the serial log and the graphics boards are untouched.
Tests
CARGO_TARGET_DIRon a separate target directory; hostcallisto(x86_64, 16 cores).cargo test --workspacejitv2cargo test --workspace --features jitv2ci_clockcargo test --workspace --features ci_clockidle-pausecargo test -p iris --lib --features idle-pauseci_clock,idle-pausecargo test -p iris --lib --features ci_clock,idle-pauseNew/adapted tests:
inline_pass_releases_the_stopped_count_latch,inline_pass_keeps_cycle_count_under_ci_clock,cpu_v2_cycle_clock_payload_migrates_to_a_fresh_compare_deadline,cpu_v3_payload_from_the_other_clock_is_refused,an_armed_compare_timer_ends_the_park,the_cycle_compare_threshold_ends_the_park,a_park_woken_by_a_masked_line_backs_off, plus the ip7 ticket tests now advance Count by the right clock.Evidence
mfc0 Countloop,iris-ci validate -n 1000000cp0_countA=0xe071974B=0xe071a0eci_clockci_clocksleep 30host elapsed (telnet)sleep 30host elapsedci_clockiris-bench run --iris ... --repeat 3ci_clockidle-pause(wall)ci_clockafter the back-offThe determinism harness used a hand-built bare-metal loop (
mfc0 t0, $9; addiu; bne) so the result does not depend on which kernel path a snapshot landed in; snapshotted from a bare machine with--load-elf. The default build's earlier "deterministic true" results were the validator comparing frozen Counts, which is why the live-Count change is in this PR.Representative commands:
Remaining risks
idle-pausedid not reach login in 400 s, while the same image withoutidle-pauseboots in 45 s. This is the pre-existingrelease-idle-pause-hangs-prom-bootissue, now written up with the Upstream: CPU clock model — discussion first #98 measurements.ci_clock,idle-pauseboots in 45 s after the back-off. A follow-up should detect IRIX 6.5's idle loop and avoid parking wall-clock instruction-counted delay loops.ci_clock.ci_clockmakes Count/Compare deterministic, not the whole machine: 8254 and device interrupts still arrive from their own threads. Tests that need full determinism must not depend on PIT timing.irix7/ostiming and the benchmark history assumed the synthetic clock. Deterministic OS runs need--features ci_clock; interactive runs get wall time. The CHANGELOG andFEATURES.mdsay so.clockfield. Users with saved fork snapshots should expect one migration.ci_clockto be meaningful; the design note is updated rather than silently claiming otherwise.Closes #98. References #83 and the upstream decision on techomancer#322.