-
Notifications
You must be signed in to change notification settings - Fork 0
feat(affinity): Add CPU affinity for client and server #70
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
Draft
dustinblack
wants to merge
5
commits into
main
Choose a base branch
from
feature/cpu-affinity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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 comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
12 tasks
This commit introduces the ability to pin the benchmark server to a specific CPU core using the --server-affinity command-line argument. This feature is useful for creating a more stable and repeatable testing environment by reducing performance noise from CPU context switching and cache misses. Key changes: - Added 'core_affinity' crate as a dependency. - Added '--server-affinity' and '--client-affinity' CLI flags. - Implemented the logic to spawn the server task on a dedicated thread with the specified CPU affinity. - Added unit tests for argument parsing and the new affinity-spawning logic. - Updated documentation and configuration display to reflect the new options. Note: Client-side affinity is parsed but not yet implemented. AI-assisted-by: Gemini 2.5 Pro feat: Add client-side CPU affinity This commit implements client-side CPU affinity and refactors the test execution logic to support it. Key changes: - Refactored single-threaded test functions to spawn the client logic in a separate task with the specified affinity. - Client tasks now return raw latency data, which is then processed by the main task. - Updated README.md to document the new --server-affinity and --client-affinity flags. - Added documentation to the refactored functions in benchmark.rs. AI-assisted-by: Gemini 2.5 Pro fix(build): Correct task spawning and error handling This commit addresses several compilation errors and warnings that arose from recent changes to the task spawning and affinity logic. The primary issue was a 'moved value' error with the oneshot sender ('tx') used for server readiness signaling. This was resolved by refactoring the server-spawning logic to ensure the sender is only used once. This change introduced a type mismatch in the 'match' statement handling the result of 'spawn_with_affinity', which has also been corrected. Additionally, several instances of an erroneous double '??' operator on non-Result types were fixed, and unused imports were removed. AI-assisted-by: Gemini 2.5 Pro
Improves the clarity of the command-line help text by moving the '--server-affinity' and '--client-affinity' flags from the 'Concurrency' heading to a more appropriate 'Affinity' heading. AI-assisted-by: Gemini 2.5 Pro
Adds the configured server and client CPU affinity values to the benchmark configuration summary that is printed at the start of a run. This provides immediate visual confirmation that the affinity settings have been applied. AI-assisted-by: Gemini 2.5 Pro
Resolves a race condition where `core_affinity::get_core_ids()` would intermittently report only a single available core, causing affinity validation to fail. The fix ensures that the list of available cores is retrieved from the main thread (which has an unrestricted view) before entering the `spawn_blocking` context, where the thread's affinity might already be constrained. This makes the core ID validation robust against the race condition. AI-assisted-by: Gemini 2.5 Pro
3388b7f
to
3cda341
Compare
🚨 Uncovered lines in this PR
📊 Code Coverage Summary
|
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.
Depends on PR #68
Description
This pull request introduces CPU affinity pinning for both the client and server tasks, allowing
for more stable and repeatable benchmark results by minimizing OS scheduling noise. It also
includes a series of fixes to resolve build failures and logic errors that arose during the
implementation.
Key Changes:
--server-affinity <CORE_ID>
to pin the server task to a specific CPU core.--client-affinity <CORE_ID>
to pin the client task to a specific CPU core.core_affinity
crate to manage this functionality.README.md
has been updated to include instructions on how to use the new CPUaffinity flags.
Type of Change
Testing
Checklist