Bound DuckDB workers for pair matching - #143
Draft
afermg wants to merge 2 commits into
Draft
Conversation
afermg
marked this pull request as draft
September 2, 2026 17:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
matching.find_pairscurrently lets DuckDB size its worker pool from every visible CPU. On large shared hosts this can oversubscribe a small metadata self-join: the benchmark host exposes 384 logical CPUs.For pandas-backed queries, this PR:
COPAIRS_DUCKDB_THREADSpositive-integer overrideDuckDB relation inputs retain their origin connection without pandas materialization or configuration changes. The primary multilabel query remains outside this PR because #137 owns that implementation seam.
Real-workload benchmark
JUMP-lite
group_low: 19,521 profiles, 37,143 positive pairs, and 515,309 negative pairs. Three fresh processes per implementation, five iterations per query; table entries are medians of process-level warm medians.A separate 1/4/8/16/32-thread sweep produced combined medians of 0.0769/0.0655/0.0609/0.0681/0.0781 seconds, respectively, supporting 8 as the bounded default on this workload.
Pair counts and normalized pair sets were identical. Row order is intentionally not asserted: the SQL query has no
ORDER BY, so neither the existing nor candidate implementation defines a row-order contract.Absolute timings on this shared host are noisy, but the bounded default was consistently faster for
group_low.Validation
git diff --checkpassed