csun5285 opened a new pull request, #62544:
URL: https://github.com/apache/doris/pull/62544

   
   ## Problem
   
   When writing nullable columns, `append_nullable` splits each block at null 
boundaries into small non-null runs.
   
   | Input block                          | add_values calls                    
                      |
   
|--------------------------------------|-----------------------------------------------------------|
   | `[1, 3, NULL, NULL, 4, 5, 6, NULL]` | `add_values([1,3], count=2)` + 
`add_values([4,5,6], count=3)` |
   
   Each `add_values` call built two heap-allocated `Field` temporaries just to 
compare
   min/max — allocation, memcpy, variant dispatch, destructor — per call.
   
   ## Fix
   
   Track page min/max as raw `ValType` (the same native type 
`std::minmax_element` already uses). Materialize `Field` only once at `flush()` 
time.
   
   ## Benchmark (Release, 65536 rows/iter)
   
   `block_rows` = post-null-split run length.
   
   | Type | block | Baseline (M items/s) | Optimized (M items/s) | Speedup |
   |---|---:|---:|---:|---:|
   | Int32 | 1 | 21.9 | 240.3 | **11.0×** |
   | Int32 | 4 | 75.9 | 353.0 | **4.7×** |
   | Int32 | 16 | 170.0 | 400.1 | **2.4×** |
   | Int32 | 64 | 261.9 | 394.4 | **1.5×** |
   | Int32 | 256 | 314.0 | 419.7 | 1.3× |
   | Int32 | 1024 | 320.6 | 425.9 | 1.3× |
   | Int32 | 4096 | 334.2 | 359.3 | 1.1× |
   | Double | 1 | 16.7 | 181.9 | **10.9×** |
   | Double | 4 | 47.0 | 168.0 | **3.6×** |
   | Double | 16 | 120.0 | 310.0 | **2.6×** |
   | Double | 64 | 223.1 | 425.3 | **1.9×** |
   | Double | 256 | 315.1 | 469.8 | 1.5× |
   | Double | 1024 | 358.9 | 477.1 | 1.3× |
   | Double | 4096 | 373.8 | 483.3 | 1.3× |
   | String | 1 | 8.0 | 59.2 | **7.4×** |
   | String | 4 | 21.7 | 57.9 | **2.7×** |
   | String | 16 | 41.3 | 60.7 | **1.5×** |
   | String | 64 | 62.9 | 80.6 | 1.3× |
   | String | 256 | 75.2 | 82.0 | 1.1× |
   | String | 1024 | 79.4 | 84.0 | 1.1× |
   | String | 4096 | 80.4 | 83.4 | 1.0× |
   
   Small batches (1–16): **2×–11×**. Large batches: no regression.
   
   
   When the columns in the variant are sparse, during compaction, the frequent 
add calls on the zonemap index cause field creation and field comparison to 
account for around 12% of CPU usage. After optimization, this drops to 3%.
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] 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 <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   


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