You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove redundant zero-initialization in Arrow IPC reader hot paths #9777
In arrow-ipc/src/reader.rs, buffers are currently allocated with MutableBuffer::from_len_zeroed(len) and then passed to read_exact, which fully overwrites the entire buffer contents.
This results in an unnecessary full memory pass:
first zero-initialization
then complete overwrite by the incoming data
Since read_exact guarantees that the provided slice is fully written on success, the initial zeroing step is redundant and can be safely avoided by allocating with capacity and setting the length before the read.
The use of unsafe set_len is sound in this context because:
the buffer is not accessed or observed between set_len and read_exact
read_exact either fully initializes the buffer or returns an error
on error, the function returns immediately and the buffer is not used
there is no exposure of partially initialized data to safe Rust code
Crash scenarios (e.g., panic, early return, process termination) do not introduce unsoundness because:
if execution stops before read_exact completes, the buffer is never observed
there is no path where uninitialized memory is read after interruption
This invariant is local and can be maintained by ensuring no intermediate access is introduced between set_len and the successful completion of read_exact.
changed the title [-]Avoid redundant zero-initialization in Arrow IPC reader hot paths[/-][+]Remove redundant zero-initialization in Arrow IPC reader hot paths[/+]on Apr 21, 2026
Rather than one giant PR to switch to read_buffer<T> I recommend we do this change as a series of smaller PRs (for each main Array type, for example). That will make it easier (and thus faster) to review. Finding enough contiguous time to review a large PR is very challenging I find
Activity
[-]Avoid redundant zero-initialization in Arrow IPC reader hot paths[/-][+]Remove redundant zero-initialization in Arrow IPC reader hot paths[/+]alamb commentedon Apr 27, 2026
Status update here:
Vecwas a very effective way to increase performance substantially withoutunsafeand take advantage of all Rust's built in optimizations for VecVec<u8>which may require an extra copy for realignment -- see details here)Vec<T>instead ofVec<u8>but that will require more substantial code changes -- see details herealamb commentedon Apr 27, 2026
Rather than one giant PR to switch to
read_buffer<T>I recommend we do this change as a series of smaller PRs (for each main Array type, for example). That will make it easier (and thus faster) to review. Finding enough contiguous time to review a large PR is very challenging I findfix: bound IPC message allocations by the bytes actually read (#10522)
fix: bound IPC message allocations by the bytes actually read (apache…