A Mac steps 8 ragdolls and 4 vehicles within 2 ms a tick #24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/3904-a-mac-steps-8-ragdolls-and-4-vehicles-wi"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Tracker: #3904
Step 5 of plan #3865. This PR holds the physics to its budget with a built bench that the gate now runs on m5's slower core tier. The measurement called for no optimisation: the worst tick is about 0.52 ms on the slower tier, about a quarter of the budget.
What it adds
tools/bench/physics_scene.sx(benchScene). It builds a physics world over the first map's collision world (baked/first_map.hbw) with the bench's own bodies alone, on the level clearing 13.5 m in front of the first spawn marker: 116 bodies and 104 joints.4 vehicles. Each has a convex hull chassis made with
hullOf(4.4 m long, 1.4 m tall, 1.9 m wide, 1500 kg, centred on its centroid) and four 25 kg sphere wheels of radius 0.35 m, hinged at its corners with their axes across the car. They stand level, side by side, 1 m apart, with their wheels 0.5 m above the ground.8 ragdolls. These are free dummies from
src/sim/dummy.sx's template, added by the newfreeDummy, whichhangDummynow shares its code with. They stand in two rows, tilted 5–25° toward the cars, with their lowest points 0.3–0.6 m up:Every body starts at least 0.38 m from any body of another vehicle or dummy. No torso part's top starts more than 2.11 m above the terrain, and no vehicle starts above a dummy.
Placement. The dummies' frame stands at the back of the clearing, so the dummies stand on its side and push the cars away from it. The free-wheeled cars roll at up to about 0.25 m/s when a dummy topples against an end. Laid out the other way round, one car rolled into a frame post.
What it does. The cars land, hop about 0.14 m and land again. Each inner dummy topples against its car's end, and each outer dummy topples onto the inner dummy in front of it. Over the 600 ticks, the contacts between bodies of different cars and dummies are these (first tick, then ticks holding a contact):
No dummy holds a contact with the frame's posts (near-upright map triangles).
tools/bench/physics.sx, built intosx-out/tools/physics_bench.clock_gettime_nsec_np(CLOCK_THREAD_CPUTIME_ID = 16)declaredextern.PhysicsWorld.stepnow runs asbegin(wake, find contacts, warm),solve(substeps, restitution, store) andend(sweep, sleep), and the bench times each one.PhysicsWorld.countsholds what the last step did. The code and its order are unchanged (see below).tools/gate.shbuilds the bench after the app and runs it undertaskpolicy -b, before the tests.tests/physics_bench_scene.sx. It steps the same scene 600 ticks undertools/sx run, about 2 s, and checks:0ac6ff9(the outer row between the inner row's dummies), it fails for dummies 0, 1, 3, 4, 5 and 7.Bench figures (m5)
At the head,
39a9a74, from the bench gate run 951 built, at a one-minute load of about 4 (14:21 EET).taskpolicy -b sx-out/tools/physics_bench:At default QoS,
sx-out/tools/physics_bench:A second round a minute later read 0.513542 ms worst and 0.381125 ms median under
-b, and 0.239166 ms and 0.175584 ms at default QoS. Gate run 951's own bench read 0.519417 ms worst and 0.381333 ms median under-b.Master before any optimisation. Master's own
src/physics/(ef94076) has no phases or counts, so this bench times its wholestep(). It ran in agit archivearm of master with this PR's scene (39a9a74's) andsrc/sim/dummy.sxadded, interleaved with the head's runs above:Interleaved rounds. Five earlier rounds at a load of about 3.5 (14:18–14:19) alternated a bench built from 39a9a74's sources in a
git archivearm and master's:-b-bSo splitting the step costs nothing measurable. A first round just before these read 0.397 ms worst and 0.255 ms median for the head under
-b, lower than every later run under-b, and 0.397 ms and 0.293 ms at default QoS.How to read them.
src/physics/gains only the phase split and the counts.Checks
The gate fails with the bench. In a
git archivearm offe94f97withBUDGET_NSset to 200 000 (0.2 ms, below the measured figure),bash tools/gate.sh fullbuilt the app, built the bench, and failed at it with exit 1 before the tests:tools/gate.shand the bench are unchanged since.The existing tests' results are as they were. Every one of the 37 existing
tests/*.sxwas copied as av_test whosecheck,near,nearVecandwithinprint every call. The copies ran ingit archivearms of masteref94076and offe94f97, and the outputs (2,883 printed figures) are byte-identical.src/physics/andsrc/sim/are unchanged sincefe94f97.The scene test's figures at the head (
39a9a74):Mutants of the head (
39a9a74), each run in agit archivearm againsttests/physics_bench_scene.sx:killed:
0ac6ff9: six dummies meet no other dummy;within the test's gross bounds, as the task expects; step 4's cases pin these rules:
The review found each killed by physics_joints, physics_bodies, physics_stack or sim_dummy.
At
0ac6ff9a static counter that changed one of two worlds' gravity was killed (the runs differ at tick 0), and a hinge whose axes are never aligned made the test run past 10 minutes, and the run was stopped.The first mutant run showed the limits check reading the limits from the joints it checked, so removing them passed. The test reads them from the dummy template (
542adea).Gates
fast, gate run 939, atfe94f97: passed (40 passed, 0 failed; its bench read 0.502 ms worst undertaskpolicy -b).full, gate run 940, at08a8f53: passed (40 passed, 0 failed; its bench read 0.507 ms worst undertaskpolicy -b).full, gate run 941, at0ac6ff9: passed (40 passed, 0 failed; its bench read 0.521 ms worst undertaskpolicy -b).full, gate run 951, at39a9a74, the head: passed (40 passed, 0 failed; its bench read 0.519 ms worst undertaskpolicy -b).