Optimize message encoding buffer reuse#5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| #[global_allocator] | ||
| static GLOBAL_ALLOCATOR: CountingAllocator = CountingAllocator; |
There was a problem hiding this comment.
Avoid defining a second global allocator in benchmarks
The new allocation-counting benchmark unconditionally declares #[global_allocator] static GLOBAL_ALLOCATOR: CountingAllocator = CountingAllocator;. The library already exposes a #[global_allocator] when the mimalloc feature (and thus the ultra/production feature sets) is enabled in src/lib.rs. Running cargo bench --features mimalloc will now fail to compile with “the #[global_allocator] has already been defined” because both the library and the benchmark provide one. Consider guarding the counting allocator behind a cfg that disables it when mimalloc (or any feature that sets a global allocator) is active, or reusing the existing allocator via a wrapper instead of redefining it.
Useful? React with 👍 / 👎.
Summary
FlatBufferBuilderandBytesMutso message encoding no longer allocates new buffers for every payloadBytesviews while updating frame writers to reuse the pooled buffersTesting
inheritsmust not be specified in root profilerelease)