fix(buffer): address allocator review follow-ups - #9745
Conversation
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Merging this PR will degrade performance by 15.34%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | allocate_freeze_drop_vortex_minimal_alignment[64] |
3.5 µs | 5.6 µs | -37.77% |
| ❌ | Simulation | take_fsl_f16_force_per_index[2048, 10] |
361.1 µs | 545.3 µs | -33.78% |
| ❌ | Simulation | chunked_varbinview_canonical_into[(1000, 10)] |
365.5 µs | 551 µs | -33.66% |
| ❌ | Simulation | allocate_drop_vortex[0] |
957.4 ns | 1,428 ns | -32.95% |
| ❌ | Simulation | chunked_varbinview_into_canonical[(1000, 10)] |
405.1 µs | 593.3 µs | -31.72% |
| ❌ | Simulation | take_fsl_f16_force_per_index[1024, 10] |
209.4 µs | 301.3 µs | -30.52% |
| ❌ | Simulation | chunked_varbinview_opt_into_canonical[(1000, 10)] |
442.7 µs | 625.3 µs | -29.2% |
| ❌ | Simulation | chunked_varbinview_opt_canonical_into[(1000, 10)] |
426.4 µs | 594.7 µs | -28.31% |
| ❌ | Simulation | take_fsl_f16_force_per_index[512, 10] |
133.5 µs | 179.7 µs | -25.73% |
| ❌ | Simulation | allocate_drop_vortex_minimal_alignment[0] |
901.5 ns | 1,206.1 ns | -25.25% |
| ❌ | Simulation | chunked_varbinview_canonical_into[(100, 50)] |
272.6 µs | 362.5 µs | -24.81% |
| ❌ | Simulation | chunked_varbinview_into_canonical[(100, 50)] |
347.2 µs | 438.2 µs | -20.77% |
| ❌ | Simulation | runend_compress_u32 |
389.2 µs | 487.6 µs | -20.18% |
| ❌ | Simulation | chunked_varbinview_opt_canonical_into[(100, 50)] |
362.5 µs | 451.1 µs | -19.64% |
| ❌ | Simulation | take_fsl_f16_force_per_index[256, 10] |
94.5 µs | 117.6 µs | -19.64% |
| ❌ | Simulation | compress[(10000, 4)] |
486.2 µs | 604.9 µs | -19.62% |
| ❌ | Simulation | non_nullable[32] |
252.7 µs | 313.1 µs | -19.3% |
| ❌ | Simulation | non_nullable[256] |
246.3 µs | 305 µs | -19.27% |
| ❌ | Simulation | nullable[256] |
247.7 µs | 306.6 µs | -19.21% |
| ❌ | Simulation | nullable[32] |
254.3 µs | 314.7 µs | -19.21% |
| ... | ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ngates/buffer-review-followups (8861f3e) with develop (dab1684)
Footnotes
-
218 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
| let offset = ptr.addr().get() - allocation.ptr().addr().get(); | ||
| let capacity = if allocation.size() == 0 { | ||
| let capacity = if size_of::<T>() == 0 { | ||
| usize::MAX |
There was a problem hiding this comment.
This is the same as native Rust Vec
| /// The minimum alignment promised for `ptr` and preserved by aligned slices. | ||
| pub(crate) alignment: Alignment, |
There was a problem hiding this comment.
When does this differ from size_of::<T>?
There was a problem hiding this comment.
This is what vortex buffer has always done, we support arbitrary alignment.
Both develop and here in fact over-align to a min of 256 bytes
| let allocation_size = size | ||
| .checked_add(actual.as_usize()) | ||
| .vortex_expect("buffer capacity overflow"); | ||
| Layout::from_size_align(allocation_size, 1).unwrap_or_else(|_| { |
There was a problem hiding this comment.
Why do we align to one byte here?
There was a problem hiding this comment.
Not we have access to a custom allocator we can get aligned memory regions directly
There was a problem hiding this comment.
We likely want to over align to some well known mem pool sizes, if such a thing exists
Signed-off-by: Nicholas Gates <nick@nickgates.com>
|
are those perf changes real? |
|
looks like we are allocating then we are aligning and that's majority of the time |
|
That's what I meant @joseph-isaacs that passing a real alignment is slower |
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Summary
BufferAllocatorRefanArcRef<dyn BufferAllocator>. Callers can provide a staticreference or an owned
Arc.StaticBufferAllocator.Allocator::grow.Vecallocations with a static reference toGlobal.BufferMut. It remains 64 bytes on 64-bit targets.it mutable.
usize::MAXcapacity, matchingVec.Benchmark
cargo bench -p vortex-buffer --bench allocation -- --min-time 0.1Medians on an Apple M5 Max. “Static” and “Arc” use the same 256-byte-aligning allocator. “Global”
uses a static
Globalreference and requests one-byte alignment.The static-reference and
Arcforms are within noise. The visible cost comes from requesting256-byte alignment, not from
ArcRefdispatch or reference counting.Validation
cargo test -p vortex-buffer --all-featurescargo test -p vortex-array --all-features allocatorcargo test -p vortex-file --all-features test_open_path_uses_memory_session_allocatorcargo clippy -p vortex-buffer -p vortex-array -p vortex-io -p vortex-file --all-targets --all-featurescargo check --workspace --all-features