Repository navigation
Settle the Chunks schema one index chunk at a time - #1243
Open
quinnj-bot[bot] wants to merge 1 commit into
Open
quinnj-bot[bot] wants to merge 1 commit into
quinnj-bot[bot] wants to merge 1 commit into
Conversation
CSV.Chunks validates every cell of a window before the first batch, to give every batch the same types. It did this one column at a time across the whole window (64 MiB by default): at most one task per column, and each task walked the window's bytes and index once more. A two-column file used two of ten threads, and a wide file streamed the window from memory once per column. Each index chunk now validates all of its selected columns while its bytes are in cache, and the chunks of a window run in parallel. Every chunk starts from the window's incoming types and widens a column only as far as its own cells need; the window's type is the join of the chunks' types. A chunk that settled at nanosecond timestamps is checked again when the window widens to microseconds, as the column walk did by restarting. The settled types, missing flags and text widths are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1243 +/- ##
==========================================
- Coverage 96.05% 95.92% -0.14%
==========================================
Files 9 9
Lines 5885 6553 +668
==========================================
+ Hits 5653 6286 +633
- Misses 232 267 +35 ☔ 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.
Why
CSV.Chunksspent about half of its time before the first batch. To give every batch the same column types, its constructor validates every cell of each window (64 MiB by default). It did that one column at a time across the whole window: one task per column, so a two-column file kept two of ten threads busy, and each task fetched a line of input and a line of index from memory for every row of the window, so wide files reread each window once per column. On a 100,000-row, 500-column file the constructor took twice the CPU of a wholeCSV.Fileread.What changed
settlebatchschema!validates one index chunk (64 KiB to 1 MiB) at a time: each task takes a chunk and checks all of its selected columns while those bytes are in cache, and the chunks of a window run in parallel. Every chunk starts from the window's incoming types and widens a column only as far as its own cells need. Widening keeps every value a narrower type accepted, so the window's type is the join of the chunks' types (promote_kernel) in any order. Microsecond timestamps are the one exception: they cannot hold every nanosecond value, so a chunk that settled at nanoseconds is checked again under microseconds when its window widens. The column walk got the same result by restarting the window. Missing flags are OR-ed and text widths take the maximum, as before. The batches themselves are unchanged.Verification
for f in CSV.Chunks(path), new/main, median of 5 interleaved fresh-process rounds (Apple M3 Max, Julia 1.12.6, load average 8 to 14). Ten threads (the default here): wall time and whole-process cycles. One task (ntasks=1): calling-thread cycles and instructions, the per-cell work.An earlier run of all 13 files at ten threads under heavier load (13 to 25) put every file at 0.63× to 0.93× of main's wall time except quoted text and the 80%-empty file, whose rounds swung from 0.6× to 1.6×; the rerun above, at lower load, puts them at 0.91× and 0.69×. One task does the same work as before (instructions within 1%, apart from 6% fewer on long text), and the wide files run in 0.65× to 0.68× of the cycles because each chunk stays in cache.
CSV.Chunksbatch (types, values, problems) on 13 generated files (1M to 10M rows: integers, floats, Bool, dates, date-times, short and long text, quoted text with embedded delimiters and newlines, missing-heavy, 2, 50 and 500 columns) are identical to main (checked on the merge of the five read PRs from this sweep: 221 fingerprints, zero differences).ntasks1 and 4, plus atypes=request. Batches are identical to main in all 420 reads.ntasks1 and 4: the batch's types and values equalCSV.File's. It passes on main too. With the nanosecond re-check removed, it fails: the column settles at microseconds and the nanosecond cell silently becomesmissing.promote_kernel's ladder (Int64, Int128, Float64, String; nanosecond then microsecond timestamps, String otherwise) gives, apart from the microsecond case handled above. Requested types never widen; their chunks only report missing cells. Tasks write disjoint(column, chunk)cells of three result matrices, aMatrix{Bool}among them (one byte per cell, no shared words). Chunk order never matters to the fold.--check-bounds=yes -t4) on the merge of this PR with the four other read PRs from this sweep: Julia 1.12.6, 333,323 of 333,323 pass; Julia 1.10.11, 332,877 of 332,877. CI green on every test job.@inline. Codecov counts 6,524 coverable lines on Inline value parsing for Bool, date-time and time columns #1241 against 5,885 on the base b9d8f5e, and an earlier PR on the same base counted 5,894, so the drop comes from how coverage is collected today, not from these diffs. codecov/patch passes (100%).🤖 Generated with Claude Code