Repository navigation
Skip CustomSeparated fields without the generic escaping-rule dispatcher - #131462
Conversation
…tcher Reading a few columns from a wide `CustomSeparatedWithNames` file spends most of its time skipping fields. Each skipped field went through `skipFieldDelimiter` -> `assertString` -> `checkString` and `skipField` -> `skipFieldByEscapingRule` -> `readEscapedStringIntoImpl`. `skipFieldByEscapingRule` is a small out-of-line switch that tail-calls the reader, so with `-mbranch-protection=pac-ret` every field adds a serial `autiasp` -> `paciasp` dependency on `x30`. On Neoverse V2 this made `formats_columns_sampling` and `count_from_formats` on `CustomSeparated` 20-25% slower in #119685, while `TabSeparatedWithNames`, whose `skipField` calls the reader directly, changed by 1%. Read `Escaped` and `Raw` fields directly, as `TabSeparatedFormatReader::skipField` does, and check a one-character field delimiter with the inline `assertChar`. Other escaping rules and multi-character delimiters keep the previous path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [b805429] Summary: ✅
AI ReviewSummaryThis PR bypasses the generic escaping-rule dispatcher for skipped Findings
Tests
Final VerdictStatus: |
| /// Skipping is the main cost of reading a few columns from a wide file, so the `Escaped` and `Raw` | ||
| /// rules read the field directly, as `TabSeparatedFormatReader::skipField` does, instead of going | ||
| /// through the generic `skipFieldByEscapingRule` for every field. | ||
| NullOutput out; |
There was a problem hiding this comment.
[Major] Measure the net benefit of the new per-field path
The supplied cycle counts compare #119685 with its base; they establish the motivating regression, but do not measure this patch. The description explicitly says its local A/B result was unusable, and this head's performance comparisons are still pending.
That distinction matters here: skipFieldByEscapingRule deliberately uses a shared NullOutput to avoid -fstack-protector-strong instrumentation (see src/Formats/EscapingRuleUtils.cpp:70-78), whereas this replacement passes a stack-local object's address to the out-of-line readers. Removing the dispatcher can therefore trade against additional per-field overhead; the speedup needs verification.
Please attach a matched ARM release base/head comparison using formats_columns_sampling and count_from_formats, with identical compiler flags, and address any overhead from the local NullOutput that the measurements reveal. The existing performance jobs can supply the evidence once completed.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 8 s compile time in total, 7 of them have a recent master baseline. |
Reading a few columns from a wide
CustomSeparatedfile spends most of its time skipping the other fields. For each skipped field the reader went throughskipFieldDelimiter->assertString->checkStringandskipField->skipFieldByEscapingRule->readEscapedStringIntoImpl.skipFieldByEscapingRuleis a small out-of-line switch that tail-calls the reader. With-mbranch-protection=pac-ret(#119685), every field then adds a serialautiasp->paciaspdependency on the return address. In the PR binary,autiaspand the branch after it take 65% of the samples ofskipFieldByEscapingRule.Measured on Neoverse V2 with the CI
arm_releasebinaries of #119685 (f0318667) and itsmasterbase (485f00de), single-threaded, 100k rows ofhits(105 columns), user cycles:SELECT WatchIDfromCustomSeparatedWithNamesSELECT WatchIDfromTabSeparatedWithNamesThis matches the
formats_columns_sampling #1andcount_from_formatsCustomSeparatedslowdowns (+22-26%) flagged on every head of #119685.TabSeparatedFormatReader::skipFieldcallsreadEscapedStringIntodirectly and checks its delimiter withassertChar, so it barely changes.This PR does the same for
CustomSeparated: theEscapedandRawrules read the skipped field directly, and a one-character field delimiter is checked inline withassertChar. Other escaping rules and multi-character delimiters keep the previous path, so behaviour does not change. The new test05632_custom_separated_skip_fieldscovers skipping columns and rows for every escaping rule, with one- and multi-character delimiters. Its reference was produced by the currentmasterbinary.I could not get a clean local A/B timing of the change: the shared build I relinked against was being rebuilt by another job, so the relinked binaries had inconsistent archives. The ARM performance comparison of this PR measures the effect without
pac-ret, and #119685 measures it withpac-retafter this is merged.Related: #119685
Related: #130965
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Faster reading of a subset of columns from
CustomSeparatedformats with theEscapedorRawescaping rule.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131462]
Version info
26.11.1.2280-master(included in26.11and later)