Skip to content
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

Small size optimization & custom deallocator for rerun::Collection #4256

Open
Tracked by #4260
Wumpf opened this issue Nov 17, 2023 · 0 comments
Open
Tracked by #4260

Small size optimization & custom deallocator for rerun::Collection #4256

Wumpf opened this issue Nov 17, 2023 · 0 comments
Labels
🌊 C++ API C/C++ API specific enhancement New feature or request
Milestone

Comments

@Wumpf
Copy link
Member

Wumpf commented Nov 17, 2023

Whenever a rerun::Collection is owning the data via an allocation, it currently stores it in a std::vector using the default allocator
It would be nice to instead be able to specify arbitrary deallocation for any pointer that is owned by rerun::Collection. Also since rerun::Collection is immutable we shouldn't pay for the capacity field of std::vector either, bloating the size of rerun::Collection unecessarily

Proposed internal data struct to that end:

TElement* _data;
void (*_dealloc)(TElement*);
size_t _size;

Whenever the data is borrowed, _dealloc is null.

Note that this model is also relatively friendly to a small-buffer/inline-buffer optimization:
We can sacrifice one bit on _size to indicate whether an inline buffer is used and then use _data + _dealloc as storage for the inline buffer.

A working prototype of a different implementation of an inline buffer can be found on this branch https://github.com/rerun-io/rerun/tree/andreas/cpp/rerun-collections-small-collection-optimization
(has no custom deallocator support)

@Wumpf Wumpf added other Generated by the "Other" issue template 👀 needs triage This issue needs to be triaged by the Rerun team enhancement New feature or request 🌊 C++ API C/C++ API specific and removed other Generated by the "Other" issue template 👀 needs triage This issue needs to be triaged by the Rerun team labels Nov 17, 2023
@Wumpf Wumpf added this to the Triage milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 C++ API C/C++ API specific enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant