DetPhysDocs日本語

Performance

The most expensive part of rollback is "when a prediction was wrong, go back N ticks and simulate N ticks again". DetPhys sets its budgets by whether that fits in one frame. The number of bodies and the prediction window N are settings. Use the numbers below to choose the bodies, shapes and N for your game.

Budgets (fit one frame in 4 ms)

DeviceBudget
Mid-range PC60 Hz, 200 concave dynamic bodies, N = 10 (re-simulate 10 ticks in one frame) within 4 ms
Mobile (Galaxy S9 class)60 baked concave bodies with N = 10, or 100 bodies with N = 6, within 4 ms
  • Devices: PC = Core i7-12700F / Windows 11 / power plan "High performance"; Galaxy S9 = SC-03K / Snapdragon 845 / Android 10.
  • "One frame" = restore N ticks back → re-simulate N ticks (taking a dyn snapshot into the ring on each) → advance one tick, averaged over 300 frames, with every body awake: the worst case.
  • In real matches mispredictions are rarer and roll back fewer ticks, so the average is a fraction of this (see "Real sessions" below).

2D rollback cost (200 bodies, N = 10, 60 Hz, 4 substeps)

Cost of one frame (200 bodies, N = 10, 4 workers)PC (i7-12700F)Galaxy S902468101214msBudget 4 msSimple shapes (1)Simple shapes (1) / PC (i7-12700F): 1.16 ms1.16Simple shapes (1) / Galaxy S9: 3.36 ms3.36Hand-built concave (5.6)Hand-built concave (5.6) / PC (i7-12700F): 2.00 ms2.00Hand-built concave (5.6) / Galaxy S9: 6.14 ms6.14Baked, steiner (9.4)Baked, steiner (9.4) / PC (i7-12700F): 3.50 ms3.50Baked, steiner (9.4) / Galaxy S9: 10.8 ms10.8Baked, hm (10.2)Baked, hm (10.2) / PC (i7-12700F): 4.16 ms4.16Baked, hm (10.2) / Galaxy S9: 12.9 ms12.9
Brackets: convex polygons per body. The PC value for hm is the top of 4.09–4.16 ms
Shape (convex polygons per body)PC, 4 workersPC 4 msGalaxy S9, 4 workersS9 4 ms
Simple shapes (1)1.16 ms (0.87 with 1 worker)fits3.36 ms (3.14 with 1 worker)fits
Hand-made concave compounds (5.6)2.00 msfits6.14 ms1.5×
Baked shapes, steiner (9.4, default)3.50 ms (3.27 with 8 workers)fits10.8 ms2.7×
Baked shapes, hm (10.2)4.09–4.16 msborderline12.9 ms3.2×
  • Conditions: PC scheduled by the OS (no core pinning); S9 pinned to its 4 big cores. With 1 worker, baked shapes (steiner, 1886 convex polygons) took 5.99 ms on the PC and 16.36 ms on the S9.
  • Bodies that fit N = 10 in 4 ms on the S9: about 124 hand-made compounds, about 70 baked steiner shapes, about 60 baked hm shapes. For 100 bodies, N ≈ 6.3–6.7.
  • Almost all the time is the step (78% of the frame for hm on the S9). It grows almost linearly with the number of convex polygons, so raising the baker tolerance (epsilon_px) to get fewer pieces makes it lighter.
  • Taking snapshots only on confirmed ticks gives 2.98 ms (steiner) and 3.45 ms (hm) for 200 baked bodies on the PC (4 workers).

3D rollback cost (200 bodies, N = 10)

200 boxes, spheres, capsules and convex hulls (207 in all, almost all awake) built through the C ABI (detphys3d.h); "roll back 10 ticks → re-simulate 11 ticks (a full snapshot and a hash every tick)", averaged over 1,589 frames. PC = i7-12700F, msvc-x64 Release, pinned to P cores; S9 = pinned to the 4 big cores.

ConditionOne frameOne tick stepSnapshot / restore (full)
PC, 1 worker5.17 ms0.40 ms0.047 / 0.067 ms
PC, 4 workers (core's pool)3.15 ms0.22 ms0.044 / 0.068 ms
PC, 4 workers (Box3D's built-in)3.37 ms0.24 ms–
Galaxy S9, 1 worker17.3 ms1.22 ms0.29 / 0.22 ms
Galaxy S9, 4 workers (core's pool)13.5 ms0.86 ms0.30 / 0.24 ms
  • Only the PC with 4 workers fits 4 ms. On the S9 it is almost all step time. The full image is at most 722 KB (1,265 contacts); a dyn snapshot is only 9% smaller.
  • This table is the heaviest case (every body awake, rolling back 10 ticks). Real 3D sessions are much lighter, as the next table shows.

3D sessions (real time, two peers in one process, 3600 ticks, N = 10, 1 worker, full)

3D push (two sphere players, boxes, spheres, convex hulls; 115 bodies, 7.7 awake on average) and 253 bodies that never sleep (230 awake). Per frame average / p99 / max [ms] of the worse peer. PC pinned to P cores, S9 pinned to big cores.

One-way delay, lossDelayB/tick115 bodies PC115 bodies S9253 bodies PC 1 worker253 bodies S9 1 worker
0 ms032.20.032 / 0.116 / 0.6330.144 / 0.363 / 0.6270.231 / 0.519 / 0.7431.103 / 2.298 / 2.549
30±10 ms, 5%033.20.034 / 0.141 / 0.2690.155 / 0.558 / 0.8590.249 / 0.869 / 1.3761.194 / 4.279 / 5.463
100±20 ms, 10%036.40.041 / 0.265 / 0.5130.190 / 1.172 / 1.9950.304 / 1.809 / 2.5751.462 / 8.402 / 9.564
135±15 ms, 20%039.20.043 / 0.335 / 0.6360.196 / 1.466 / 2.2930.323 / 2.321 / 2.7361.527 / 10.455 / 11.649
135±15 ms, 20%238.60.043 / 0.290 / 0.5140.191 / 1.195 / 1.6970.313 / 1.891 / 2.4051.476 / 8.525 / 10.469
  • The PC fits 4 ms even with 253 never-sleeping bodies at 135 ms one way (max 2.7 ms). On the S9, 253 never-sleeping bodies push p99 over 4 ms once the delay exceeds 30 ms (one re-simulated tick ≈ 1 ms). A normal scene with 115 bodies stays at 2.3 ms max even on the S9.
  • When most bodies sleep, the full snapshot (0.08–0.10 ms on the S9) costs more than the step.
  • PC and S9 as two processes (UDP, 1800 ticks): per frame PC 0.08–0.15 ms average, S9 0.20–0.29 ms average (max 1.9–4.0 ms).
  • Turn-based 3D (stacking convex hulls, up to 12 bodies): 89 B per turn, resync state at most 43 KB.

3D moving concave shapes

Two scenes for detphys3d_kinematic.h. 60 Hz, 4 substeps, gravity −10 m/s², 1 worker, default splitting (up to 4 pieces, 20 mm), full snapshots. PC = Windows x64, msvc-x64 Release; S9 = Galaxy S9 (SC-03K, Android 10), android-arm64. Neither was pinned to cores.

  • Scene a: one spinning concave gear (an octagonal platform + 3 dividers + 12 rim walls, 1.2 rad/s; radius 3.26 m to the corners of the rim walls, so every tick is split into 4).
  • Scene b: four moving platforms (back and forth with holds, lift, orbit, sway; all concave trays; no splitting).
ConditionPCS9
One tick (with splitting and update), a: 1 kinematic, 24 dynamic boxes0.10–0.12 ms–
One tick, b: 4 kinematic, 20 dynamic boxes0.04 ms–
One rollback frame (full restore + 10 ticks), a / b1.1–1.3 / 0.43–0.51 ms–
200 dynamic bodies, a: one tick step0.254 ms1.01 ms
200 dynamic bodies, a: restore + 10 ticks, mean / max2.64 / 4.55 ms10.3 / 18.6 ms
200 dynamic bodies, b: one tick step0.097 ms0.39 ms
200 dynamic bodies, b: restore + 10 ticks, mean / max1.01 / 2.61 ms4.1 / 10.9 ms
One advance of a real-time session (two peers in one process), a / b0.14 / 0.055 ms0.49 / 0.18 ms
Full snapshot size, a / b97 / 49 KBsame
  • With 200 dynamic bodies on a gear split 4 times every tick, the maximum of restore + 10 ticks is 4.55 ms on the PC, a little over the 4 ms budget. The number of pieces depends on the spinning platform's bounding radius and speed (a smaller or slower platform, a larger subtick_move_mm or a smaller max_subticks is lighter, traded against the tunneling speed).
  • On an S9, 200 dynamic bodies with N = 10 do not fit in 4 ms (as in the 3D rollback table above, the step is almost all of it).

Real sessions

WhatConditionsResult
Real time, two peers in one processPush scene with 77 / 205 bodies, N = 10, 3600 ticks, 5–150 ms one way and 5–20% loss injectedWorst frame: PC 2.0 ms or less in every condition. S9 4.2 ms (p99 3.9) only with 205 bodies, fast-changing inputs, 135 ms one way and 20% loss; 4 ms or less otherwise. Re-simulation averaged 0.06–2.3 ticks per frame, at most 10
Real time, PC and S9 as two processes (UDP)77 bodies, 1800 ticksPer frame: PC 0.08–0.12 ms average (max 1.4), S9 0.23–0.36 ms average (max 3.0, pinned to big cores)
Unity push sample, PC and S91800 ticks, Wi-Fi LANS9 at 59.8–59.9 fps. Core per frame (poll + advance + C# rule) 0.8–1.35 ms average, p99 3.3–4.0 ms
Same sample with the moving field (gear, platform, lift)SameS9 at 59.7–59.9 fps. Core 1.70–1.91 ms average, p99 3.9–7.5 ms. No tunneling. A Unity 2022.3 APK also ran at 59.9 fps, 1.87–1.88 ms average
Godot push sample (the core's built-in rule), S9 against Unity (PC)Moving field, 1800 ticks, 80 bodiesS9 core 0.91–0.95 ms average, p99 1.8–2.2 ms (step 380 µs, snapshot 51 µs, restore 83–90 µs), 32.3 B/tick. Godot on the PC 0.13 ms per frame (0.18 ms with the moving field)
Built-in push (core) against the same rule written in C++ / C#PC, 205 bodiesThe difference is within the noise (core 0.197–0.207 ms, former C++ 0.202–0.213 ms). With the moving field about 2× (splitting, and boxes do not sleep)
4 moving concave shapes + 200 dynamic bodiesOne frame with N = 10PC 0.58 ms (1.14 ms on split ticks), S9 2.3 ms (4.7 ms while splitting)
Turn-based (stacking)Two peers in one process, 196 ticks per turn on averageOne turn per peer: PC 1.25 ms, S9 4.6 ms
Unity stacking sample, PC and S9Automatic fast playpoll: PC 1.3–1.6 ms, S9 5.6–8.0 ms. One turn (wall clock) 13.5–20.8 ms on average

On the S9, running without core pinning and with idle time can show about 2 ms average and 24 ms worst because of OS scheduling (the Unity rows above were measured inside the engine frame).

Traffic

ItemAmount
Real time (inputs, acks, hash checks)32–48 B per tick one way (without UDP / IP headers)
Turn-based (stacking)150–190 B per turn for both peers together
State sent on a resync (full)about 184–190 KB for 77 bodies, about 415 KB for 205 bodies (about 1.5 s at 135 ms one way)
3D real time (inputs, acks, hash checks)32.2–39.2 B per tick one way (up to 43.5 B between two processes)
State sent on a 3D resync (transfer)190–260 KB for 115 bodies (0.1–0.2 s between a PC and an S9). Not compressed yet
Largest datagram55 B with inputs and checks only. Resync state chunks are 1051 B (real time) and 1057 B (turn-based) with chunk_bytes 1024. How this fits a transport's limit: 8. Transports and room codes

Right after a resync the guest re-simulates many ticks at once (205 bodies, 135 ms one way: 90 ticks in one frame, 8.2 ms on the PC).

Snapshot size and time (2D, 200 bodies)

ItemPCGalaxy S9
dyn snapshot (200 concave bodies)0.037 ms0.11 ms
restore (in place)0.046 ms0.11 ms
Sizedyn 544–592 KiB / full 836–885 KiBsame

Engine layer cost

Creating a scene of 116 bodies, running 600 ticks and hashing: Unity Editor 14–16 ms (2022.3 also 14.5–15.3 ms), S9 APK 54–58 ms; Godot (headless) 15–17 ms, S9 55–75 ms; Unreal (UE 5.8.4 editor, -nullrhi) 14.7 ms. The hash is the same in every engine.

Tuning

KnobEffect
Body count, convex polygon countThe biggest effect. A larger baker epsilon_px gives fewer polygons
Prediction window N (max_prediction)Smaller means a lighter worst frame; too small means more waiting with distant peers
Input delay, automatic input delayFewer mispredictions (traded against the feel of zero delay)
Workers (worker_count)Helps with about 200 concave bodies; with few or simple shapes 1 worker is faster. The hash does not change
Snapshot kinddyn (default) is faster for real time. Raise snapshot_base_slots if shapes change often
Hash check interval (hash_interval)Every tick by default; hashing costs little
Splitting of moving concave shapes (max_subticks, subtick_move_mm)A split tick costs that many steps. Slower motions or fewer splits are lighter (traded against the tunneling speed). In 3D the fastest point is measured with the shapes' bounding radius, so large spinning platforms split more
Desync debuggerZero when off (default). 5–20 µs per tick when on (3D with about 70 bodies: 15–19 µs on a PC, about 175 µs on an S9)

DetPhys is not affiliated with Box2D or Box3D and is not endorsed or recommended by Box2D, Box3D or their author. It uses Box2D v3 and Box3D, both under the MIT license, as its physics.

LicensesMatches the current versions (2026-11)

© 2026 PetafProductsContactPrivacy

This site uses no analytics or tracking.

↑↓ to choose, Enter to open, Esc to close