forked from kaspanet/rusty-kaspa
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement file descriptor budget pool (kaspanet#284)
* "Implement file descriptor budget pool" In this commit, a file descriptor budget pool has been implemented for better allocation of file descriptors. The feature has been added in a new library named "fd_budget_pool". The implementation uses atomic operations to keep track of acquired file descriptors and ensures that the total number of acquired descriptors never exceeds a system-specific limit. A FDGuard structure was introduced to automatically release the acquired file descriptors when they are no longer in use. The ordering of atomic operations is marked as 'to do' for later optimization considerations. The get_limit function will check the system and determine the maximum allowable file descriptors. Additionally, tests are written to confirm the correct functioning of the feature. Changes have also been made to Cargo files to include the new library and its dependencies. The ultimate goal of this feature is to prevent system-level issues arising from exhausting file descriptors. * "Move fd_budget_pool to utils module" Moved the 'fd_budget_pool' module into the 'utils' module as 'fd_budget'. This was done to consolidate all utility functions into one module to make the codebase cleaner and easier to maintain. This commit involves removal of 'fd_budget_pool' from the workspace and updated the 'Cargo.toml' and 'lib.rs' files accordingly. The code was also refactored to improve error handling. * Optimize file descriptor usage across databases. Many database interfaces were changed to support setting a file descriptor limit upon creation of the DB. This allows better allocation of the total file descriptor budget across the multiple databases instantiated across the system. A utility function was also added to the utils crate to manage the allocation of file descriptors. This will lead to a more stable system under high load and better use of system resources. * Add 'rlimit' dependency for non-wasm32 targets The 'rlimit' dependency was added in the Cargo.toml file under the condition that the target architecture is not 'wasm32'. This is to ensure that appropriate resource limits can be set for the given non-wasm32 targets. * Adjust test_db_relations_store to include drop operation Added a 'drop(lt)' function to the 'test_db_relations_store()' function in relations.rs. The function 'lt' was previously created but never used. The new 'drop(lt)' ensures that 'lt' is cleared from memory when it is no longer needed, optimizing the performance and memory usage. * decrease limit for daemon_sanity_test * use constants defining db file limits * add fd_total_budget to mempool benchmark * Add cleanup step to core and task runtime This commit introduces a cleanup phase by clearing services in both core and task runtime. This is done to ensure that all services are dropped and properly disposed of after being used. For the task runtime, this cleanup happens after the async-runtime worker stops. For the core, cleanup occurs once it's shut down. This step further advances the robustness of our termination handling. * Refactor 'get_limit' function to 'limit' in 'fd_budget' The function 'get_limit' in the file 'fd_budget.rs' has been renamed to 'limit' to reflect its getter style and improve the code readability. This change affects the references to 'get_limit' from 'mempool_benchmarks.rs' and 'main.rs' files as well, which are updated accordingly. Additionally, updated the 'fd_total_budget' calculation in 'main.rs' to subtract 32 instead of 64. * Refactor fd_budget test function name The test function in fd_budget.rs was renamed from 'it_works' to 'test_acquire_and_release_guards'. This change was made to better describe the function's purpose and operations. The refined name illustrates that this function tests both the acquisition and release of guards, hence providing clarity to the code. * Make fd_total_budget field private * Updated fd_budget for unsupported OS fallback Modified the fd_budget.rs file to return a fallback value of 512 for unsupported operating systems rather than panicking. This improvement provides better stability for the application when running in different environments. * Modify fd_budget for better resource allocation Adjusted fd_budget allocation within multiple files to enhance resource utilization across various components of the application. The changes include dividing fd_total_budget equally among active and staging consensuses and assigning fd_budget based on the given limit values in each module. These modifications were implemented to ensure more efficient and fair distribution of resources, and to prevent potential resource allocation issues for unsupported operating systems. * "Refactor fd_budget import statement The import statement for the fd_budget module was refactored across multiple files for better readability. Instead of directly importing the limit function, the whole fd_budget module is being imported, and calls to limit function are then prefixed with 'fd_budget::'. This provides clearer code structure and facilitates easier tracking of module usage." * add positive check for fd_budget --------- Co-authored-by: Ori Newman <[email protected]>
- Loading branch information
1 parent
83f840a
commit ae7dae3
Showing
28 changed files
with
295 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,3 @@ tempfile.workspace = true | |
|
||
enum-primitive-derive = "0.2.2" | ||
num-traits = "0.2.15" | ||
rlimit = "0.10.1" |
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
Oops, something went wrong.