Skip to content

tests/AABB: de-flake dynamic-vs-brute-force timing assertion - #2560

Merged
alecjacobson merged 2 commits into
mainfrom
horde/deflake-aabb-timing
Sep 1, 2026
Merged

alecjacobson merged 2 commits into
mainfrom
horde/deflake-aabb-timing

Conversation

@alecjacobson

Copy link
Copy Markdown
Contributor

Problem

The AABB: dynamic test (tests/include/igl/AABB.cpp) gates a speed comparison on F.rows() > 300:

if(F.rows() > 300) {
  REQUIRE(t_dynamic_tree < t_static_tree);
  REQUIRE(t_dynamic_tree < t_brute_force);
}

Each t_* is a single-point query (one barycenter) averaged over MAX_RUNS = 10 runs — only a few microseconds. On small/medium meshes the tree's O(log n) advantage over the O(n) brute-force scan is within timing noise (effectively a wash around ~1e3 faces), so on shared CI runners the t_dynamic_tree < t_brute_force assertion flakes.

Observed on an unrelated PR's CI (ubuntu-24.04 Static tutorial tests):

tests/include/igl/AABB.cpp:229: FAILED:
  REQUIRE( t_dynamic_tree < t_brute_force )
with expansion:  0.0000473499 < 0.0000459433   ← lost by ~3%
with message:    decimated-knight.obj          ← 1000 faces

The meshes that hit this comparison are {decimated-knight.obj 1000, decimated-knight.mesh 3544, truck.obj 4770, bunny.off 69451, elephant.off 157160}. The tree only robustly beats brute force on the last two (~100×); the smaller ones are noise-dominated.

Fix

Raise the comparison threshold from 300 to 10000 faces, so the timing assertions only run where the asymptotic advantage clearly dominates measurement noise (bunny + elephant). The dynamic tree's correctness (indices, distances, structure) is still verified on every mesh — only the timing comparison is gated.

Passed 5/5 local runs (1,170,443 assertions each).

Found while investigating a flaky CI failure on #2558 (the flake is pre-existing and unrelated to that PR).

🤖 Generated with Claude Code

Horde and others added 2 commits September 1, 2026 16:04
The "AABB: dynamic" test compared a single-point tree query (averaged over 10
runs, only a few microseconds) against brute force and required the tree to be
faster for any mesh with >300 faces. On small/medium meshes the tree's O(log n)
advantage over the O(n) scan is within timing noise — effectively a wash around
1e3 faces — so on shared CI runners this flaked (observed 47.3us vs 45.9us on
decimated-knight, 1000 faces).

Raise the comparison threshold from 300 to 10000 faces so the speed assertions
only run where the asymptotic advantage robustly dominates measurement noise
(bunny ~69k and elephant ~157k faces, where the tree wins by ~100x). Correctness
of the dynamic tree is still checked on all meshes; only the timing comparison is
gated. Passed 5/5 local runs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alecjacobson
alecjacobson enabled auto-merge (squash) September 1, 2026 17:49
@alecjacobson
alecjacobson merged commit e095673 into main Sep 1, 2026
0 of 18 checks passed
@alecjacobson
alecjacobson deleted the horde/deflake-aabb-timing branch September 1, 2026 18:11
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