-
Notifications
You must be signed in to change notification settings - Fork 9
perf: object pool #192
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
base: main
Are you sure you want to change the base?
perf: object pool #192
Conversation
CodSpeed Performance ReportMerging #192 will improve performances by 20.83%Comparing Summary
Benchmarks breakdown
Footnotes
|
eac1e0d to
3a3faac
Compare
54f2f12 to
724819e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a MemoryPool system to optimize memory allocations by reusing Vec<usize> buffers, particularly for the WithIndices struct. The pool uses a BTreeMap to organize vectors by capacity and only pools vectors with capacity ≥ 64 elements to balance pooling benefits with overhead.
- Adds
MemoryPoolandPooledUsizeVecfor efficient vector reuse - Threads
memory_poolparameter through theStreamChunkstrait and all implementations - Updates
WithIndicesto use pooled vectors instead of regularVec<usize> - Refactors
MapOptionsto manually implementPartialEq,Eq, andHashtraits
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/memory_pool.rs | Introduces new memory pool infrastructure with MemoryPool and PooledUsizeVec types |
| src/with_indices.rs | Updates to use PooledUsizeVec instead of Vec<usize> with lifetime parameter changes |
| src/source.rs | Adds manual trait implementations for MapOptions and threads memory_pool parameter through StreamChunks |
| src/helpers.rs | Updates all streaming functions to accept and pass through memory_pool parameter |
| src/source_map_source.rs | Threads memory_pool parameter and creates default pool where needed |
| src/replace_source.rs | Updates to use memory_pool when creating WithIndices instances |
| src/raw_source.rs | Adds memory_pool parameter to StreamChunks implementations (unused) |
| src/original_source.rs | Adds memory_pool parameter to StreamChunks implementation (unused) |
| src/concat_source.rs | Threads memory_pool parameter through nested stream_chunks calls |
| src/cached_source.rs | Threads memory_pool parameter and updates tests |
| src/lib.rs | Exports new MemoryPool type |
| tests/compat_source.rs | Updates test implementation to match new StreamChunks signature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR introduces a
ObjectPoolsystem to optimize memory allocations by reusingVec<usize>buffers, particularly for theWithIndicesstruct. The pool uses aBTreeMapto organize vectors by capacity and only pools vectors with capacity ≥ 64 elements to balance pooling benefits with overhead.ObjectPoolandPooledfor efficient vector reusememory_poolparameter through theStreamChunkstrait and all implementationsWithIndicesto use pooled vectors instead of regularVec<usize>