Skip to content

perf: elide result null bitmap allocation for is-not-null scans - #788

Open
lizhen-0710 wants to merge 1 commit into
bytedance:mainfrom
lizhen-0710:fix-isnotnull-null-buffer-elision-oss
Open

perf: elide result null bitmap allocation for is-not-null scans#788
lizhen-0710 wants to merge 1 commit into
bytedance:mainfrom
lizhen-0710:fix-isnotnull-null-buffer-elision-oss

Conversation

@lizhen-0710

@lizhen-0710 lizhen-0710 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

When a scan predicate is IS NOT NULL and the raw value is kept as the output type, selected output rows cannot contain nulls. The previous path could still prepare an internal result null bitmap whenever the input range had nulls. That bitmap was initialized and maintained by the reader, but was not attached to the final output vector.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🚀 Performance improvement (optimization)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🔨 Refactoring (no logic changes)
  • 🔧 Build/CI or Infrastructure changes
  • 📝 Documentation only

Description

Teach SelectiveColumnReader to prepare output nulls through a guarded helper that skips result null bitmap allocation only for raw projected or extracted primitive, string, and binary outputs proven non-null by IS NOT NULL. Use the same helper from Parquet page reads so cross-page reads get the same behavior, and clear stale null state when output nulls are elided.

Add common allocation tests and Parquet E2E coverage for compacted output, page and row-group paths, result reuse, scalar types, complex negative cases, filter-only columns, and mixed nullable outputs.

Performance Impact

  • No Impact: This change does not affect the critical path (e.g., build system, doc, error handling).

  • Positive Impact: I have run benchmarks.

    Click to view Benchmark Results
    Paste your google-benchmark or TPC-H results here.
    Before: 10.5s
    After:   8.2s  (+20%)
    
  • Negative Impact: Explained below (e.g., trade-off for correctness).

Release Note

Please describe the changes in this PR

Release Note:

Release Note:
- Fixed a crash in `substr` when input is null.
- optimized `group by` performance by 20%.

Checklist (For Author)

  • I have added/updated unit tests (ctest).
  • I have verified the code with local build (Release/Debug).
  • I have run clang-format / linters.
  • (Optional) I have run Sanitizers (ASAN/TSAN) locally for complex C++ changes.
  • No need to test or manual test.

Breaking Changes

  • No

  • Yes (Description: ...)

    Click to view Breaking Changes
    Breaking Changes:
    - Description of the breaking change.
    - Possible solutions or workarounds.
    - Any other relevant information.
    

When a scan predicate is IS NOT NULL and the raw value is kept as the output type, the selected output cannot contain nulls. The previous path still prepared a result null bitmap for nullable input data, adding allocation pressure even though the bitmap was not needed by the final output.

Teach SelectiveColumnReader to prepare output nulls through a guarded helper that skips result null bitmap allocation only for raw projected or extracted primitive, string, and binary outputs proven non-null by IS NOT NULL. Use the same helper from Parquet page reads so cross-page reads get the same behavior, and clear stale null state when output nulls are elided.

Add common allocation tests and Parquet E2E coverage for compacted output, page and row-group paths, result reuse, scalar types, complex negative cases, filter-only columns, and mixed nullable outputs.
@lizhen-0710 lizhen-0710 changed the title perf: elide null buffers for is not-null scan outputs perf: elide result null bitmap allocation for is-not-null scans Jul 27, 2026
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.

1 participant