github-actions[bot] commented on code in PR #70883:
URL: https://github.com/apache/doris/pull/70883#discussion_r4665729271


##########
be/src/storage/index/inverted/snii/reader/logical_index_reader.cpp:
##########
@@ -605,6 +635,37 @@ Status 
LogicalIndexReader::open_norms(format::NormsPodReader* out) const {
     return status;
 }
 
+Status LogicalIndexReader::read_dense_norms(std::vector<uint8_t>* bytes,
+                                            format::NormsPodReader* out) const 
{
+    const RegionRef& norms = section_refs().norms;
+    const auto read_len = static_cast<size_t>(norms.length);
+    RETURN_IF_ERROR(reader_->read_at(norms.offset, read_len, bytes));
+    if (bytes->size() != read_len) {
+        return Status::Error<ErrorCode::INVERTED_INDEX_FILE_CORRUPTED, false>(
+                "logical_index: short norms read");
+    }
+    return format::NormsPodReader::open(Slice(*bytes), out);
+}
+
+Status LogicalIndexReader::read_sparse_norms(std::vector<uint8_t>* dense,
+                                             format::NormsPodReader* out) 
const {
+    const RegionRef& norms = section_refs().sparse_norms;
+    const auto read_len = static_cast<size_t>(norms.length);
+    std::vector<uint8_t> section;
+    RETURN_IF_ERROR(reader_->read_at(norms.offset, read_len, &section));

Review Comment:
   [P2] Account for sparse decode scratch in the query memory tracker
   
   On the first scoring load of a sparse index, this ordinary vector holds the 
entire sparse section while open_sparse allocates the expanded dense vector; 
open_null_bitmap also creates frame/CRoaring scratch with an empty reservation 
callback. The searcher cache charges only doc_count plus fixed state, and this 
head's jemalloc wrappers do not charge ordinary STL allocations to a task 
tracker. For a valid 1,000,000-row index with five NULLs and varying norms, the 
writer selects a 1,000,010-byte sparse section, so almost another megabyte 
remains unaccounted alongside the charged million-byte dense vector. Larger 
segments and concurrent first loads multiply that untracked peak and bypass 
query memory limits. Please track/reserve the sparse section and NULL decode 
scratch with task-scoped RAII, keeping their lifetime and charge separate from 
the retained dense cache bytes.



-- 
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]

Reply via email to