Skip to content

physics wake: the packed-crates test fits Debug CI (wake depths on first read, Debug-cheap loops, split in two) - #1562

Merged
transfix merged 1 commit into
masterfrom
fix/wake-packed-test-debug-cost
Nov 27, 2026
Merged

transfix merged 1 commit into
masterfrom
fix/wake-packed-test-debug-cost

Conversation

@transfix

Copy link
Copy Markdown
Owner

PhysicsFieldWake.PackedBodiesStayBoundedAndSleep took 581-747 s of its 1200 s ctest budget on package-linux / libcvc-debug, and on #1550's slow runner it timed out three times. That failed a PR that doesn't touch physics. This PR makes the test cheaper in Debug without changing what it checks or any bit it computes. It doesn't touch the timeout: #1557 owns that line.

Why it was slow

What changes

  • fluid_wake::ready_depths makes the depth layers at the first read after a wave step, instead of at every wave step. It is called in two places:

    • in field_set::apply, before the field workers' reads, when an awake body is in the wake's field;
    • in field_set::water_at, whose callers are serialized (a boat's pre-step, the world's lock).

    The inputs and their order are the same, so the output is the same bits. motion() reads only the layers that were made.

  • Raw pointers in the per-cell loops: the wake's per-cell passes (deepen, derive, sum, the wave step's dh/dt) and fft_plan::run_2d's gather and scatter now index through raw pointers. The operations and their order are unchanged. On its own this takes 28% off a 20 s calm run with a wake in Debug: 37.5 s to 27.1 s over three interleaved runs, with the same peaks to 17 digits.

  • The test is split in two. The calm half keeps its name, so physics_field_test: 3600 s for the packed-bodies wake test #1557's 3600 s entry still applies to it. The swell half becomes PackedBodiesStayBoundedInASwell. Each half gets its own ctest budget, and ctest runs them side by side.

  • Two comment claims are now asserted: every crate sleeps on calm water (9 of 9), and none sleeps in the swell (0 and 0). The comment "without one they sleep within 40" now says 3 s (2.55 s measured).

Measured

Local Debug build (Windows, MSVC 14.44, deps in Release, MultiThreadedDLL). The old and new builds ran side by side on one loaded box:

before after
calm half 283.6 s (one test, both halves) 72.5 s
swell half 87.8 s
total 283.6 s 160.3 s

Every value the test prints is the same to the digit. CI ran about 2.0-2.6x slower than this box before, so expect roughly 150-230 s per half on CI. That is not measured yet; CI on this PR will show it.

No pinned hash moves:

  • the wake golden 0xc72e26b4ef0f764a
  • the shore golden 0x89789ba92fbd1853
  • the swell scene f0085b4212e1a8c0 and the ocean scene be86208109133b1a

Tests run locally (Debug):

  • physics_field_test 53/53
  • the scene-world wake tests 5/5 (AriadneBoatNode.*Wake*, AriadneSceneWeather.AFrontWakesASleepingBody)
  • physics_boat_test 10/10, physics_dyn_boat_plant_test 16/16
  • ocean_sea_test 23/23, ocean_ewave_test 18/18

Changed lines are clang-format 18 clean.

Not done

…cally, same bits)

PhysicsFieldWake.PackedBodiesStayBoundedAndSleep took 581-747 s of its 1200 s ctest budget on
package-linux / libcvc-debug and timed out three times on a slow runner (#1550's). It took 269 s
there on #1344; #1532 made every wake test 2.5-2.8x slower in Debug (the ring 3.0 to 8.2 s, the
golden 2.4 to 5.8 s, this one 269 to 702 s). The test itself is as #1344 wrote it.

Profiled locally (Debug, MSVC /Od): the calm run with a wake is 62% of the test, and 87% of that
is the wake's wave step: deepen, the motion below the top that #1532 added (2 forward and ~3
inverse 64 x 64 FFTs a state a wave step), 51%; the ewave step 21%; sum, which now adds the
depths, 9%. In an unoptimized build std::vector's operator[] is a call per element, and these
passes made ~400k of them a state a wave step. And once every crate sleeps (~90 s into the calm
run) the wake made depths for ~30 s more, while its waves died away, with nothing reading them.

- fluid_wake::ready_depths: the depths are made at the first read after a wave step (in
  field_set::apply before the field workers' reads, when an awake body is in the wake's field,
  and in field_set::water_at), not at every wave step. The same inputs in the same order: the
  same bits. motion() reads only the layers that were made.
- The wake's per-cell passes (deepen, derive, sum, the wave step's dh/dt) and fft_plan::run_2d's
  gather and scatter index through raw pointers: the same operations in the same order. On their
  own, 28% off a 20 s calm run with a wake in Debug (37.5 s to 27.1 s, three interleaved runs,
  the same peaks to 17 digits).
- The test is two: the calm half keeps its name (and #1557's 3600 s), the swell's half is
  PackedBodiesStayBoundedInASwell, so each has its own ctest budget and ctest runs them side by
  side. What the comments claimed is now asserted too: every crate sleeps on calm water (9 of 9)
  and none in the swell (0 and 0). "Without one they sleep within 40" is 3 (2.55 s).

Measured locally, Debug, the old and new builds run side by side on one loaded box: 283.6 s
before; after, the calm half 72.5 s and the swell's 87.8 s (160.3 s). Every value the test prints
is the same to the digit. No pinned hash moves: the wake golden 0xc72e26b4ef0f764a, the shore
golden 0x89789ba92fbd1853, the swell and ocean scenes.
@transfix
transfix enabled auto-merge (squash) November 26, 2026 20:48
@transfix
transfix merged commit 787caaa into master Nov 27, 2026
30 checks passed
@transfix
transfix deleted the fix/wake-packed-test-debug-cost branch November 27, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant