Skip to content

Upgrade ODE, correct robot contacts and accelerate dense physics - #3

Merged
fred-huang122 merged 7 commits into
masterfrom
perf/ode-0.16.6-integration
Nov 2, 2026
Merged

fred-huang122 merged 7 commits into
masterfrom
perf/ode-0.16.6-integration

Conversation

@fred-huang122

@fred-huang122 fred-huang122 commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Upgrade grSim to double-precision ODE 0.16.6, correct robot-shell contacts, and keep the tested 6 v 6 sustained-pushing workload running in real time on the available CPU cores.

  • Use each team's configured outer radius for robot contacts. Attach the proxy sphere directly to the chassis, preserving combined mass/inertia while removing one body and six fixed-joint rows per robot. Retain the separate ball hull and dribbler cutout.
  • Correct cylinder inertia and ball rolling/spin resistance, including the 0.35 m/s² rolling default and saved/live-settings migration. Derive conservative collision masks from registered surfaces; keep unclassified objects permissive.
  • Read row-major factors directly in four-row AVX2 triangular solves on supported x86-64 CPUs. Runtime dispatch preserves platform BLAS for other CPUs/strides, Accelerate on macOS, and original ODE kernels when optimization is disabled/unavailable. Small kernels retain ODE arithmetic; OpenBLAS uses one active math thread per caller.
  • Automatically select up to three ODE helpers for games with at least six robots per team and at least three available logical CPUs, capped at one fewer than the reported CPU count. Smaller worlds stay serial. GRSIM_ODE_THREADS=0..16 explicitly overrides selection; zero retains serial mode.
  • Publish the actual helper count in immutable snapshots. A controller regression covers automatic startup, world/count resets, explicit overrides, invalid values and shutdown ownership.

The direct solver, five substeps, contact geometry, materials and tolerances are unchanged by the performance work. ODE parallelizes complete independent contact islands; it does not split contacts between interacting robots. Live pushing profiling found three independent 24-body groups. Cold live pushing can exceed the serial budget even when the warmer fixed-step benchmark fits, so the app now selects the already-supported island workers automatically.

The CPU profile originally spent 79.9% of user cycles inside OpenBLAS; the direct vector kernels reduce that share to 11.8%. Five shuffled timing rounds, 300 measured ticks after 60 warmup ticks, twelve Parsian robots on Division B, Ryzen 9 7945HX. Both sides use accurate shell contacts; this table isolates the math change with explicit worker counts. OPENBLAS_NUM_THREADS=1 controls library startup for both processes.

Case Helpers Previous math, ms/tick New math, ms/tick
Spaced 0 1.174 1.132
Spaced 3 1.045 1.051
Dense opposing-heading crowd 0 8.699 7.337
Dense opposing-heading crowd 3 8.260 6.893
Sustained pushing 0 19.833 13.859
Sustained pushing 3 7.930 5.385

Serial pushing math takes 30% less time; all five trials meet the 16.67 ms tick budget. Forcing serial mode can still lag in the cold live-app workload.

With the same GPU fix on both app builds (#4), three paired default-mode RTX 4060 trials give:

6 v 6 app case Previous default FPS New default FPS New simulation/wall speed
Spaced 47.0 50.3 1.000×
Crowd 40.0 47.2 1.002×
Sustained pushing 0 47.3 0.999×

The old serial default accumulated 1.86–5.52 seconds of backlog and suppressed drawing under the existing backlog policy. The new default reports three helpers and finishes pushing trials with 6.54–8.71 ms backlog. The render policy and clock rate are unchanged. Existing workloads were left running; GPU use with grSim closed ranged 14–66%, so small FPS differences are workload-dependent. Crowd ratios above 1 can include backlog recovery.

Validation:

  • All 21 local regressions pass. Current CI passes Ubuntu 22.04/24.04 (21 tests), native arm64 macOS 15/26 (20 tests), and the exact macOS 15 ZIP downloaded and launched on macOS 26.
  • Native/fallback math tests cover 264 triangular cases through 1025 rows, both transposes, sparse/dense factors, strides, unused/padding canaries, dot products, eight concurrent callers and long-double residuals. Address/undefined sanitizers pass.
  • Matched five-second physics audits retain peak shell penetration of 0 mm spaced, 0.823 mm crowded and 0.324 mm pushing, with 0/3 helpers. No LCP errors or nonfinite states; math-backend trajectory differences remain below 0.06 nanometres over five seconds and 2.14 nanometres over a 15-second pushing audit.
  • A separate cold-start default-app audit observes every physics substep: 47,841 robot-contact records, maximum shell/planar penetration 0.711 mm, below the unchanged 2 mm guard, and zero ODE warnings/errors. Its 15-second measurement maintains 1.0001× simulation speed and 54.2 FPS.
  • Existing rotated/mixed-radius robot-pair, ball/dribbler, analytic physics, defaults, worker and trajectory regressions remain enabled.

Profiling data, reports, private-access harnesses and rejected prototypes remain outside Git. README/INSTALL contain reusable setup and policy guidance. Helper scheduling may change floating-point trajectories; use the explicit serial override for reproducible comparisons. The Mac package remains ad-hoc signed; hosted graphics checks use Apple Software Renderer and do not measure physical Mac GPU throughput.

Verified Apple Silicon ODE app, macOS 15 or later.

@fred-huang122
fred-huang122 marked this pull request as ready for review November 1, 2026 03:41
Pin double-precision ODE 0.16.6, isolate per-world schedulers, retain
opt-in helpers, correct cylinder inertia and ball-ground resistance,
and derive conservative collision masks including the chassis hull.

Keep automated physics, trajectory, concurrency and chassis regressions
plus a reusable benchmark. Retain concise setup/defaults documentation.
Keep local research, raw data, plots and one-off analysis tools out of
the branch history; their previous state is preserved locally.

Runtime, build and retained test inputs are byte-for-byte identical to
the validated ODE implementation. Native Apple Silicon packaging and
macOS 15/26 download checks remain unchanged.
@fred-huang122
fred-huang122 force-pushed the perf/ode-0.16.6-integration branch from 18c76f4 to 95e1270 Compare November 1, 2026 04:43
@fred-huang122 fred-huang122 changed the title Upgrade ODE physics and validate the Apple Silicon application Upgrade ODE physics with focused regression coverage Nov 1, 2026
Attach the sphere directly to the chassis and preserve the old combined mass and inertia, removing one body and fixed joint per robot. Add dynamic pair and six-a-side penetration checks and reject solver errors. Isolate the kinematic hull fixture from driving/rolling constraints and synchronize window exposure in its rendering check.
@fred-huang122 fred-huang122 changed the title Upgrade ODE physics with focused regression coverage Upgrade ODE to 0.16.6 and correct robot contact geometry Nov 1, 2026
Use native double-precision triangular solves and dot products for kernels with at least 64 entries: Accelerate on macOS and optional single-threaded OpenBLAS elsewhere. Keep scalar fallback and direct ODE stepping. Add pinned-kernel, residual, stride, concurrent-call and fallback regressions, and reproducible dependency patching.
@fred-huang122 fred-huang122 changed the title Upgrade ODE to 0.16.6 and correct robot contact geometry Upgrade ODE, correct robot contacts and speed up dense crowds Nov 2, 2026
Read row-major factors directly in four-row AVX2 solves to avoid BLAS packing and dispatch overhead. Detect CPU support at runtime and retain existing BLAS, Accelerate and scalar fallbacks. Keep contact geometry, materials and physics substeps unchanged; extend residual/reference checks through 1025 rows and report triangular dispatch.
The live pushing case contains three independent contact groups and exceeds the serial frame budget despite faster matrix kernels. Use up to three helpers on large multicore games while retaining serial stepping for small worlds and explicit overrides. Keep collision detection, the direct solver and substeps unchanged. Publish actual worker counts in snapshots and test startup, rebuilds, overrides and shutdown through the real controller.
@fred-huang122 fred-huang122 changed the title Upgrade ODE, correct robot contacts and speed up dense crowds Upgrade ODE, correct robot contacts and accelerate dense physics Nov 2, 2026
@fred-huang122
fred-huang122 merged commit e213389 into master Nov 2, 2026
5 checks passed
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