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
Add CLI flags to config LevelDB table/total sizes #981
Merged
marcello33
merged 6 commits into
maticnetwork:develop
from
alchemyplatform:rroblak/upstream-level-db-patch-develop-cherry
Sep 12, 2023
Merged
Add CLI flags to config LevelDB table/total sizes #981
marcello33
merged 6 commits into
maticnetwork:develop
from
alchemyplatform:rroblak/upstream-level-db-patch-develop-cherry
Sep 12, 2023
Conversation
This file contains 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
rroblak
force-pushed
the
rroblak/upstream-level-db-patch-develop-cherry
branch
from
August 29, 2023 22:03
db548a5
to
675092d
Compare
I wired up CLI flags to allow configuring LevelDB table and total sizes: - `--leveldb.compaction.table.size`, LevelDB SSTable file size factor in MiB (default: 2) - `--leveldb.compaction.table.multiplier`, multiplier on LevelDB SSTable file size (default: 1) - `--leveldb.compaction.total.size`, total size factor in MiB of LevelDB levels (default: 10) - `--leveldb.compaction.total.multiplier`, multiplier on LevelDB total level size (default: 10) N.B. that the default values for these configs are exactly the same as before this changset and so Bor behavior should not change unless these flags are deliberately overridden. Bor/Geth inherited the default values from [the `goleveldb` defaults](https://github.com/syndtr/goleveldb/blob/126854af5e6d8295ef8e8bee3040dd8380ae72e8/leveldb/opt/options.go). We (Alchemy) found it necessary to override these configs as follows to keep Bor archive nodes tracking the canonical chain: - `--leveldb.compaction.table.size=4` - `--leveldb.compaction.total.size=20` These overrides double the size of LevelDB SSTable files (2 MiB -> 4 MiB) and also the total amount of data in each level (100 MiB -> 200 MiB, 1,000 MiB -> 2,000 MiB, etc.). The idea is to have LevelDB read and write data in larger chunks while keeping the proportional frequency of compaction operations the same as in the original defaults defined by Dean and Ghemawat. Without these overrides we found that our archive nodes would tend to fall into a "LevelDB compaction loop of death" where the incoming stream of blockchain data could not be flowed into LevelDB's structure quickly enough, resulting in the node blocking writes for long periods of time while LevelDB's single-threaded compaction organized the data. Over time the nodes would fall farther and farther behind the canonical chain head, metaphorically dying a slow node's death. These configs can be changed on existing node databases (resyncing is not necessary). LevelDB appears to work correctly with SSTable files of different sizes. Note that the database does not undergo any sort of migration when changing these configs. Only newly-written files (due to new data or compaction) are affected by these configs.
rroblak
force-pushed
the
rroblak/upstream-level-db-patch-develop-cherry
branch
from
August 29, 2023 22:23
675092d
to
95953ad
Compare
rroblak
commented
Aug 29, 2023
Thanks @rroblak for contributing this feature and creating a detailed PR! Added a few comments about db option passing. There are some linter failures. You can check them by running |
cffls
reviewed
Aug 30, 2023
cffls
approved these changes
Sep 11, 2023
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. Thank you @rroblak for addressing the comments!
marcello33
approved these changes
Sep 12, 2023
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.
Description
I wired up CLI flags to allow configuring LevelDB table and total sizes:
--leveldb.compaction.table.size
, LevelDB SSTable file size factor in MiB (default: 2)--leveldb.compaction.table.multiplier
, multiplier on LevelDB SSTable file size (default: 1)--leveldb.compaction.total.size
, total size factor in MiB of LevelDB levels (default: 10)--leveldb.compaction.total.multiplier
, multiplier on LevelDB total level size (default: 10)N.B. that the default values for these configs are exactly the same as before this changset and so Bor behavior should not change unless these flags are deliberately overridden. Bor/Geth inherited the default values from the
goleveldb
defaults.
We (Alchemy) found it necessary to override these configs as follows to keep Bor archive nodes tracking the canonical chain:
--leveldb.compaction.table.size=4
--leveldb.compaction.total.size=20
These overrides double the size of LevelDB SSTable files (2 MiB -> 4 MiB) and also the total amount of data in each level (100 MiB -> 200 MiB, 1,000 MiB -> 2,000 MiB, etc.). The idea is to have LevelDB read and write data in larger chunks while keeping the proportional frequency of compaction operations the same as in the original defaults defined by Dean and Ghemawat.
Without these overrides we found that our archive nodes would tend to fall into a "LevelDB compaction loop of death" where the incoming stream of blockchain data could not be flowed into LevelDB's structure quickly enough, resulting in the node blocking writes for long periods of time while LevelDB's single-threaded compaction organized the data. Over time the nodes would fall farther and farther behind the canonical chain head, metaphorically dying a slow node's death.
These configs can be changed on existing node databases (resyncing is not necessary). LevelDB appears to work correctly with SSTable files of different sizes. Note that the database does not undergo any sort of migration when changing these configs. Only newly-written files (due to new data or compaction) are affected by these configs.
Changes
Nodes audience
We added the following flags to our nodes'
bor server
invocation:--leveldb.compaction.table.size=4 --leveldb.compaction.total.size=20
to allow them to catch back up to the canonical chain head.Checklist
Testing
Manual tests
bor server
.