-
Notifications
You must be signed in to change notification settings - Fork 445
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
base: master
Are you sure you want to change the base?
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 83.0% 83.0% -0.1%
=========================================
Files 828 828
Lines 375638 375564 -74
=========================================
- Hits 311919 311809 -110
- Misses 63719 63755 +36 🚀 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. |
Problem
** Experiment PR. Don't merge. **
Creating threadpool for epoch processing is expensive. When multiple forks
happen at the new epoch, multiple threadpools will be created. This waste
resources and could hurt performance.
In this PR, we use global threadpool for new epoch processing.
Summary of Changes
Use global threadpool for new epoch processing
Fixes #