-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor serialization buffer management and support memory tracking. (…
…#5231) [SC-50984](https://app.shortcut.com/tiledb-inc/story/50984/evaluate-proper-solution-for-serialization-code-base-to-use-tracked-buffers) This PR adds support for tracking memory used by serialization buffers. The first step towards implementing this is the replacement of the `Buffer` class with the new `SerializationBuffer` class, which has the following characteristics: * Like `Buffer`, `SerializationBuffer` supports both owned and non-owned memory buffers. This is necessary to maintain the semantics of the `tiledb_buffer_t` C API. `SerializationBuffer` also allows swapping between owned and non-owned modes. * `SerializationBuffer` does not support the `write` function which incrementally adds data by growing the buffer. Instead, it supports only the `assign` operation, which replaces the whole existing data of the buffer. `assign` copies the given data to a buffer owned by `SerializationBuffer`, unless a special marker value is passed, which changes it to just store a span to the buffer. * There is also the `assign_null_terminated` method that sets an owned buffer and adds a null terminator at the end. This is used by JSON serialization for some reason (is it actually needed?). * `SerializationBuffer` does not store an offset and does not expose a `read` function that copies to a user-provided buffer and advances the offset. Instead the class is implicitly convertible to a const span of bytes, which gives access to the entire buffer at once. * `SerializationBuffer`s are typically immutable between `assign`ments, but some cases require subsequent modification. To cover these, the `owned_mutable_span` function returns a mutable span to the buffer, but will throw if used in a non-owned buffer. * `SerializationBuffer` supports being used with polymorphic allocators, which enables integration with the memory tracking system. A new `MemoryTracker` was added on `ContextResources` to track serialization-related allocations. `BufferList` was also updated to store `SerializationBuffer`s. Creations of serialization buffers and buffer lists were updated to pass an allocator, and C API handles for both types were likewise updated. I also took up on the opportunity and converted all deserialization APIs that accepted a `Buffer` to accept a `span<const char>`, because they did not need any other facilities of `SerializationBuffer`. --- TYPE: NO_HISTORY --------- Co-authored-by: Luc Rancourt <[email protected]>
- Loading branch information
1 parent
9ebf9cd
commit ef7aba6
Showing
53 changed files
with
1,146 additions
and
1,067 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.