Repository navigation
Conversation
When one chunk promoted a column while another was still parsing it under
an older type, the second chunk joined its detected type with the
column's current type. With a typemap target outside the promotion order
(Int64 => Int32, or the documented Timestamp{Nanosecond} => DateTime)
that join is String, so a sparse column read Int32 serially and text in
most parallel reads (29 of 40 at 2 threads, 28 of 40 at 4). The conflict
was found under the old type and says nothing against the current one,
so the chunk now re-parses under the current type. Both drivers route
through _promotemapped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
directchunk! took the shared promotion lock once per column per chunk to read that column's type and final vector. A 1,000-column file in 118 chunks took it 118,000 times per read, and the waiting showed up in 8-task profiles. Each chunk now copies every column's type and final once, under one lock. A column that another chunk promotes after the copy parses under its old type and is re-parsed after the wave, which is what already happens when the promotion lands while the chunk is parsing that column. wide_numeric.csv (124 MB, 18k rows x 1,000 columns), 8 tasks, interleaved: 0.078-0.083 -> 0.061-0.062 s wall, total CPU 0.48-0.54 -> 0.38-0.39 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj
force-pushed
the
claude/one-lock-per-chunk
branch
from
October 22, 2026 11:28
46afcc0 to
44886f5
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1221 +/- ##
=======================================
Coverage 95.79% 95.79%
=======================================
Files 9 9
Lines 5566 5570 +4
=======================================
+ Hits 5332 5336 +4
Misses 234 234 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Builds on #1222; merge that first. This branch contains #1222's commit: the copy below widens the window in which a chunk parses under a stale type, and without #1222 a
typemaptarget outside the promotion order then turns a sparse column into text on every parallel read (an independent review measured 40 of 40 runs; main already does it in about 30 of 40).directchunk!took the shared promotion lock once per column per chunk to read that column's current type and final vector. A 1,000-column file in 118 chunks took it 118,000 times per read, and that wait showed up in 8-task profiles. Each chunk now copies every column's type and final once, under one lock.Why a stale copy is safe: if another chunk promotes a column after the copy, this chunk parses that column under the old type into the old final, records the old type in
segtypes, anddirectwave!re-parses it into the promoted final after the wave (redirect!; a chunk that parsed asMissingonly refills its slice). That is the existing path for a promotion that lands while a chunk is parsing the column; the copy widens the window in which it can happen, which can only add re-parses, and only when a promotion races with the copy. A chunk's own promotions still read the current type under the lock. The cost: a chunk whose copy predates a promotion parses that column under the old type before the re-parse and keeps the replaced final vector alive until the chunk finishes; both happen only when a promotion lands during the wave, which sampling makes rare.Interleaved process pairs, Julia 1.12.6, M3 Max (load average about 8):
Review: my own pass, then an independent agent review (stale detection, the free Missing upgrade, String finals and adopted slots,
limit, Timestamp widening; 144 parallel runs matching serial), which found thetypemapinteraction now fixed by #1222.segtypes[k][j]with the frozen final type, so any chunk that parsed under an old type is re-parsed; String finals adopt each chunk's bytes into the chunk's own slot after the wave; Timestamp nanosecond-to-microsecond widening reads onlysegtypesand the source spans.promoorfinals.Verification:
promotions that land while another chunk parses:nsample=1seeds every column from the first row, so all 40 columns promote across 948 chunks; four parallel reads must equal the serial read in values, types, and problems, with and without atypemap. It guards the re-parse path this change leans on (the speedup itself is measured above, not tested).--check-bounds=yes -t4: 331,812 passed (head, including Re-parse a stale chunk under the column's current type #1222).🤖 Generated with Claude Code