Repository navigation
physics wake: the packed-crates test fits Debug CI (wake depths on first read, Debug-cheap loops, split in two) - #1562
Merged
Conversation
…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.
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.
PhysicsFieldWake.PackedBodiesStayBoundedAndSleeptook 581-747 s of its 1200 s ctest budget onpackage-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
Physics wake: shores, depth and the wake in water_at (C5's gaps, C6) #1532 made every wake test 2.5-2.8x slower in Debug. The test itself is unchanged since physics, ariadne: the waves floating bodies make push the others, opt-in (C5, D6) #1344. CI Debug times went from physics, ariadne: the waves floating bodies make push the others, opt-in (C5, D6) #1344 to Physics wake: shores, depth and the wake in water_at (C5's gaps, C6) #1532 as follows:
The profile (local Debug build, MSVC
/Od, timers around the wake's step): the calm run with a wake is 62% of the test, and 87% of that run is the wake's wave step:deepen, the motion below the top that Physics wake: shores, depth and the wake in water_at (C5's gaps, C6) #1532 added: 51%. It runs 2 forward and about 3 inverse 64×64 FFTs per state per wave step.sum, which now adds the depth layers: 9%The calm run without a wake costs 0.4 s, because the crates sleep after 2.55 s.
Per-element calls. In an unoptimized build every
std::vector::operator[]is a function call, and these passes made about 400k of them per state per wave step.Unread work. About 90 s into the calm run every crate is asleep, but the wake kept making depth layers for the remaining ~30 s while its waves died away. Nothing read them.
What changes
fluid_wake::ready_depthsmakes the depth layers at the first read after a wave step, instead of at every wave step. It is called in two places:field_set::apply, before the field workers' reads, when an awake body is in the wake's field;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) andfft_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: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:
0xc72e26b4ef0f764a0x89789ba92fbd1853f0085b4212e1a8c0and the ocean scenebe86208109133b1aTests run locally (Debug):
physics_field_test53/53AriadneBoatNode.*Wake*,AriadneSceneWeather.AFrontWakesASleepingBody)physics_boat_test10/10,physics_dyn_boat_plant_test16/16ocean_sea_test23/23,ocean_ewave_test18/18Changed lines are clang-format 18 clean.
Not done
PhysicsFieldWake.TheWakesCostOnTheSea(207-260 s on CI) is unchanged. Its cost is mostly the three-cascade sea's reads, and it was already 236 s on physics, ariadne: the waves floating bodies make push the others, opt-in (C5, D6) #1344.