Tell duckdb if we're blocked on IO - #8068
Conversation
Benchmarks: TPC-H SF=10 on S3 📖Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.975x ➖, 2↑ 1↓)
datafusion / vortex-compact / ns (1.044x ➖, 0↑ 2↓)
datafusion / parquet / ns (0.868x ➖, 4↑ 0↓)
duckdb / vortex-file-compressed / ns (1.011x ➖, 0↑ 0↓)
duckdb / vortex-compact / ns (1.034x ➖, 0↑ 0↓)
duckdb / parquet / ns (1.097x ➖, 0↑ 1↓)
|
Benchmarks: FineWeb NVMe 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.991x ➖, 0↑ 0↓)
datafusion / vortex-compact / ns (1.007x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.971x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.965x ➖, 2↑ 2↓)
duckdb / vortex-compact / ns (1.006x ➖, 0↑ 1↓)
duckdb / parquet / ns (0.957x ➖, 0↑ 0↓)
No file size changes detected. |
Benchmarks: FineWeb S3 📖Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.898x ➖, 1↑ 0↓)
datafusion / parquet / ns (0.940x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.023x ➖, 0↑ 0↓)
duckdb / parquet / ns (1.004x ➖, 1↑ 1↓)
|
Benchmarks: TPC-H SF=10 on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.005x ➖, 0↑ 0↓)
datafusion / vortex-compact / ns (1.015x ➖, 0↑ 0↓)
datafusion / parquet / ns (1.007x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.040x ➖, 0↑ 0↓)
duckdb / vortex-compact / ns (1.031x ➖, 0↑ 0↓)
duckdb / parquet / ns (0.983x ➖, 2↑ 0↓)
duckdb / duckdb / ns (1.008x ➖, 0↑ 1↓)
No file size changes detected. |
Benchmarks: TPC-H SF=1 on S3 📖Verdict: No clear signal (environment too noisy confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.013x ➖, 0↑ 1↓)
datafusion / parquet / ns (1.020x ➖, 1↑ 1↓)
duckdb / vortex-file-compressed / ns (1.033x ➖, 0↑ 2↓)
duckdb / parquet / ns (1.014x ➖, 0↑ 0↓)
|
Benchmarks: Statistical and Population Genetics 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
duckdb / vortex-file-compressed / ns (1.040x ➖, 0↑ 2↓)
duckdb / parquet / ns (1.001x ➖, 0↑ 0↓)
File Size Changes (2 files changed, -32.3% overall, 0↑ 2↓)
Totals:
|
Benchmarks: TPC-DS SF=1 on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.997x ➖, 2↑ 1↓)
datafusion / parquet / ns (1.006x ➖, 0↑ 1↓)
duckdb / vortex-file-compressed / ns (1.060x ➖, 1↑ 22↓)
duckdb / parquet / ns (0.995x ➖, 4↑ 0↓)
File Size Changes (25 files changed, -43.5% overall, 0↑ 25↓)
Totals:
|
Benchmarks: Clickbench on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.006x ➖, 0↑ 1↓)
datafusion / parquet / ns (1.000x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.033x ➖, 1↑ 7↓)
duckdb / parquet / ns (1.003x ➖, 0↑ 1↓)
File Size Changes (101 files changed, -39.2% overall, 0↑ 101↓)
Totals:
|
Benchmarks: TPC-H SF=1 on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.994x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.986x ➖, 2↑ 0↓)
duckdb / vortex-file-compressed / ns (1.024x ➖, 0↑ 2↓)
duckdb / parquet / ns (0.995x ➖, 0↑ 0↓)
File Size Changes (9 files changed, -43.9% overall, 0↑ 9↓)
Totals:
|
ac58d6e to
281de76
Compare
Polar Signals Profiling ResultsLatest Run
Previous Runs (1)
Powered by Polar Signals Cloud |
45e50d1 to
4863391
Compare
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
4863391 to
abbfa58
Compare
| /// Poll next item without blocking caller thread | ||
| fn poll_next_item(local_state: &mut TableFunctionLocal) -> NextItem { | ||
| if let Some(future) = local_state.pending.as_mut() { | ||
| let mut ctx = Context::from_waker(std::task::Waker::noop()); | ||
| return match future.poll_unpin(&mut ctx) { | ||
| Poll::Ready(item) => { | ||
| local_state.pending = None; | ||
| if let Some(item) = item { | ||
| NextItem::Ready(item) | ||
| } else { | ||
| NextItem::None | ||
| } | ||
| } | ||
| Poll::Pending => NextItem::BlockedOnIO, | ||
| }; | ||
| } | ||
|
|
||
| match local_state.iterator.try_recv() { | ||
| TryRecv::Item(item) => NextItem::Ready(item), | ||
| TryRecv::Closed => NextItem::None, | ||
| TryRecv::Empty => { | ||
| let rx = local_state.iterator.receiver(); | ||
| local_state.pending = Some(Box::pin(async move { rx.recv().await.ok() })); | ||
| NextItem::BlockedOnIO | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Finish array receive started by scan() | ||
| pub fn wait_and_fetch(local_state: &mut TableFunctionLocal) { | ||
| if let Some(mut future) = local_state.pending.take() { | ||
| // Duckdb calls this on a background task thread pool which is separate | ||
| // from table function processing pool. This call therefore doesn't | ||
| // block the query worker | ||
| let item = RUNTIME.block_on(&mut future); | ||
| // When this assignment is happening, thread related to "local_state" | ||
| // is suspended. It will be resumed only when wait_and_fetch returns | ||
| // so there's no race condition | ||
| local_state.pending = Some(Box::pin(std::future::ready(item))); | ||
| }; | ||
| } |
There was a problem hiding this comment.
this needs very careful explanation.
It also shouldn't be in this mod I would this in the iterator def?
Benchmarks: Clickbench Sorted on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.977x ➖, 1↑ 1↓)
datafusion / parquet / ns (1.025x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.018x ➖, 0↑ 1↓)
duckdb / parquet / ns (0.994x ➖, 0↑ 0↓)
duckdb / duckdb / ns (1.022x ➖, 0↑ 0↓)
File Size Changes (201 files changed, +0.0% overall, 94↑ 107↓)
Totals:
|
| type ScanItemFuture = BoxFuture<'static, Option<ScanItem>>; | ||
|
|
||
| pub struct TableFunctionGlobal { | ||
| iterator: DataSourceIterator, |
There was a problem hiding this comment.
is this used in the scan?
Benchmarks: Appian on NVME 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.003x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.996x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.982x ➖, 1↑ 0↓)
duckdb / parquet / ns (1.001x ➖, 0↑ 0↓)
duckdb / duckdb / ns (0.998x ➖, 0↑ 0↓)
File Size Changes (1 files changed, -0.0% overall, 0↑ 1↓)
Totals:
|
Benchmarks: Vortex queries 📖Verdict: No clear signal (low confidence) How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.999x ➖, 0↑ 0↓)
datafusion / parquet / ns (1.003x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.028x ➖, 0↑ 0↓)
duckdb / parquet / ns (1.004x ➖, 0↑ 0↓)
No file size changes detected. |
|
In addition to the comments ^ benchmarks likely show no impact because we can't really reproduce slow IO even on our S3. I'll think whether we can get a good reproduction where we will see a speedup, otherwise there's still no sense to merge this |
|
This PR is superceded by #9355 |
If we're running Duckdb over slow storage (S3), getting ArrayRef's may block. Before this PR, scan function would block until getting an array. Now we can tell Duckdb we're waiting for IO, and it will suspend the worker thread and reschedule it when we get the array.
This doesn't have any impact if we're running over fast storage like NVME.