Skip to content

Improve partition box key hashing - #7

Open
yuqian19870725-creator wants to merge 4 commits into
carbonengine:mainfrom
yuqian19870725-creator:main
Open

Improve partition box key hashing#7
yuqian19870725-creator wants to merge 4 commits into
carbonengine:mainfrom
yuqian19870725-creator:main

Conversation

@yuqian19870725-creator

Copy link
Copy Markdown

Summary

  • replace the linear implicit size_t conversion with a dedicated KeyHash
  • hash each coordinate independently to reduce unordered-map bucket collisions
  • add regression coverage for coordinates that previously collided and for 16³ distinct box lookups

Validation

  • MSVC v143 standalone compile/runtime check passed using the updated Partition.h
  • 16³ distribution check improved from 106 distinct old hashes to 4,096 distinct new hashes
  • the full CMake configure could not complete because the project triplet requires the unavailable Visual Studio v141 toolset

@sverrirsccp

Copy link
Copy Markdown

Hey there - thanks a lot for your contribution!

I work at Fenris Creations and wanted to let you know that we've acknowledged your PR. We'll take a proper look at it as soon as we can and really appreciate you taking the time to contribute.

@ccpgames-carbon

ccpgames-carbon commented Jul 20, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread tests/TestPartition.cpp Outdated
Comment thread src/Partition.h

@hrafn hrafn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the current hash function here does not spread things out as much as we would like, but am not entirely convinced of this new approach, as it seems a bit over-elaborate, and adds a test that doesn't seem to add any value.

@yuqian19870725-creator

Copy link
Copy Markdown
Author

@hrafn Thanks again for the detailed feedback. I added benchmark results and rationale to the hash-combiner thread, and would appreciate a fresh review of the current revision when you have a chance. If you still prefer a simpler approach or want the collision test changed/removed, I am happy to update the PR accordingly.

@hrafn hrafn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you make a convincing argument for your hashing approach, but the tests need cleaning up.

Remove the RetainsEveryDistinctBoxKey test, and I'd be happy to merge this in.

@yuqian19870725-creator

Copy link
Copy Markdown
Author

@hrafn Done — I removed the RetainsEveryDistinctBoxKey test as requested. The focused regression test remains. Thanks for the review; this should be ready to merge.

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.

4 participants