-
Notifications
You must be signed in to change notification settings - Fork 564
Use global threadpool for new epoch block processing #5833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
thread_pool_creation_us=5705i It takes 5-6ms to create the threadpool at epoch boundary. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5833 +/- ##
=========================================
- Coverage 82.9% 82.9% -0.1%
=========================================
Files 840 840
Lines 377801 377727 -74
=========================================
- Hits 313300 313193 -107
- Misses 64501 64534 +33 🚀 New features to boost your workflow:
|
Using global threadpool means some other logic may be occupying it, which may delay your work starting by far more than 5-6 ms. |
@alexpyattaev what other logic is using global threadpool? From what I see, the global threadpool threads seem to be idle all the time? do you have a benchmark for the delay on using global thread pool? The current code creates one threadpool per epoch boundary block, which can leads to hundreds of threads at the epoch boundary because the long running epoch processing create many forks ... |
Thing is it is hard to tell which components use global pool at all. So we can never be sure it does not get added later. And our unittests do not check for epoch transitions. But maybe creating pools per fork is the worse of the two evils. |
Another alternative is to create a dedicated threadpool for epoch boundary processing. This way, we know that no other component will compete for the thread pool. But the downside is that this threadpool is idle most of the time except at epoch boundary. So there is pros and cons here too. @steviez I recalled that you have audited all thread pool usage before. I would like to now if you have any opinion on the thread pool usage at epoch boundary? Can we use global thread pool at epoch boundary? |
I had a good handle on this at one point, but that was more than a year ago so my answer is "hard to say". The more things that use the global threadpool, the harder it is to answer this question tho. I share Alex's concern about usage spikes; the pool might have low usage in relation to the lifetime of the process, but hard to know what is happening in short bursts. And, if this code is relying on the pool to be idle, then this pool arguably "owns" the global pool.
Generally speaking, I'd like to see our usage of the global pool trend towards zero with the exception being "one time tasks" at startup.
Eyeballing some metrics on MNB, I see
I had thought about something like this before. Our code for creating new banks is serial in |
I think one of the danger to use "global thread pool" is that 3rd party libraries could be competing for the global pool. |
Find it. I think you are right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the status of this PR?
I ask because it is marked as ready for review, and my review is requested, yet the PR description says its experimental and should not be merged.
Yes, it is ready for review. In my original study, using global threadpool gave us better performance as long as no other process was occupying the global threadpool, which is the case for agave validator. |
Can you share/include up to date perf numbers of the epoch processing with and without this PR, please? |
Benchmark shows that it is faster with the new thread pool than with global threadpool, actually: 547ms vs 567ms. The difference, 20ms, is more than the cost of creating the threadpool 5ms. In addition, the threadpool is also used for processing other than epoch rewards. For example, apply_feature_activation is also better with the new thread pool (though not much).
So the cost of creating a new thread pool is worth it. We'd better keep using the new thread pool. |
Problem
Creating threadpool for epoch processing is expensive. When multiple forks happen at the new epoch, threadpools will be created multiple time. This wastes resources and hurt performance.
In this PR, we use global threadpool for new epoch processing.
Summary of Changes
Use global threadpool for new epoch processing
Fixes #