-
Notifications
You must be signed in to change notification settings - Fork 38.7k
kernel: Move kernel-related cache constants to kernel cache #31483
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5db7d4d
doc: Correct docstring describing max block tree db cache
sedited 8bd5f8a
[refactor] init: Simplify coinsdb cache calculation
sedited c03a279
util: Add integer left shift helpers
sedited d5e2c4a
fuzz: Add fuzz test for checked and saturating add and left shift
sedited e758b26
kernel: Move kernel-specific cache size options to kernel
sedited 8826cae
kernel: Move non-kernel db cache size constants
sedited 65cde36
kernel: Move default cache constants to caches
sedited 2a92702
init: Use size_t consistently for cache sizes
sedited File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (c) 2024-present The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #ifndef BITCOIN_KERNEL_CACHES_H | ||
| #define BITCOIN_KERNEL_CACHES_H | ||
|
|
||
| #include <util/byte_units.h> | ||
|
|
||
| #include <algorithm> | ||
|
|
||
| //! Suggested default amount of cache reserved for the kernel (bytes) | ||
| static constexpr size_t DEFAULT_KERNEL_CACHE{450_MiB}; | ||
| //! Max memory allocated to block tree DB specific cache (bytes) | ||
| static constexpr size_t MAX_BLOCK_DB_CACHE{2_MiB}; | ||
| //! Max memory allocated to coin DB specific cache (bytes) | ||
| static constexpr size_t MAX_COINS_DB_CACHE{8_MiB}; | ||
|
|
||
| namespace kernel { | ||
| struct CacheSizes { | ||
| size_t block_tree_db; | ||
| size_t coins_db; | ||
| size_t coins; | ||
sedited marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| CacheSizes(size_t total_cache) | ||
| { | ||
| block_tree_db = std::min(total_cache / 8, MAX_BLOCK_DB_CACHE); | ||
| total_cache -= block_tree_db; | ||
| coins_db = std::min(total_cache / 2, MAX_COINS_DB_CACHE); | ||
| total_cache -= coins_db; | ||
| coins = total_cache; // the rest goes to the coins cache | ||
| } | ||
| }; | ||
| } // namespace kernel | ||
|
|
||
| #endif // BITCOIN_KERNEL_CACHES_H | ||
ryanofsky marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.