Repository navigation
Conversation
DynamicIntegerPointsKdTreeDecoder allocates memory quadratic in the
point dimension, up front, in its constructor. The dimension is the
total number of components over all attributes, and a stream sets it at
five bytes per attribute. This change makes the decoder's memory linear
in the dimension. The decoded output is unchanged.
Decoder memory by dimension, main always allocated against this change
at most:
3 components: 2.3 KB -> 1.6 KB
64 components: 1 MB -> 33 KB
255 components: 17 MB -> 133 KB
2,048 components: 1.1 GB -> 1.1 MB
6,375 components: 10 GB -> 3.3 MB
A 143-byte point cloud with 25 attributes of 255 components makes main
commit about 10 GB before it reads any KD-tree data, and then fail. With
this change it fails without that allocation. A valid 8,372-byte stream
of three points with 2,048 components decodes with about 5 MB in 80 ms,
against 1.1 GB and 1 to 1.9 s on main. Ordinary point clouds decode as
fast or faster, from 1% faster with 3 components to 30% faster with 64.
The decoder kept a full copy of the node's base and levels for every
level of the tree, which is 32 * dimension levels deep. A split changes
only one base value and one level. The decoder now keeps a single base
and levels vector, records the old values at each split, and restores
them when the walk returns to a shallower node.
This branch has not been deployed
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.
DynamicIntegerPointsKdTreeDecoder allocates memory quadratic in the point dimension, up front, in its constructor. The dimension is the total number of components over all attributes, and a stream sets it at five bytes per attribute. This change makes the decoder's memory linear in the dimension. The decoded output is unchanged.
Decoder memory by dimension:
What this means for actual streams:
How: the decoder kept a full copy of the node's base and levels for every level of the tree, which is 32 × dimension levels deep. A split changes only one base value and one level. The decoder now keeps a single base and levels vector, records the old values at each split, and restores them when the walk returns to a shallower node.
Verification: