airborne12 opened a new pull request, #69794:
URL: https://github.com/apache/doris/pull/69794
### What problem does this PR solve?
Issue Number: None
Related PR: #69728
Problem Summary: Backport #69728 to `branch-4.2`.
`SniiBkdIndexColumnWriter`, the numeric, date and IP index writer, installed
no memory reporter. Its point buffer, and its NULL docid vector, which grows
with the row count, were invisible to the process-wide SNII build tracker (the
`SniiIndexBuild` MemTracker and the `snii_index_build_mem_consumption` gauge)
that the text writer feeds.
The writer now creates a reporter in the unregistered population, since a
forced spill cannot reclaim a BKD build, and hands it to the BkdBuilder. It
charges the NULL docids through `reserve_docids_for_append`, a growth routine
added next to `MemoryReporter`: the larger capacity is charged before it is
allocated, and the old charge is returned after the move. It gives the vector
and its charge back as soon as `finish()` has moved the docids into the bitmap,
because IndexBuilder keeps finished writers alive until the whole rowset is
closed.
This only adds accounting. The reporter has no cap, so it cannot fail a
build, and its callback charges a plain MemTracker, not a limiter.
#### Branch adaptations
`branch-4.2` has the same BKD writer and the same `MemoryReporter`, so the
writer, header and test changes carry over. The `init()` hunk of
`snii_bkd_index_writer.cpp` needed a manual merge because `_add_value` takes a
`const void*` on this branch, and in the new test `add_values` takes the column
name as its first argument.
The text writer is not part of this backport. On `branch-4.2` it accounts
its NULL docids with `_report_null_docids_capacity()`, not with the
`Reservation`-based routine that master's text writer had when #69728 extracted
`reserve_docids_for_append`. So here the helper is added next to
`MemoryReporter` and only the BKD writer calls it, and `snii_index_writer.cpp`
is unchanged. The commit is based on master `24dc7762f1`.
### Release note
The SNII index build memory metric now also counts the point buffers and
NULL rows of numeric, date and IP indexes.
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [x] Unit Test
- The test of #69728:
SniiBkdAdapterTest.BuildMemoryIsChargedAndGivenBackAtFinish.
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason
- Behavior changed:
- [x] No. The bytes are only reported to the build tracker, and are
returned at finish.
- [ ] Yes.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### Validation
- `memory_reporter.h` and `snii_bkd_index_writer.h` take master's change
unchanged, `snii_bkd_index_writer.cpp` and the test were merged as described
above, and the text-writer hunk of `snii_index_writer.cpp` is dropped.
- clang-format 16 on the four changed files.
- A local ASAN run of the BE unit tests on this branch is pending and will
be added here. The PR's CI runs the same tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]