Dandandan opened a new pull request, #21676:
URL: https://github.com/apache/datafusion/pull/21676

   ## Which issue does this PR close?
   
   <!--
   Related to improving CPU utilization in parallel query execution (e.g. 
ClickBench).
   -->
   
   ## Rationale for this change
   
   `SharedMemoryReservation` was defined as `Arc<Mutex<MemoryReservation>>`, 
but `MemoryReservation` is already internally thread-safe:
   - Its `size` field uses `AtomicUsize` with atomic 
`fetch_update`/`fetch_add`/`fetch_sub`
   - The underlying `MemoryPool` implementations (`GreedyMemoryPool`, 
`FairSpillPool`, `UnboundedMemoryPool`) all handle their own internal 
locking/atomics
   
   The outer `Mutex` was therefore redundant and caused unnecessary lock 
contention. In the repartition operator specifically, this lock was acquired 
**on every batch** by every input partition (sender) plus the output partition 
(receiver), making it a serialization bottleneck that reduced CPU utilization 
during parallel query execution.
   
   ## What changes are included in this PR?
   
   - Changed `SharedMemoryReservation` type alias from 
`Arc<Mutex<MemoryReservation>>` to `Arc<MemoryReservation>`
   - Removed `.lock()` calls at all usage sites (repartition operator and 
symmetric hash join)
   - Removed unused `parking_lot::Mutex` imports
   
   ## Are these changes tested?
   
   Covered by existing tests — no behavioral change, only removal of redundant 
synchronization. All existing repartition and symmetric hash join tests 
continue to pass.
   
   ## Are there any user-facing changes?
   
   No. `SharedMemoryReservation` is `pub(crate)`.
   
   🤖 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]

Reply via email to