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
Slow local file reads when using GetResult.into_stream #693
Describe the bug
See apache/datafusion#21450
Root cause: there's a spawn_blocking call per each 8KiBs read from the file, adding significant context switch overhead
To Reproduce
See apache/datafusion#21446
For the tests I've used a c7a.16xlarge ec2 instance, with a trimmed down version of hits.json to 51G (original has 217 GiB), with a warm cache (by running cat hits_50.json > /dev/null)
Expected behavior
A more efficient implementation (e.g. tokio uses a buffer size of 2MiBs when reading files)
I think the trade-off here depends on which is more precious, memory or CPU/latency. 2MB might be peanuts in an analytics context, but significant in contexts with higher concurrency.
Perhaps we could make this configurable, e.g. as a parameter?
Even without increasing the buffer size, we could reduce the context switch overhead, e.g. by using a single spawn_blocking thread and an mpsc channel, as I mentioned in apache/datafusion#21478 (comment) when considering alternative implementations.
Activity
tustvold commentedon Apr 14, 2026
I think the trade-off here depends on which is more precious, memory or CPU/latency. 2MB might be peanuts in an analytics context, but significant in contexts with higher concurrency.
Perhaps we could make this configurable, e.g. as a parameter?
ariel-miculas commentedon Apr 14, 2026
Even without increasing the buffer size, we could reduce the context switch overhead, e.g. by using a single
spawn_blockingthread and an mpsc channel, as I mentioned in apache/datafusion#21478 (comment) when considering alternative implementations.tustvold commentedon Apr 14, 2026
Does that not just move the problem into how big to make the mpsc buffer?
ariel-miculas commentedon Apr 14, 2026
Not really, cause you eliminate the overhead of creating one
spawn_blockingtask per chunk.ariel-miculas commentedon Apr 14, 2026
using an mpsc channel with one slot and sending 8KiB at a time, I get this result:
whereas with the existing
into_streamimplementation I get:tustvold commentedon Apr 14, 2026
In which case SGTM 😄
ariel-miculas commentedon Apr 14, 2026
The only problem is that a long-living
spawn_blockingthread runs into this sort of thing: apache/datafusion#15654