Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Box3D’s 64-bit content hashing to avoid a mixing weakness (low hash bits not being influenced by high input bytes) and adds a targeted regression test to ensure full-width mixing for geometry content hashes.
Changes:
- Reworked
b3Hash64NonZeroto hash byte-by-byte (FNV-1a) followed by a splitmix64 finalizer. - Added a unit test that detects the specific “upper-byte doesn’t affect low hash bits” failure mode.
- Updated documentation/versioning references to reflect 64-bit hashing and the new hash behavior for serialized geometry.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
test/test_recording.c |
Adds GeometryHashWidth subtest to ensure the hash function reaches the full 64-bit space for structured inputs. |
src/core.c |
Replaces the previous 8-byte-at-a-time hashing optimization with byte-wise FNV-1a and a splitmix64 finalizer. |
samples/gfx/geometry_registry.h |
Updates comment to reflect that the geometry registry is keyed by a uint64_t content hash. |
include/box3d/types.h |
Updates serialized-data version constants for hull/mesh/height-field to match the new hashing behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| // Fowler/Noll/Vo FNV-1a salted by length, then the splitmix64 finalizer so tiny inputs | ||
| // still spread across all bits. | ||
| // FNV-1a with splitmix64 finalizer so tiny inputs still spread across all bits. |
hash function unit tests
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.
The 64-bit hash function was not well tested and had a bad optimization.
Switched to using rapidhash: https://github.com/Nicoshev/rapidhash