2010YOUY01 opened a new pull request, #27746:
URL: https://github.com/apache/datafusion/pull/27746

   > [!IMPORTANT]
   >
   > **Fork CI setup:** For pull requests from a fork to `main`, enable 
workflows in your fork's **Actions** tab before you push.
   > See the [fork CI setup 
guide](https://datafusion.apache.org/contributor-guide/#pull-requests-from-forks).
   
   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes https://github.com/apache/datafusion/issues/27398
   
   ## Rationale for this change
   
   ### Background and dependencies
   
   - Step 2 of the optimization plan in #27398, following #27399. It is also a 
prerequisite for the existence-join refactor in #26361 (which can reuse the 
same index design).
   - It would be great to complete the HJ refactor soon to minimize disruption 
to ongoing development. Some remaining polish in this PR, explained below, may 
be better handled in follow-up PRs.
   
   ### This PR
   
   Despite the large diff, you only need to understand two things to understand 
this PR:
   
   - The three-layer architecture of HJ: execution state machine, batched join 
processor, and join index.
   - The storage design: contiguous duplicate matches, referenced by compact 
handles and expanded in bounded chunks.
   
   Both are explained in #27398.
   
   #### Benchmark Result
   Comparing `hj` benchmark with main:
   
   <details>
   <summary>Full benchmark results</summary>
   
   ```
   
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
   ┃ Query                                                                      
   ┃      main ┃ contiguous-hash-table ┃        Change ┃
   
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
   │ QQuery 1_density=1_prob_hit=1_25*1.5M                                      
   │   1.19 ms │               1.13 ms │     no change │
   │ QQuery 2_density=0.026_prob_hit=1_25*1.5M                                  
   │   3.60 ms │               4.75 ms │  1.32x slower │
   │ QQuery 3_density=1_prob_hit=1_100K*60M                                     
   │  56.87 ms │              54.17 ms │     no change │
   │ QQuery 4_density=1_prob_hit=0.1_100K*60M                                   
   │ 169.45 ms │             157.14 ms │ +1.08x faster │
   │ QQuery 5_density=0.75_prob_hit=1_100K*60M                                  
   │ 615.03 ms │             171.41 ms │ +3.59x faster │
   │ QQuery 6_density=0.75_prob_hit=0.1_100K*60M                                
   │ 216.87 ms │             199.69 ms │ +1.09x faster │
   │ QQuery 7_density=0.5_prob_hit=1_100K*60M                                   
   │ 576.10 ms │             163.39 ms │ +3.53x faster │
   │ QQuery 8_density=0.5_prob_hit=0.1_100K*60M                                 
   │ 205.13 ms │             196.10 ms │     no change │
   │ QQuery 9_density=0.2_prob_hit=1_100K*60M                                   
   │ 577.21 ms │             171.05 ms │ +3.37x faster │
   │ QQuery 10_density=0.2_prob_hit=0.1_100K*60M                                
   │ 207.57 ms │             206.25 ms │     no change │
   │ QQuery 11_density=0.1_prob_hit=1_100K*60M                                  
   │ 585.61 ms │             175.90 ms │ +3.33x faster │
   │ QQuery 12_density=0.1_prob_hit=0.1_100K*60M                                
   │ 207.61 ms │             210.07 ms │     no change │
   │ QQuery 13_density=0.01_prob_hit=1_100K*60M                                 
   │ 609.96 ms │             181.81 ms │ +3.35x faster │
   │ QQuery 14_density=0.01_prob_hit=0.1_100K*60M                               
   │ 219.20 ms │             216.94 ms │     no change │
   │ QQuery 15_density=0.2_prob_hit=0.1_100K_(20%_dups)*60M                     
   │ 190.67 ms │             172.71 ms │ +1.10x faster │
   │ QQuery 16_density=1_prob_hit=1_25*1.5M_RightSemi                           
   │   1.30 ms │               1.42 ms │  1.09x slower │
   │ QQuery 17_density=1_prob_hit=1_100K*60M_RightSemi                          
   │  59.53 ms │              58.72 ms │     no change │
   │ QQuery 18_density=1_prob_hit=0.1_100K*60M_RightSemi                        
   │  71.43 ms │              75.05 ms │  1.05x slower │
   │ QQuery 19_density=1_prob_hit=1_25*1.5M_RightAnti                           
   │   1.11 ms │               1.12 ms │     no change │
   │ QQuery 20_density=1_prob_hit=1_100K*60M_RightAnti                          
   │  52.77 ms │              54.45 ms │     no change │
   │ QQuery 21_density=1_prob_hit=0.1_100K*60M_RightAnti                        
   │  77.85 ms │              77.53 ms │     no change │
   │ QQuery 22_density=1_prob_hit=0.01_100K_(fanout_100)*60M_RightSemi          
   │  80.52 ms │              77.66 ms │     no change │
   │ QQuery 23_density=1_prob_hit=1_32K_(fanout~78)*2.3M_long_keys_count        
   │  90.49 ms │              26.37 ms │ +3.43x faster │
   │ QQuery 24_density=1_prob_hit=1_3K_(single_hot_bucket)*20K_long_keys_count  
   │ 276.68 ms │              35.65 ms │ +7.76x faster │
   │ QQuery 
25_density=1_prob_hit=1_20K_(fanout~78_multi_key)*240K_multi_key_count │ 113.04 
ms │              24.99 ms │ +4.52x faster │
   │ QQuery 26_density=1_prob_hit=0.027_270K_dense_keys*15M                     
   │  43.45 ms │              44.15 ms │     no change │
   │ QQuery 27_density=0.027_prob_hit=0.027_270K_sparse_keys*15M                
   │  51.51 ms │              45.08 ms │ +1.14x faster │
   │ QQuery 28_density=0.01_prob_hit=0.2_6M_(1.5M_one_key)*100K_count           
   │ 512.27 ms │              87.67 ms │ +5.84x faster │
   
└───────────────────────────────────────────────────────────────────────────────┴───────────┴───────────────────────┴───────────────┘
   ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
   ┃ Benchmark Summary                    ┃           ┃
   ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
   │ Total Time (main)                    │ 5874.02ms │
   │ Total Time (contiguous-hash-table)   │ 2892.38ms │
   │ Average Time (main)                  │  209.79ms │
   │ Average Time (contiguous-hash-table) │  103.30ms │
   │ Queries Faster                       │        13 │
   │ Queries Slower                       │         3 │
   │ Queries with No Change               │        12 │
   │ Queries with Failure                 │         0 │
   └──────────────────────────────────────┴───────────┘
   
   ```
   
   </details>
   
   ## What changes are included in this PR?
   
   Suggested reading order:
   
   1. `hash_join/mod.rs` — comments explain the three-layer hash join 
architecture.
   2. `join_index.rs` — `JoinIndexMap`: this PR introduces a new layer for the 
physical hash table implementation (all changes are inside 
`BatchedJoinProcessor`, without changing the state machine).
   3. `join_index/directory.rs` — `JoinHashIndex`: join hash table 
implementation.
   4. `batched_join_processor.rs` — `BatchedJoinProcessor`: interaction between 
the raw hash index and the join processor.
   5. `directory/dense.rs` — `DenseIntegerDirectory`: specialization 1.
   6. `directory/integer.rs` — `IntegerDirectory`: specialization 2.
   
   ## What is the testing strategy for this PR?
   
   - Existing tests
   - Added coverage in `join_exact_index.slt` (TODO for myself: check for 
overlap with existing tests.)
   
   ## Are there any user-facing changes?
   
   No SQL behavior changes.
   
   


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