Skip to content

Toward Box3D in every category: float plain ball joints, profiling and bench fixes - #234

Merged
nicolas-maman merged 4 commits into
mainfrom
perf/solver
Nov 23, 2026
Merged

nicolas-maman merged 4 commits into
mainfrom
perf/solver

Conversation

@nicolas-maman

Copy link
Copy Markdown
Collaborator

Work in progress from the loop to beat Box3D in every benchmark category.

  • Plain ball joints solve their point in single precision, as Box3D does (the user's call: joint maths in float, spherical first, kept only if it wins). Joint grid, pinned, best and median of 5: 10.52 / 10.77 to 10.20 / 10.35 ms, Box3D 10.15 / 10.36, so level where it was 1.05x behind. The golden trace and the human figure are unchanged, because their joints all have limits.
  • profile.sh gives the profiling build ae build's inlining budget. Without it, profiles showed out-of-line maths calls the shipped program never makes.
  • Box3D's bench lines print microsecond precision: large world's 0.0094 ms read as 0.009.
  • AEPHYSICS_BENCH_STEPS and a per-step stages line in both suites.

Tried and reverted, no measurable gain: Box3D's body-frame normals in the wide contact solve; a float mesh query.

Waiting on Aether: #3815 (lane min/max as minps, convex pile); #3849 (@inline, for the contact solver's gather_bodies, about 5% of sleep and the pyramids); #3852 (std.math sqrt inlined, about 3% of trees25).

SNAPSHOT_VERSION 12 (JointSim's spherical data grew).

…l names none

Since Aether 0.937.0 (aether#3779) ae build adds --param
inline-unit-growth=100 to an optimising build whose project names no
budget, and aether.toml names none. profile.sh compiled the generated C
with aether.toml's flags alone, so its program kept mul_quat and
make_matrix_from_quat out of line where the shipped one inlines them,
and its profiles showed calls the real program never makes.
…ence does

The user's call (2026-11-23): joint maths in float like Box3D, the
spherical joint first, kept only if it wins. A ball joint with no
spring, motor, limits or lock (a chain's, the joint grid's) now warm
starts and solves its point in single precision, as
b3WarmStartSphericalJoint and b3SolveSphericalJoint do: the anchors and
the centres' offset narrowed in the prepare (anchor_a, anchor_b,
delta_center_f), the body states and inertias as they are kept (single
precision already, so no widening), the 3x3 point mass and its solve in
floats (point_mass_matrix_f, solve3_f). The impulse is kept in double
but always holds a single's value. A joint with any angular row keeps
the double solve for now.

Joint grid, pinned, best and median of 5 against main: 10.52 / 10.77 to
10.20 / 10.35 ms a step, Box3D 10.15 / 10.36: level with the reference
where it was 1.05x behind. The golden trace and the human figure (whose
joints all have limits) are unchanged.

test_joint_solver's plain-point check asserted an impulse greater than
zero on a point already satisfied: it passed on rounding's 1e-46 in
double and is exactly zero in single precision. The cube now slides as
well as turns before the solve, so the point carries a real impulse,
and the warm start's expected velocity is the single-precision product.

JOINT_DATA_BYTES 744; SNAPSHOT_VERSION 12.
…s ours do

suite_box3d and physics_world_box3d printed a step's milliseconds to
three decimals: large world's 0.0094 ms read as 0.009 and 0.0096 as
0.010, coarser than the difference being measured against aephysics'
step (printed in full). Six decimals now, and the total to three.
…nd both print the solver stages per step

A scene whose setup outweighs its steps (large world's million static
bodies) can now be profiled over its steps: AEPHYSICS_BENCH_STEPS=n runs
every scene n steps in suite.ae and suite_box3d.c alike. Both print a
stages line (solve, transforms, refit, sleep islands, sensors) beside
the pairs and collide phases, so a gap can be placed by stage: large
world's 6% is the solve (6.5 to 7.5 us a step against Box3D's 5.8 to
6.3), its spheres landing on several floor boxes each.
@nicolas-maman
nicolas-maman merged commit 34f9abd into main Nov 23, 2026
3 checks passed
@nicolas-maman
nicolas-maman deleted the perf/solver branch November 23, 2026 20:10
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