-
Notifications
You must be signed in to change notification settings - Fork 38.7k
checkqueue: set MAX_SCRIPTCHECK_THREADS to nCores - 1 #32692
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
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32692. ReviewsSee the guideline for information on the review process. ConflictsNo conflicts as of last run. |
|
I think up to |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
There is a master worker, plus
I'll look into it. |
That is incorrect. With
Thread contention is the overhead inside bitcoind caused by coordination between the threads, and is unrelated to what the hardware provides or how loaded it is. The reason for the existing limit of 15 is because benchmarks showed that even on an otherwise unloaded machine with more cores than that, adding more script validation threads was net slower after about that many. That benchmark dates from 2013, so there is no reason to assume it still holds, as both hardware and typical blockchain script usage has changed significantly, as well as other parts of the codebase. But it would still be worth investigating if there isn't just some number above which it makes no sense. |
src/validation.h
Outdated
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.
Don't do this. Upper-case variable names are for constants, and this is no longer a constant. If there is reason for it to be a variable, the constant and its name should be removed, and the code using it should be adapted to compute it on the fly.
From the code I read from checkqueue.h ( https://raw.githubusercontent.com/bitcoin/bitcoin/refs/heads/master/src/checkqueue.h#:~:text=std%3A%3Aoptional%3CR%3E%20Complete()%20EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) ) I think
I'll try to find a machine which has enough cpu resource to test it. |
That's not correct. The number of worker threads is one less than the argument to |
I see, sorry for missing this part, but |
|
@HowHsu I am so sorry! You are right. |
|
Hi Sipa,
Any doc about this test?
Is the benchmark you mentioned /bench/connectblock.cpp I've done some investigation, and found the bottleneck may be the ECC calculation itself, not lock contension or something else. |
|
I'm going to close this one since I found that under the current scriptcheck queue implementation, cores >=14 or 15 may degrade the performance. |
|
Maybe this is something best solved by runtime benchmarking? (Or perhaps just at startup, since early blocks may not give us the parallelization we need for it) |
|
I post a new scriptcheck pool implementation #32791 with atomic variables rather than mutex to reduce thread sync contention. That achieves very good performance improvement. But the idea is based on that |
I think we can do it so, binary search the best worker thread number with bencharking on some standard test data. |
|
Maybe turn into draft while CI is red and this is still a WIP? |
A fixed MAX_SCRIPTCHECK_THREADS value is not flexible for users to leverage their cpu resources, and a value large than nCores - 1 doesn't make sense since it only adds some context switch overhead. Set it to nCores - 1. Assumption: A user who sets the number of script verification workers is aware of how this affects the system performance, otherwise he/she leaves it as default (which is 0) Signed-off-by: Hao Xu <hao.xu@linux.dev>
|
Are you still working on this? |
No |
I also checked this using the |
A fixed MAX_SCRIPTCHECK_THREADS value is not flexible for users to leverage their cpu resources, and a value large than nCores - 1 doesn't make sense since it only adds some context switch overhead. Set it to nCores - 1. Assumption: A user who sets the number of script verification workers is aware of how this affects the system performance, otherwise he/she leaves it as default (which is 0)