Revised PR for #69: Use thread pool for replies#72
Merged
Alogani merged 2 commits intoAlogani:develfrom Jan 31, 2026
Merged
Conversation
Owner
|
Nice ! Thanks |
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.
This fixes #69 by removing unnecessary commits related to other PRs. I also removed the reply thread pool's size calculations and simply set the pool's size to be equal to
num_threads.There is a problem - while it increases the throughput by 1.5x if multiple threads are accessing the filesystem or if an application reads in parallel, the latency for a single request suffers a lot from this potential change, especially if there are no pending FUSE requests, due to the implementation of the
threadpoollibrary. The benchmarks of the services I'm developing shows at least 1.5->2x the latency on single-thread workflows.In particular, there are two hot spots, one of them is the lines below. The
ThreadPool's job receiver uses astd::sync::Mutexwrapping astd::sync::mpscchannel. When I have a thread pool with a size of 8, and there are no tasks in the pool, one of the thread is blocked atlock.recv(), and the seven other threads are contending for theMutexatjob_receiver. So when the first thread receives a job, it releases the lock, and callsfutex_wake(which is a syscall that takes an absurd amount of time) to wake one of the seven contending threads. Therefore, having 7 idle threads basically means that 7 FUSE requests in the future are guaranteed to be severely throttled byfutex_wake.The second hotspot is in the
executemethod. It uses ampscchannel which also performsfutex_waketo wake up a parked thread that waits atlock.recv()above, which is a second source of slowdown.