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
Don't create CompressionContext when no compression is selected [IPC] #9463
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
When attempting to run Miri on a program using arrow-ipc, there are always error on foreign calls, even when not using ZSTD, due to the CompressionContext being created all the time, even when compression is None.
I don't think we should be making unnecessary FFI calls unless we intend to use the encoder/decoder.
This is relevant both for the arrow-ipc crate, and the arrow-flight crate, but both are from the same underlying issue.
Describe the solution you'd like
CompressionContext should be an Option, or the zstd encoder/decoder within it should be an Option.
This Option should only be Some when compression is specified.
Describe alternatives you've considered
Tried disabling the feature, but it leads to a cascade of compilation failures so big it's not really worth trying to untangle right now.
We hit this in Apache DataFusion Comet when upgrading to arrow-ipc 58.1.0. Our Miri CI started failing on a test that only uses lz4 compression, because StreamWriter::try_new() unconditionally creates a CompressionContext::default() which eagerly calls ZSTD_createCCtx().
Activity
mbutrovich commentedon Apr 24, 2026
We hit this in Apache DataFusion Comet when upgrading to arrow-ipc 58.1.0. Our Miri CI started failing on a test that only uses lz4 compression, because
StreamWriter::try_new()unconditionally creates aCompressionContext::default()which eagerly callsZSTD_createCCtx().Call chain:
The root cause is in
arrow-ipc/src/compression.rs:Same issue exists for
DecompressionContext.Proposed fix
Wrap the compressor/decompressor in
Optionand lazy-init on first use:Then in
compress_zstd, usectx.zstd_compressor()instead ofctx.compressor. Same pattern forDecompressionContext.This preserves the context reuse optimization from #8405/#9400 while avoiding the unnecessary FFI call when zstd isn't the selected codec.
CC @albertlockett @Dandandan
albertlockett commentedon Apr 24, 2026
sounds good @mbutrovich ! Thanks for the detailed investigation
fix: lazy-init zstd compression contexts to avoid unnecessary FFI cal…
alamb commentedon Apr 28, 2026
label_issue.pyautomatically added labels {'arrow'} from #9808alamb commentedon Apr 28, 2026
label_issue.pyautomatically added labels {'performance'} from #9808fix: lazy-init zstd compression contexts to avoid unnecessary FFI cal…