-
Notifications
You must be signed in to change notification settings - Fork 170
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
Implement file descriptor budget pool #284
Merged
Merged
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
biryukovmaxim
force-pushed
the
fd-budget
branch
5 times, most recently
from
September 28, 2023 12:49
3fea046
to
5aa7068
Compare
biryukovmaxim
force-pushed
the
fd-budget
branch
3 times, most recently
from
October 13, 2023 01:37
bc83246
to
1df6fd7
Compare
someone235
requested changes
Oct 25, 2023
someone235
changed the title
"Implement file descriptor budget pool"
Implement file descriptor budget pool
Oct 25, 2023
biryukovmaxim
force-pushed
the
fd-budget
branch
from
October 25, 2023 15:08
1df6fd7
to
b743931
Compare
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
biryukovmaxim
force-pushed
the
fd-budget
branch
from
October 27, 2023 08:38
3dc1da0
to
7babf13
Compare
someone235
requested changes
Oct 29, 2023
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."
someone235
approved these changes
Oct 29, 2023
smartgoo
pushed a commit
to smartgoo/rusty-kaspa
that referenced
this pull request
Jun 18, 2024
* "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]>
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.
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.