Repository navigation
Collision: the broad phase hands over each pair once, and never more than every pair - #59
Merged
Merged
Conversation
…than every pair -- many objects sharing many cells made it the pairs times the cells they share: 164 objects gave 20 million candidates a frame, for 13 366 pairs, and the nightly's behaviors property sat an hour in that sort until the shard's 60-minute limit cancelled the run (17, 18 and 19 November). A pair comes from the first cell its two spans share; past every pair, the loop the grid is an optimisation of. The order is the sorted one it was, so no callback moves. The property: over an hour, then 16.6 s at the nightly's seed and 5000 cases
…ess.run(text=True) decodes strictly, so a byte that is not UTF-8 raises there and never comes back as one. Drawn with them, git rev-parse 'printed' '\ud800' and Path.resolve() could not encode a folder name no git can have answered (Hypothesis, the nightly run on this branch, test_rmp_update; replayed red on the old generator)
…bytes that are not UTF-8 -- the one exception to R7, by Omar's decision (2026-11-20); the rmp properties' docstring says so
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.
What changed, and why
The nightly
deep.ymlruns of 17, 18 and 19 November endedcancelled. In each one, theproperties (1)shard reached its 60-minutetimeout-minutes.I replayed shard 1 (cases 1-40) here with the nightly's settings (
seed=12345 max_success=5000) and--duration:tests/property/behavior_more_prop.cpp:448): still running after 3731 s.gdb shows the property inside
candidate_pairs()(src/rmp/scene/collision.cpp), sorting a vector of 20 608 486 pairs. That came from 164 objects, which have only 13 366 pairs between them. The cause is in the framework, not the test: when many objects share many cells (a volley of bullets whose sweeps cross the grid), each cell handed over every pair it held. The total was the pairs times the cells they share, and it was sorted and de-duplicated every frame.The fix, in
candidate_pairs():(max x0, max y0)of their overlap. This is the same set as before, without duplicates.Σ k(k-1)/2 > n(n-1)/2, counted from the counting sort's starts), the pass takes the all-pairs loop. The grid is an optimisation of that loop, and the code already treats the loop as correct.(a, b), as before, so no callback changes order and no golden moves.After the fix, that property takes 16.6 s at the nightly's seed and 5000 cases.
objects::detail::candidates_for_tests()(insrc/rmp/scene/object_internal.h, which is internal, notinclude/) tells the test how many pairs one pass gathered.The timeout is unchanged and no gate is touched.
Second commit (d45dd34): the next finding of the same nightly. Fixes #60.
The nightly dispatched on this branch (run 44602911780) went on to fail its
hypothesisjob inMainIsTotalTest.test_rmp_update, withUnicodeEncodeError: ... '\ud800' ... surrogates not allowedfromPath.resolve()incmd_update. The program output that made it wasgit rev-parse --show-toplevelanswering'\ud800', and no real git can answer that:subprocess.run(text=True)decodes strictly, so a byte that is not UTF-8 raisesUnicodeDecodeErrorthere and never comes back as a lone surrogate.printf '\355\240\200'(U+D800's own bytes) raises too.SHORTintests/rmp_property_test.pynow leaves out categoryCs, asTYPEDalready does for argv.Third commit (a84d640): Omar's decision on what the second leaves out. A git that prints bytes that are not UTF-8 (a framework cloned into a folder whose name is not UTF-8) makes
rmpdie withUnicodeDecodeErroras a traceback. Omar decided on 2026-11-20 to leave it so, as the one exception to R7 ("a sentence, never a traceback"). It is written inCLAUDE.md's standing rules, with his name and the date, and intests/rmp_property_test.py's docstring.The ladder
rmp fmt checkrmp lint--experimental-custom-checks)collision.cpp27 andcollision_test.cpp9custom-rmp-raw-pointer, exactlytools/lint_debt.txtunit_test(sanitized Debug)property_test(collision, grid and pair cases)seed=12345 max_success=5000rmp test(xvfb-run -a ./rmp test)rmp_property_testci: 38 tests OK; profilenightly,MainIsTotalTest: 21 tests OK (325 s)properties (1)success in 37 min 52 s (it was cancelled at 60 min on 17, 18 and 19 Nov); shards 2-4: 22, 18, 19 min; every fuzz target success;hypothesisred on #60, fixed by d45dd34seed=12345 max_success=5000)Seen red first
The generator fix: the nightly's counterexample (
@reproduce_failure('6.168.5', b'AXicY3BkYAAjTAgiGJvfLmgAAE4VBiA=')) was replayed on the old generator and printedUnicodeEncodeError: 'utf-8' codec can't encode character '\ud800'. On the new one, the class passes at nightly strength."the broad phase never hands over more pairs than there are" (
tests/collision_test.cpp). The world is 300 small objects and 100 objects of 2000 by 2000 over the same cells. I put the old behaviour back on a copy (no bound, no first-cell rule) and the test printedCHECK( 111570 <= 79800 ) is NOT correct!. With the fix it passes."they agree where many big objects share many cells": the existing grid-against-loop differential, on the same world. It now goes through the fallback path and must give the same touching set. It is a differential, so it was not planted red.
Not verified
rmp test coverageand thecollisionmutation module: these are measured in the pinned image, so CI's coverage job and the weekly run will say.Checklist
rmp fmt checkis clean.rmp lintis clean: no new warning, and aNOLINTonly with its reason.rmp testpasses.rmp test examplespasses: not applicable (no public API, example, scene, input or UI change).rmp test sanitizepasses: not applicable (nothing that parses, casts or frees).rmp test fuzzpasses: not applicable (no parser).rmp test coveragepasses in the pinned image (CI).Generated by Claude Code