Skip to content

Optimize immutable id tracker mapping - #6023

Merged
generall merged 8 commits into
devfrom
optimize-immutable-id-tracker-mapping
Feb 20, 2025
Merged

generall merged 8 commits into
devfrom
optimize-immutable-id-tracker-mapping

Conversation

@generall

Copy link
Copy Markdown
Member

No description provided.

Comment on lines +102 to +103
let mut external_to_internal_num: Vec<(u64, PointOffsetType)> = Vec::new();
let mut external_to_internal_uuid: Vec<(Uuid, PointOffsetType)> = Vec::new();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I consider overallocating here once better than having to reallocate a few times.

Suggested change
let mut external_to_internal_num: Vec<(u64, PointOffsetType)> = Vec::new();
let mut external_to_internal_uuid: Vec<(Uuid, PointOffsetType)> = Vec::new();
let mut external_to_internal_num: Vec<(u64, PointOffsetType)> = Vec::with_capacity(len);
let mut external_to_internal_uuid: Vec<(Uuid, PointOffsetType)> = Vec::with_capacity(len);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

my logic was that only one of them actually filled, so didn't want to allocate more memory on start than needed

deleted: BitVec,
internal_to_external: CompressedInternalToExternal,
external_to_internal: CompressedExternalToInternal,
) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We must enforce the size of deleted here, since this structure does not support dynamically sized deleted flags currently.

PointMappings is an example of where the deleted flags can have a different size:

    // It is possible that `deleted` can be longer or shorter than `internal_to_external`.
    // - if `deleted` is longer, then extra bits should be set to `false` and ignored.
    deleted: BitVec,

I'll add an explicit resize for now to prevent that problem. We can do that since we own the types here.

@timvisee timvisee Feb 20, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Base automatically changed from optimize-immutable-id-tracker to dev February 20, 2025 12:41
@timvisee
timvisee force-pushed the optimize-immutable-id-tracker-mapping branch from 16e88b9 to e330add Compare February 20, 2025 12:44

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🙌 Nice!

I rebased onto #6022 after merging it and committed some review remarks.

@timvisee
timvisee force-pushed the optimize-immutable-id-tracker-mapping branch from e330add to cb93323 Compare February 20, 2025 12:46
@generall
generall merged commit 8d5a34e into dev Feb 20, 2025
@generall
generall deleted the optimize-immutable-id-tracker-mapping branch February 20, 2025 13:21
timvisee added a commit that referenced this pull request Mar 21, 2025
* clone PointMappings into CompressedPointMappings

* fmt

* compressed internal to external

* implement compressed external to internal mapping

* some autogenerated tests

* fix test

* Explicitly resize deleted flags, ensure length matches number of points

* Review remarks

---------

Co-authored-by: timvisee <[email protected]>
@timvisee timvisee mentioned this pull request Mar 21, 2025
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.

2 participants