perf: optimize buffer selection with pointer hashing and fast-path#772
Open
wicyn wants to merge 1 commit intotaskflow:masterfrom
Open
perf: optimize buffer selection with pointer hashing and fast-path#772wicyn wants to merge 1 commit intotaskflow:masterfrom
wicyn wants to merge 1 commit intotaskflow:masterfrom
Conversation
Refactored the spill logic to improve performance under high contention. Key changes include: 1. Optimized Index Generation: Implemented Fibonacci hashing on node pointers to ensure a more uniform distribution across buffers. 2. Efficient Modulo Calculation: Added a fast-path for power-of-two buffer sizes using bitwise AND, significantly reducing CPU cycles. 3. Lock-Avoidance Fast-Path: Introduced a non-blocking search that probes all buffers with try_lock before falling back to a blocking wait.
Member
|
@wicyn thank you for the pull request. Do you have any measured runtime difference between this pull and the original one? I feel this is significantly more complex, not sure about its practical benefit. Say, do you see any unittest runtime difference? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR optimizes the
_spilland_bulk_spilllogic in theExecutorto reduce contention and improve performance.Key Changes:
size - 1).try_lockon all buffers before falling back to a blocking wait.These changes significantly reduce synchronization overhead when multiple threads are spilling tasks simultaneously.