Duckdb Parallelism
Duckdb Parallelism
Parallel Quacking
Parallel Quacking
SELECT …
FROM S
JOIN R USING (A) 3: Probe HTs and output result
JOIN T USING (B); (depends on 1 and 2)
1: HT Build “T”
2: HT Build “S”
Morsel-Driven Parallelism
SELECT …
FROM S
JOIN R USING (A)
JOIN T USING (B);
HT Build “T”
HT Build “S”
▸ Sink Interface
▸ Sink has two states
▸ Global state: single state per sink
▸ Local state: single state per thread
▸ Actual content depends on the operator
Parallelism in DuckDB
▸ Sink Interface
▸ Sink takes as input the two states + a DataChunk
▸ Called repeatedly until the source data is exhausted
Parallelism in DuckDB
▸ Sink Interface
▸ Combine is called after source of a single thread is
exhausted
▸ Sink Interface
▸ Finalize is called after all tasks related to the sink
are completed
Parallelism in DuckDB
▸ Splitting up scans
▸ Splitting up scans is generally not very difficult
▸ But we have multiple types of scans
▸ Base table, parquet, CSV, aggregate HT, etc…
▸ How to split up depends on scan type
Parallelism in DuckDB
▸ Implementation is optional
▸ No implementation -> scan will not be parallelized
Parallelism in DuckDB
* This image is taken from HyPer which builds on the LHS - we build on the RHS.
Is there a standard? Should we switch this? Is it even important?
Parallelism in DuckDB
SELECT …
FROM S
JOIN R USING (A)
Another hash join: create another
JOIN T USING (B); build pipeline and dependency
Parallelism in DuckDB
TPC-H Q1
P1 (depends on P2)
Scans the aggregate HT!
P2
▸ Notes on parallelism
▸ The final pipeline (i.e. the one that outputs
results) is not parallelized
▸ Future work!
Parallelism in DuckDB
▸ NUMA Awareness
▸ TODO :)
Preliminary Results
▸ Results
▸ Before we implemented splitting of scans we were
curious
▸ Preliminary results
Preliminary Results
▸ Preliminary results
Preliminary Results
▸ Q1
Parallel Sequential
Preliminary Results
▸ Q18 Sequential
Preliminary Results
▸ Q18 Parallel
Future Work
▸ Future Work
▸ Rework aggregate hash table
▸ More profiling of contention (specifically in scans)
▸ Parallel window functions, ORDER BY, Top N…
▸ Parallel Parquet/CSV/Pandas scans
▸ Expand profiler to better display parallelism/
pipelines