tests/AABB: de-flake dynamic-vs-brute-force timing assertion - #2560
Merged
Merged
Conversation
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
enabled auto-merge (squash)
September 1, 2026 17:49
alecjacobson
disabled auto-merge
September 1, 2026 18:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
AABB: dynamictest (tests/include/igl/AABB.cpp) gates a speed comparison onF.rows() > 300:Each
t_*is a single-point query (one barycenter) averaged overMAX_RUNS = 10runs — 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 thet_dynamic_tree < t_brute_forceassertion flakes.Observed on an unrelated PR's CI (
ubuntu-24.04 Static tutorial tests):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,443assertions each).Found while investigating a flaky CI failure on #2558 (the flake is pre-existing and unrelated to that PR).
🤖 Generated with Claude Code