-
Notifications
You must be signed in to change notification settings - Fork 259
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
validator: Add CLI args to control rocksdb threadpool sizes #4214
Conversation
We previously used options.increase_parallelism() which would size the high priority (memtable flush) threadpool differently than what the comments would indicate in the code. So, set the threadpool sizes directly. Threadpool sizes are unchanged from this PR, but will enable fine tuning in subsequent changes
36f0b91
to
6598e6c
Compare
6598e6c
to
62a73f8
Compare
I would suggest we change defaults to use at 4-8 threads in total. The work here is IO bound, and in my tests I have not observed rocksdb ever using more than 3 threads. If someone needs more, they would be able to change via CLI. Even under max load I believe 8 threads would be enough to saturate the ssd, unless rocksdb needs serious optimization. Even if it somehow can use more threads, it could then interfere with other validator operations that are already saturating their respective CPU cores (PoH, snapshot packaging, gossipRx). So I suggest the default pool size should never be set above n_cpu/2 for any thread pool at all. |
I agree that the current pool sizes are overkill. For this PR, the goal is to introduce the CLI args without any change in behavior. Basically, introduce the mechanical changes in one PR (this one) and then the actual changes in functionality (shrink the pools) in another. Breaking these up has a handful of benefits, including smaller diff's in general (easier to review) as well as isolating the functionality changes (which deserve more scrutiny) to a much smaller diff |
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.
LGTM, one commented line should probably be deleted instead.
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.
Few minor nits. 1 question around the default low prio pool thread count
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.
LGTM
Problem
See #105 for more context
Summary of Changes
Threadpool sizes are unchanged from this PR, but will enable fine tuning in subsequent changes
Additional Context for setting threadpool size directly
The below section has some code snippets/links that explain why our current code configures
num_cpus
low priority threads andnum_cpus / 4
high priority threads. LetN = num_cpus::get()
.Snippets
We were previously calling
increase_parallelism()
withN
which ends up here:This immediately creates
N
low priority threads, and 1 high priority thread. But, note thatmax_background_jobs
is also set toN
. This is important because when the DB is opened, the options are checked for consistency and thread pools are grown if necessary. That happens here:with the implementation here:
We hit the
if
case and then assumingN > 4
as it is for validators:Then, we go grow these threadpools if necessary here:
So, the value of
4
that we set here is coerced up on high core count nodes:agave/ledger/src/blockstore_db.rs
Line 2009 in c7131f6
Empirically, if I adjust the value in
options.set_max_background_jobs()
to256
, I see 192 (3N/4
) low and 64 (N/4
) high threads.Testing out on a machine with 32 cores / 64 threads, I still see 64 low priority threads / 16 high priority threads with this PR. I also confirmed that setting
--rocksdb-compaction-threads X
and--rocksdb-flush-threads Y
yieldsX
low priority threads andY
high priority threads