eldenmoon opened a new pull request, #71103: URL: https://github.com/apache/doris/pull/71103
### Background The VARIANT V2 shredder selects paths to store as independent columns. Each path's writer encodes data pages and builds the indexes for that column. The segment writer packages the resulting inverted indexes in the segment's index file. ### What problem does this PR solve? Issue Number: None Related PR: None PR Type: Performance Problem Summary: On a 5,000-path table with 50 present keys per row, a three-way Stream Load used a median 7.00 GiB of additional BE heap. The V2 writer kept every path's dictionary buffer, page buffers, and index builders until all paths had been appended. Completing and releasing each path's writer before allocating the next reduced that median to 0.35 GiB in the 4.1 Release comparison. ### Details - **Why it was slow:** The peak included thousands of page and inverted-index builders across simultaneous flushes. Each dictionary made its initial reservation as soon as the path writer was constructed, regardless of the number of values actually present in that segment. - **Optimization:** Finish and write each materialized path's data and indexes within the path loop. Preserve the data-byte totals and account for inline index ranges. The existing segment index writer still packages the child inverted-index output. - **Results:** Same 4.1 base revision, 192 logical CPU dev host, Release build, 896 JSON rows per load, 5,000 physical paths and 1% presence. Three simultaneous loads, eight timed and eight separately sampled runs per arm in reversed order. Median wall time fell from 1.206 to 0.966 seconds. Median sampled jemalloc peak fell from 8.19 to 1.57 GiB and RSS peak fell from 4.65 to 2.85 GiB. Optimized V1 in the same harness took 1.027 seconds with a 1.50 GiB heap peak and 2.66 GiB RSS peak. - **Applicability and cost:** Applies to full V2 writes with materialized paths. Inline indexes are interleaved with column data. The index-only preload path joins ranges that already share a cache block. Sealed inverted-index output stays alive until the common pack step. A 24-column dense control had 310 versus 320 ms wall-clock medians. The paired result changed direction when the order was reversed. ### Testing - Release Stream Load checked all 5,000 physical paths and exact row IDs from index-only MATCH_ANY. - An overflow fixture checked every row's value, nulls, one dictionary and three plain data pages, and two logical inverted indexes in one packed file. The original 4.1 V2 build reopened a segment written by the candidate. - The final master Release artifact passed the wide and overflow checks. Of 44 V2 regression suites, 42 passed, including SNII. Two suites stopped before their first fixture load because the external object service returned HTTP 403. - 95 scoped master ASAN tests passed, including the checks for abort cleanup, preload ranges, and VARIANT V2 compatibility. Format, build hygiene, and changed-line clang-tidy checks passed. ### Release note Reduces BE memory during loads of wide VARIANT V2 tables. ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Partially verified due to two local regression fixtures returning HTTP 403. ### AI Disclosure - Tool: OpenAI Codex (GPT-6) - Generated: C++ changes, tests, benchmark harness, and description. - Human review: No author review recorded at submission time. -- 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]
