Skip to content

perf(thrift): bind scalar readers once per Arrow batch - #602

Merged
vuanhphung merged 16 commits into
mainfrom
perf/thrift-cells
Dec 1, 2026
Merged

vuanhphung merged 16 commits into
mainfrom
perf/thrift-cells

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

The Thrift catalog-sales profile spends 54.9% of CPU in ScanRow, including 14.9% in null checks and 2.4% in interval checks. These decisions are invariant within an Arrow record.

Bind concrete scalar reads, validity handling and decimal/interval decisions once per record. Only audited holders read the top-level bitmap directly; the row loop indexes a destination-sized reader slice. Overlap: #597 and #605 (merged) are separate; kernel work is #601.

Behavior changes (in CHANGELOG): a closed scanner returns an explicit error, without an ERROR log, instead of stale values; a destination whose column count differs from the Arrow holders errors instead of filling leading columns or NULL-padding; a column-value setup failure is logged once and stops scanning instead of being ignored.

Live medians, main → PR, eight fresh processes per side, rotated ABBA, warmups discarded:

Thrift scenario User CPU s Sys CPU s Total CPU s Query wall s
Catalog ~500 MB 4.400→3.230 .905→.920 5.290→4.155 6.282→5.577
Catalog, independent review 4.310→3.140 .810→.905 5.190→4.090 5.839→4.930
Boolean CloudFetch 80M 5.655→4.920 .060→.060 5.710→4.980 6.916→6.344
Float CloudFetch 50M 4.025→3.570 .345→.340 4.360→3.910 6.986→6.280
Double CloudFetch 30M 2.550→2.400 .390→.390 2.950→2.805 5.571→5.750

SELECT 1 and LIMIT 10000 are flat. These runs are from the first reviewed head (9e1dc50). The review fixes keep the gain: per-cell micro versus current main is −23% to −52%, and live CPU at a2159a8 matches 9e1dc50 within A/A noise (catalog total 5.365→5.320 s, boolean 6.815→6.755 s). 15 live checksum cases match main, all 12 guard mutants fail, and lint, unit and race checks pass.

Adversarial review: converged after two takeover rounds; no open high findings.

This pull request and its description were written by Isaac.

vuanhphung and others added 4 commits November 27, 2026 06:25
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@vuanhphung vuanhphung changed the title Bind Thrift scalar readers once per Arrow batch perf(thrift): bind scalar readers once per Arrow batch Nov 27, 2026
@vuanhphung
vuanhphung marked this pull request as ready for review November 27, 2026 07:52

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

Keep both Thrift scanner and complex-rendering changelog entries.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
@vuanhphung
vuanhphung marked this pull request as draft November 30, 2026 21:56
vuanhphung and others added 7 commits November 30, 2026 21:59
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Keep the scanner review notes and upstream kernel port changelog entry.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@vuanhphung
vuanhphung marked this pull request as ready for review December 1, 2026 00:29

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Low

Looks good, with one low concern. The per-record reader binding, the bitmap shortcut and the lifecycle handling look correct, and tests cover them well. The one gap is the CHANGELOG: it leaves out one of the user-visible behavior changes.

Comment thread CHANGELOG.md Resolved
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Nit

Looks good — no blocking issues. I checked that the bitmap offset matches arrow-go's IsNull, how UnknownNullCount is handled, that each holder's IsNull follows the same top-level validity, the colInfo/holder sizing, and that the sticky error and closed state are correct; the three behavior changes are in CHANGELOG.

Other findings

  • ⚪ Nit — readers := ars.rowValues.readers[:len(destination)] in ScanRow re-slices to a length the check just above already guarantees. The re-slice can be dropped, or kept with a comment saying it is there only to let the compiler skip bounds checks. (Found by Claude Opus 5.5 · the judge disputed it but couldn't back that up, so it's kept)

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

The re-slice is intentional bounds-check-elimination scaffolding from the accepted performance fix, so I’m keeping it unchanged. Go 1.27.3 SSA diagnostics on ce04b64 confirm no check at the reader access (line 230); the preceding length guard still handles mismatched destinations.


This comment was generated with GitHub MCP.

Resolve the main changes by merging (no force-push).

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Nit

Looks good, no blocking findings. Reader binding matches the old per-cell IsNull/decimal/interval logic. The bitmap offset handling matches arrow-go's IsNull. The three behavior changes are tested and recorded in CHANGELOG.

Other findings

  • ⚪ Nit — In ScanRow, readers := ars.rowValues.readers[:len(destination)] is redundant after the exact-length check above it; indexing ars.rowValues.readers directly (or a plain local alias) would read more clearly. (Found by Claude Opus 5.5 · the judge disputed it but couldn't back that up, so it's kept)

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

@vuanhphung
vuanhphung enabled auto-merge December 1, 2026 06:50
@vuanhphung
vuanhphung added this pull request to the merge queue Dec 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 1, 2026
@vuanhphung
vuanhphung enabled auto-merge December 1, 2026 15:52

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

Verdict: 1 Nit

Looks good, no blocking issues. Every bound reader returns the same NULLs and values as the holder path it replaces. Each audited holder's IsNull reads the same ArrayData as the bitmap shortcut, the holders keep the bitmap buffers alive after sar.Release, and colInfo is the same length as the holders. The behavior changes are listed in CHANGELOG and have tests.

Other findings

  • ⚪ Nit — readers := ars.rowValues.readers[:len(destination)] repeats a length check that already ran on the line above. If the reslice is there to help the compiler drop bounds checks, add a comment saying so; otherwise index ars.rowValues.readers directly. (Found by Claude Opus 5.5 · the judge disputed it but couldn't back that up, so it's kept)

@vuanhphung
vuanhphung added this pull request to the merge queue Dec 1, 2026
Merged via the queue into main with commit eefbf7b Dec 1, 2026
14 checks passed
@vuanhphung
vuanhphung deleted the perf/thrift-cells branch December 1, 2026 16:13
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.

2 participants