-
Notifications
You must be signed in to change notification settings - Fork 517
use std::vector instead of PooledAllocator #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
use std::vector instead of PooledAllocator #274
Conversation
Signed-off-by: Luca Bartoli <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #274 +/- ##
==========================================
- Coverage 86.18% 85.38% -0.81%
==========================================
Files 1 1
Lines 666 643 -23
Branches 124 121 -3
==========================================
- Hits 574 549 -25
- Misses 92 94 +2
🚀 New features to boost your workflow:
|
|
static constexpr size_t BLOCKSIZE = 8192; if you want to be more cache friendly,increase it. use std::vector alloc large mem is not necessary. and. when leaf_max_size = 10 (default) nodes is too imprecise. |
|
Dear @qq422216549
I do not agree, for the cache spatial locality and temporally locality, and to help the ram controller, having continuous memory is the best. We could optimize the formula, the Using |
|
@lucabart97 I like the overall simplification from handmade to std. Let me check it locally carefully and do an independent benchmark before taking the decision to merge, since this would have a relevant impact. |
|
@jlblancoc what I miss is a smart formula to know the number of nodes given the input and the leaf sizes |
|
@lucabart97 My ideas: On the general approachWhy not using On the "smart formula"I think that the worst, worst case would be having all leafs with just one point. But we must use heuristics not to waste memory for "most common cases". Then, going up the tree, each level has 1/2 nodes the former level, so it's a sum of a geometric series: Actually, the mathematical ideal infinite sum should end when the a level has 1 node only, but the difference is insignificant. We could test this formula with some real dataset to check if it's close to reality. Then, together with the |
While comparing pointer-based and index-based approaches, I tested the
PooledAllocator. It appears to segment memory, which can negatively affect cache locality. To address this, I experimented with storing the entire tree in a single contiguous buffer usingstd::vector, making the structure more cache-friendly.I perform some tests:


I think that
size_t nodes = 4 * (Base::size_ / Base::leaf_max_size_);is not the best formula to predict the Nodes size, so the build time is affected by that (?)Suggestions are welcome :)