Repository navigation
Tests: the 8 slowest unit tests do the same checks for a fraction of the CPU - #1385
Merged
Merged
Conversation
at_the_byte_cap_sessions_are_dropped_before_crash_reports found the body size by growing it three bytes at a time and framing a ~100 KB record (JSON plus a bitwise CRC) on every step: about 2700 frames, 28 s alone. A frame is a fixed overhead plus four base64 characters per three bytes, so the body is now derived from the overhead of an empty record, and two asserts pin the derivation to encode(): four reports of that size fit, one base64 group more does not. The records fed to trim() and the asserted result are unchanged; 0.08 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… for nothing Most of a dispatcher frame in a test (a debug build) was Dispatcher::state_hash: a sampled detail::identity_tests walk spent 64% of its CPU in the two state_hash calls that bracket the prepare pass and 94% under frame_with in all, almost all of it in Canon's per-byte iterator calls. - Canon feeds bytes through one index loop (`bytes`) and inlines byte/tag, instead of `for b in v.to_le_bytes()` / `v.bytes()`, whose iterator `next` is a call in a debug build. The bytes fed, and so the hash recorded replay anchors compare against, are unchanged; a new test pins the stream against a byte-at-a-time reference and against the value the previous loops produced. - frame_with hashes before and after the prepare pass only when it runs one. With draw == false (the walk tests) the only call between the two hashes is rig.opaque_route(bool), which holds none of the hashed state, so the assertion compared a state with itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a_backward_seek_after_a_deep_read_keeps_the_events_at_the_target pushed 30 000 events and rewound to event 10 000. Every push past the 8 192-event window copies and ranks the whole window, so 21 800 of those pushes were the same quadratic eviction repeated; the window held the identical latest 8 192 events at the seek after MAX_EVENTS + 300 reads. The test now reads that far, asserts the window is full, and rewinds to event 100, which is still more than STALE_AHEAD_MS behind everything held. The 100 pushes at the target and their assertions are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n once - long_hud_titles_fit_before_every_control_slot drew the same title (an unpaused draw reads no clock) for every focused control and every one of 30 pop frames; it now draws it once per language, slot and kicker and keeps the per-frame pop check against the control rects. - worst_contrast_2d re-derived the pill's ink regions for each of ~5 000 pixels (`ink_at` is `pill_ink(..).at(..)`); it derives them once and reuses the last pixel's contrast when its backing and ink are the same values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…um certificate `machine/src/machine.rs` is pinned whole-file in `ci/proofs/platform-generated-enums.json` and `ci/readonly_generated.py`, so #1385's rewrite of the `Canon` byte loops failed `check-machine-shape.py` (the machine-shape audit lost its certificate for the newtype id structs, so every shared opaque payload read as unproven) and `test_readonly_generated.py`. What the certificate certifies from machine.rs is the `newtype!` macro and its ten `u32` invocations: `declarations()` lexes exactly those and emits `pub struct Name(pub u32)`. The PR's change is `impl Canon` and `canon_tests`, from line 882 on; lines 1-881 are byte-identical, the extracted declarations are identical, and the FNV-1a byte stream is pinned by the new `canon_is_fnv_1a_over_tagged_little_endian_bytes` test. So the new file hash is added to `MACHINE_SOURCES`, the certificate is regenerated with `produce_certificate` (only the machine.rs hash list and one review line change) and `CERTIFICATE_SHA256` is the hash of that certificate. The way #1358 and #1366 updated it. 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.
What
CI's
host unit tests (default features)job spends most of its test time in a handful of CPU-bound debug-build tests. Each one below was profiled (sample/ per-test--report-time, alone,--test-threads 1) to find where the time goes, and the cost removed without changing what the test asserts. No#[ignore], no deleted or loosened assertion, no Cargo profile touched.Per-test before/after
Each measured alone with
--test-threads 1on the shared, loaded Mac, before and after from saved binaries run back to back (the screens walks were run twice per side).plx_telemetryqueue::tests::at_the_byte_cap_sessions_are_dropped_before_crash_reportsplx_screensdetail::identity_tests::no_landing_on_the_related_row_ever_moves_the_card_under_the_focusframe_withwereDispatcher::state_hash, whichframe_withruns twice per frame in a debug buildplx_screenssearch::tests::no_landing_on_a_search_row_...plx_screenshome::tests::no_landing_ever_leaves_the_focused_card_outside_the_windowplx_uiwidgets::tab_capsule_motion_tests::the_top_bar_keeps_three_to_one_on_every_glyph_pixel_of_every_hopink_atre-derived the pill's ink regions for each of ~5000 pixelsplx_uiwidgets::tab_capsule_motion_tests::a_label_a_capsule_is_crossing_stays_readable_on_every_glyph_row_not_only_the_centre_oneplx_appkitplayer_hud::tests::long_hud_titles_fit_before_every_control_slotplx_mediaplayer::ass_source::tests::a_backward_seek_after_a_deep_read_keeps_the_events_at_the_targetWhole
plx_telemetrybinary: 58 s in CI -> 2.3 s here. Binaries run 3 at a time, same machine, load varying (before / after):plx_ui28.7 -> 9.5 s,plx_appkit26.7 -> 14.4 s,plx_media36.3 -> 36.2 s (media is gated by other tests; this one fell 9.2 -> 1.3 s).The property each test keeps, and the mutation that still fails it
Each mutation was applied to production code, the four crates run, and reverted (the tree is clean).
queue.rs): four crash reports of the largest size that fit plus a newer session;trimmust keep the four crashes in FIFO order and drop the session. The size is now derived from the empty record's frame overhead (four base64 chars per three bytes) and two asserts pin it toencode()(four fit, one base64 group more does not), so the records and the asserted result are the same as before. Mutation: rank a session like a crash report intrim->["c2","c3","c4","sess"]instead of["c1".."c4"], test fails.Canonencoder (plx_machine): the hash is FNV-1a over a tag byte and little-endian bytes.u32/u64/f32/strnow feed bytes through one index loop withinline(always)rather thanfor b in v.to_le_bytes()/v.bytes(), whose iteratornextis a call per byte in a debug build. The bytes fed are identical. New testcanon_is_fnv_1a_over_tagged_little_endian_bytescompares the stream against a byte-at-a-time reference and against a constant recorded from the previous loops (it passed on the old encoder before the rewrite). Mutation: a different prime insidebytes-> that test fails.Dispatcher::frame_with(plx_ui): thedebug_assertionscheck "a prepare pass changed the logical state" hashed before and after step 9. Withdraw == false(the walk tests) no prepare pass runs, and the only call between the two hashes isrig.opaque_route(bool), handed one bool and nothing of the hashed state, so it compared a state with itself. The hash pair now runs only whenwill_present && draw, i.e. when the prepare pass runs. The guard is unchanged for those frames. No test grades the guard itself (none existed); this is argued from the code, not demonstrated by a mutation.plx_screens.worst_contrast_2d): grades every glyph pixel of every pill every frame at 3:1, exactly as before; the ink regions are decided once per call (ink_atis by definitionpill_ink(..).at(..)) and the last pixel's contrast is reused when its backing and ink arrays are equal. Mutation: never flip to the focus ink inside the focus capsule (pill_ink) ->the_top_bar_keeps_three_to_one_...anda_label_a_capsule_is_crossing_...fail (9plx_uitests fail in all).right + MDstays exactly as it was. The draw depends on the cell's right edge, the title and the measure, and withpaused = falsereads no clock, so the repetitions were identical. Mutation: fit the title towidth + 60indraw_player_title_at-> test fails.ass_source.rs): the regression is that after a deep read a rewind's events are retired before the stale-ahead ones. ReadingMAX_EVENTS + 300events leaves the same full window (latest 8192) as 30 000 did; the test now asserts the window is full, then rewinds to event 100 (more thanSTALE_AHEAD_MSbehind everything held) and the 100 pushes and assertions at the target are unchanged. Mutation: disable the stale-ahead branch ofretire_to_fit-> the test fails (and one other media test).Gates
Run on the committed tree (
git status --shortempty before and after), via themake test-craterecipe minus itsdisk-preflightprerequisite (see below):(The times are 6 binaries at once on a machine at load 10-70.) Full
make checkwas not run (CI gates it).make test-crate'sdisk-preflighthung for 20+ minutes under load while it ranbuild-gc.sh --evicton other lanes' trees, so the recipe was run directly with the same arguments; free space was 24 GiB.The generated-enum certificate (
ci/proofs/platform-generated-enums.json,ci/readonly_generated.py) pinsmachine/src/machine.rswhole-file, so the file's new hash is added to it (the way #1358 and #1366 did): it certifies only thenewtype!macro and its tenu32invocations (lines 62-108), which this PR does not touch (first changed line is 882, insideimpl Canon); the declarations the checker extracts are identical before and after.Not done
plxnative_modules(138.8 s in CI) was not profiled.hud_format::lint_tests(still 5.3 / 3.2 / 3.0 / 1.8 s alone for the four slowest) and the otherplx_appkit/plx_screenstests under 2 s were not touched.no_landingwalks are still 12 / 7 / 3 s; shrinking them further means fewer seeds or frames, which needs a mutation set of the focus-stability code that I did not build, so counts are unchanged.testlock::serial()critical sections were not narrowed.🤖 Generated with Claude Code