Skip to content

Cap auto append-pool size and flush bulk workers in parallel at drain - #17

Open
adubovikov wants to merge 1 commit into
quackscience:mainfrom
adubovikov:fix/pool-cap-parallel-drain
Open

adubovikov wants to merge 1 commit into
quackscience:mainfrom
adubovikov:fix/pool-cap-parallel-drain

Conversation

@adubovikov

Copy link
Copy Markdown
Contributor

Requested by Alex

Fixes #16.

Two ingest regressions on many-core machines since a23ee39; details and bisect are in the issue.

1. Cap the auto append-pool size (regression from #9).

  • PoolThreadCount() auto sizing is again min(hw/2, AUTO_POOL_THREAD_CAP = 4), and it also never exceeds DuckDB's threads setting (TaskScheduler::NumberOfThreads()).
  • PipelineThreadCount() auto sizing also respects threads (it still scales to hw*2/3, up to 16).
  • An explicit rawduck_pool_threads still goes up to MAX_POOL_THREADS.
  • With more than about 4 optimistic writers, a bulk import leaves free blocks that CHECKPOINT never reclaims (the file is 1.5–1.9× the data).

2. Write bulk workers in parallel at drain (regression from #11).

  • In RawAppendPool::Drain, a worker holding at least one full row group (GetRowGroupSize() rows) is written by its own thread again, as before Feat/variant benchmark #11.
  • Smaller workers stay in memory for the single CHECKPOINT pack. That keeps the compact layout Feat/variant benchmark #11 aimed for on small and medium tables: always flushing every worker doubled the size of a 33k-row, 29-column table in my tests.
  • rawduck_overlap_flush keeps its mid-append meaning.
  • flushed is a vector<uint8_t>, not vector<bool>, because worker threads write it concurrently.

Results (22 cores, DuckDB v1.5.6, threads=8, default rawduck_* settings):

table main 78d3cd8 this PR
2M-row SIP-like, INSERT 9.8–10.6 s, 580–760 MB (630–1070 free blocks) 3.8–4.0 s, 401–406 MB (0 free)
same, raw_ingest_file 9.8 s, 615 MB 3.95 s, 406 MB
0.8M rows / 15 cols, INSERT 1.26 s, 35.9 MB 0.68–1.0 s, 18.4–26.5 MB*
160k rows / 53 cols (OTel logs-like) 1.18 s, 14.2 MB 1.1 s, 13.6–16.0 MB*
33k rows / 29 cols (OTel spans-like) 0.40 s, 7.1 MB 0.37–0.43 s, 7.4 MB

* The spread on the medium tables is the pre-existing random free-block behaviour described in the issue. It shows up the same way with only change 1 applied and on a23ee39. Used blocks are unchanged.

  • Table content is identical to main on all tables (count(*) plus per-column sum(hash(col::VARCHAR))).
  • make test_release: All tests passed (663 assertions, 2 skipped: quack, gRPC env).

👹 Fixed by Goblin

Two ingest regressions since a23ee39, measured with a 2M-row SIP INSERT on
a 22-core box (DuckDB v1.5.6):

- f8f20a0 removed AUTO_POOL_THREAD_CAP, so the auto pool grew to
  hardware_concurrency()/2 (11 workers here). Above ~4 optimistic writers
  the import leaves free blocks CHECKPOINT never reclaims: 690-770 MB file
  for 400 MB of data. Restore the cap of 4 for auto sizing and never exceed
  DuckDB's own threads setting (explicit rawduck_pool_threads still goes up
  to MAX_POOL_THREADS). Pipeline threads also respect threads now.
- afb7532 made the drain keep every worker's collection uncompressed until
  commit, which serializes compression: 4.6 s -> 9.8 s. Workers holding at
  least one full row group are written in parallel again; smaller ones
  still stay in memory for the single CHECKPOINT pack, so small/medium
  tables keep the compact layout afb7532 was after.

Result: 3.9 s / 403 MB / 0 free blocks (HEAD: 9.8 s / 690-760 MB),
OTel traces/logs/metrics sizes unchanged, identical table content,
all sqllogictests pass (663 assertions).

👹 Fixed by Goblin

Co-Authored-By: Goblin <goblin@hep-labs.local>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingest regressions on many-core machines: file bloat (#9 pool cap removal) and ~2x slower bulk INSERT (#11 deferred drain flush)

1 participant