Skip to content
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

Fairness #3134

Merged
merged 9 commits into from
Jan 10, 2024
Merged

Fairness #3134

merged 9 commits into from
Jan 10, 2024

Conversation

tanveergill
Copy link
Contributor

@tanveergill tanveergill commented Jan 9, 2024

Description of change

Checklist
  • Tested in playground or other setup
  • Screenshot (Grafana) from playground added to PR for 15+ minute run
  • Documentation is changed or added
  • Tests and/or benchmarks are included
  • Breaking changes

Summary by CodeRabbit

  • New Features

    • Introduced fairness_label_key for enforcing fairness in workload scheduling.
    • Added new fairness-related metrics for observability.
  • Documentation

    • Updated configuration specification with fairness_label_key details.
    • Revised observability documentation to reflect new metrics.
  • Refactor

    • Enhanced the Scheduler interface with additional workload identification.
    • Updated scheduling logic to incorporate fairness in request handling.
  • Chores

    • Adjusted pre-commit spell check configuration.
  • Bug Fixes

    • Removed obsolete metrics related to previous scheduling mechanisms.

@tanveergill tanveergill requested review from a team as code owners January 9, 2024 03:18
Copy link
Contributor

coderabbitai bot commented Jan 9, 2024

Walkthrough

The system's scheduling logic has been updated to introduce a new fairness mechanism that differentiates requests based on a fairness_label_key. This ensures a more equitable distribution of resources among requests within the same priority. Metrics related to the previous Weighted Fair Queuing Scheduler have been removed in favor of new ones that track this fairness. Additionally, the scheduler code now includes methods for identifying request workload and flow, and the configuration files have been adjusted to reflect these changes.

Changes

File Path Change Summary
api/aperture/policy/language/v1/flowcontrol.proto, docs/content/reference/configuration/spec.md Added fairness_label_key to enforce fairness in request scheduling.
docs/content/reference/observability/prometheus-metrics/agent.md Removed WFQScheduler metrics; added workload fairness metrics.
pkg/scheduler/scheduler.go, pkg/scheduler/wfq.go, pkg/scheduler/.../scheduler.go Updated Scheduler interface and WFQScheduler with new methods and fields for fairness; metrics adjusted accordingly.
pkg/scheduler/wfq_test.go, pkg/metrics/schema.go Updated tests and metrics schema to align with scheduling fairness changes.
pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go Modified Factory struct, SchedulerMetrics, and Decide method to accommodate fairness metrics.
.pre-commit-config.yaml Updated codespell configuration.

"In the burrow of the code, a change was sown,
🐇 A fairness key in the scheduler's home.
No more FIFO, just fair play,
For every request that hops its way."


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b2dff54 and 3aa96a5.
Files ignored due to filter (10)
  • api/buf.lock
  • api/gen/proto/go/aperture/policy/language/v1/flowcontrol.pb.go
  • api/gen/proto/go/aperture/policy/language/v1/flowcontrol.pb.validate.go
  • api/gen/proto/go/aperture/policy/language/v1/flowcontrol_vtproto.pb.go
  • blueprints/gen/jsonschema/_definitions.json
  • blueprints/gen/v1/scheduler.libsonnet
  • docs/content/assets/openapiv2/aperture-controller.swagger.yaml
  • docs/content/assets/openapiv2/aperture.swagger.yaml
  • docs/gen/policy/policy.yaml
  • go.mod
Files selected for processing (8)
  • api/aperture/policy/language/v1/flowcontrol.proto (1 hunks)
  • dashboards/grafana/dashboards/summary/scheduler/rows-fn.libsonnet (1 hunks)
  • docs/content/reference/configuration/spec.md (1 hunks)
  • docs/content/reference/observability/prometheus-metrics/agent.md (1 hunks)
  • pkg/metrics/schema.go (1 hunks)
  • pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go (8 hunks)
  • pkg/scheduler/request.go (1 hunks)
  • pkg/scheduler/wfq.go (14 hunks)
Additional comments: 15
pkg/scheduler/request.go (2)
  • 5-5: The addition of the WorkloadLabel field to the Request struct is a good way to identify workloads. This should help in implementing the fairness feature across requests.

  • 12-14: The update to the NewRequest function signature to include the workloadLabel parameter aligns with the changes to the Request struct and supports the new fairness mechanism.

dashboards/grafana/dashboards/summary/scheduler/rows-fn.libsonnet (1)
  • 196-196: The simplification of the Grafana dashboard function by removing barGaugePanel elements is consistent with the PR's objective to streamline the dashboard panels.
pkg/metrics/schema.go (1)
  • 120-125: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [1-1]

The removal of WFQFlowsMetricName and WFQRequestsMetricName constants aligns with the PR's objective to move away from the WFQScheduler metrics. Please ensure that there are no remaining references to these constants in the codebase to prevent any potential errors.

pkg/scheduler/wfq.go (5)
  • 12-12: The addition of the github.com/cespare/xxhash package is noted. This package is used for hashing, which is relevant to the new fairness feature.

  • 134-151: New fields fairnessSeedUpdateTime, fairnessSeed, and fairnessQueuesPerWorkload have been added to the WFQScheduler struct. Ensure that the logic surrounding these fields is thread-safe, especially since fairnessSeed is updated in a non-atomic way in the Identifiers function.

  • 260-282: The Identifiers function has been updated to include logic for computing fairnessQueueID and constructing workloadID and flowID. Ensure that the hashing and bitwise operations are correctly implemented and that the fairnessSeed is updated in a thread-safe manner.

  • 313-328: The queueRequest function now includes logic to maintain a count of fairness queues per workload. Ensure that the increment of fairnessQueuesPerWorkload is thread-safe and that the logic correctly reflects the intended behavior.

  • 336-344: The cost calculation in queueRequest now includes a fairnessAdjustment factor. Confirm that this adjustment is correctly applied and that the cost calculation is accurate.

pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go (3)
  • 156-156: The registration of metrics in the OnStart hook is done correctly. However, it's important to ensure that the removed WFQ gauges are not used elsewhere in the codebase.
Verification successful

The executed script did not find any references to wfqFlowsGaugeVec or wfqRequestsGaugeVec in the Go files of the codebase. This suggests that the removal of these gauges from scheduler.go has not left any dangling references in the code.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the removed WFQ gauges are not referenced anywhere else in the codebase.
rg --type go 'wfqFlowsGaugeVec|wfqRequestsGaugeVec'

Length of output: 53

* 309-309: The deletion logic for metrics in the `Delete` method is correct. It's good to see that there is error handling for the case where metrics cannot be deleted. However, it's important to ensure that the log messages are consistent and provide enough context for debugging.
  • 564-569: The addition of the fairnessLabel logic in the Decide method is consistent with the PR's objective to introduce fairness into the scheduling process. Ensure that the fairnessLabelKey is properly documented and validated elsewhere in the codebase.
Verification successful

To further verify the documentation and validation of fairnessLabelKey, I will generate a script to search for instances where fairnessLabelKey is used in the code and check for associated comments or validation logic.


To ensure thorough verification, I will generate a script to search for the actual usage of the FairnessLabelKey in the code where validation logic would typically be implemented.


The review comment is partially verified. The FairnessLabelKey is documented in the protobuf definition files, and while there are no static validation rules defined in the protobuf validation file, the key is used in the code with runtime checks to ensure it is applied if set. This aligns with the PR's objective to introduce fairness into the scheduling process.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the `fairnessLabelKey` is documented and validated.
rg --type go --files-with-matches 'fairnessLabelKey' | xargs -L 1 cat | grep -C 3 'fairnessLabelKey'

Length of output: 729



Script:

#!/bin/bash
# Search for usage of `fairnessLabelKey` and any associated validation or documentation.
rg --type go 'fairnessLabelKey' -C 5

Length of output: 1786



Script:

#!/bin/bash
# Search for the actual usage of `fairnessLabelKey` in the code to find validation logic.
rg --type go -F 'FairnessLabelKey' --context 10

Length of output: 17596

api/aperture/policy/language/v1/flowcontrol.proto (2)
  • 458-460: The addition of the fairness_label_key field to the Scheduler message is correctly placed at index 11 and follows the Protocol Buffers style guide for extending messages. This field will enable the enforcement of fairness among requests within a workload, as intended by the PR objectives.

  • 455-463: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-460]

Overall, the changes to the flowcontrol.proto file are limited to the addition of the fairness_label_key field in the Scheduler message. The file's structure, syntax, and other message definitions remain intact and consistent with the Protocol Buffers specifications. No issues related to syntax, logic, or integration of the new field have been identified.

docs/content/reference/configuration/spec.md (1)
  • 8809-8820: The documentation for the fairness_label_key field is clear and provides a good explanation of its purpose and default behavior. It's a valuable addition to the configuration spec for users to understand how to enforce fairness among requests within a workload.

pkg/scheduler/wfq.go Outdated Show resolved Hide resolved
pkg/scheduler/wfq.go Outdated Show resolved Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3aa96a5 and 95d44ac.
Files selected for processing (1)
  • pkg/scheduler/wfq.go (14 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pkg/scheduler/wfq.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 95d44ac and b6d1ffa.
Files ignored due to filter (5)
  • api/gen/proto/go/aperture/policy/language/v1/flowcontrol.pb.go
  • blueprints/gen/jsonschema/_definitions.json
  • docs/content/assets/openapiv2/aperture-controller.swagger.yaml
  • docs/content/assets/openapiv2/aperture.swagger.yaml
  • docs/gen/policy/policy.yaml
Files selected for processing (2)
  • api/aperture/policy/language/v1/flowcontrol.proto (1 hunks)
  • docs/content/reference/configuration/spec.md (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • api/aperture/policy/language/v1/flowcontrol.proto
  • docs/content/reference/configuration/spec.md

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b6d1ffa and daf1d90.
Files selected for processing (3)
  • pkg/scheduler/scheduler.go (1 hunks)
  • pkg/scheduler/wfq.go (15 hunks)
  • pkg/scheduler/wfq_test.go (22 hunks)
Additional comments: 30
pkg/scheduler/scheduler.go (1)
  • 15-16: The addition of the Identifiers method to the Scheduler interface aligns with the PR objectives to support the new fairness feature. The method signature looks correct and well-integrated into the interface.
pkg/scheduler/wfq.go (7)
  • 8-12: The import of the github.com/cespare/xxhash package and the addition of the NumFairnessQueues global variable are consistent with the PR objectives to implement fairness in request scheduling.

  • 99-99: The addition of the workloadID field to the flowInfo struct is necessary for the new fairness logic to track workloads.

  • 132-151: The new fields fairnessSeedUpdateTime, fairnessSeed, and fairnessQueuesPerWorkload in the WFQScheduler struct are essential for the fairness feature, enabling the scheduler to maintain state related to fairness across different workloads.

  • 259-284: The Identifiers method correctly implements the logic to generate flowID and workloadID based on the fairness and workload labels, priority, and generation. The use of xxhash for hashing and bitwise operations for efficiency is noted and approved.

  • 313-344: The modifications to the queueRequest method, including the use of the Identifiers method and the new cost calculation logic, are consistent with the fairness feature's requirements. The cost calculation now considers the number of fairness queues per workload, which is a key part of the fairness logic.

  • 521-527:

  • 587-593: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [590-607]

The updates to the preemptionMetrics struct and the related methods for updating metrics appear to be correct. The metrics now include labels for workload, which is necessary for the new fairness feature. The initialization and publishing of metrics are handled appropriately.

pkg/scheduler/wfq_test.go (22)
  • 26-31: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [1-17]

The import section looks standard and does not seem to have any issues. All imported packages are used in the file.

  • 108-111: The flowTracker struct has been modified to include a workloadLabel and the priority field has been renamed to invPriority. Ensure that all references to these fields are updated accordingly throughout the codebase.

  • 130-132: The String method of flowTracker has been updated to use workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 205-205: The makeRequest method of flowTracker has been updated to use the new workloadLabel and invPriority fields. This change is consistent with the modifications to the flowTracker struct.

  • 220-220: The BenchmarkBasicTokenBucket function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 249-253: The BenchmarkTokenBucketLoadMultiplier function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 331-338: The logic within baseOfBasicBucketTest function now creates a map to track fairness queues per workload. This is likely related to the new fairness feature. Ensure that the logic correctly implements the intended fairness mechanism.

Verification successful

The extended output from the rg command provides the relevant section of the baseOfBasicBucketTest function, which includes the creation and usage of the fairnessQueuesPerWorkload map. This map is used to track the number of fairness queues per workload, which aligns with the new fairness feature described in the PR objectives.

The code snippet shows that for each flow in flows, the sched.Identifiers method is called to obtain a workloadID. This ID is then used to count the number of queues per workload in the fairnessQueuesPerWorkload map. Additionally, the snippet includes a calculation of sumPriority and adjustedPriority for each flow, which seems to be part of the fairness mechanism by adjusting the priority based on the number of queues and the inverse priority (invPriority) of the flow.

Based on the provided code snippet, it appears that the logic within the baseOfBasicBucketTest function is implementing a mechanism to ensure fairness by considering the number of queues per workload and adjusting priorities accordingly. This is consistent with the intended functionality of the fairness feature as described in the PR objectives and the AI-generated summary.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the fairness mechanism is implemented correctly by checking the logic in the function.
ast-grep --lang go --pattern $'func $_($$$) {
  $$$
  make(map[string]int)
  $$$
}'

Length of output: 84



Script:

#!/bin/bash
# Search for the 'baseOfBasicBucketTest' function to verify the implementation of the fairness mechanism.
ast-grep --lang go --pattern $'func baseOfBasicBucketTest($$$) {
  $$$
  make(map[string]int)
  $$$
}'

Length of output: 103



Script:

#!/bin/bash
# Search for the 'baseOfBasicBucketTest' function within Go files to confirm its existence.
rg --type go 'func baseOfBasicBucketTest'

Length of output: 164



Script:

#!/bin/bash
# Extract the content of the 'baseOfBasicBucketTest' function to verify the fairness mechanism implementation.
rg --type go -A 20 'func baseOfBasicBucketTest' pkg/scheduler/wfq_test.go

Length of output: 838



Script:

#!/bin/bash
# Extract more content of the 'baseOfBasicBucketTest' function to verify the fairness mechanism implementation.
rg --type go -A 40 'func baseOfBasicBucketTest' pkg/scheduler/wfq_test.go

Length of output: 1583

* 342-344: The calculation of `adjustedPriority` within `baseOfBasicBucketTest` function seems to be part of the new fairness logic. It's important to ensure that this calculation is correct and aligns with the intended fairness algorithm.
  • 384-384: The error logging within the baseOfBasicBucketTest function indicates that the test will fail if the fairness is not within the specified tolerance. This is a good practice as it ensures that the fairness feature is working as expected.

  • 424-427: The TestHighRpsFlows function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 437-440: The TestLowRpsFlows function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 450-453: The TestMixRpsFlows function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 463-466: The TestSingleHighRequest function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 476-479: The TestSingleLowRequest function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 489-492: The TestSingleLowRequestLowTimeout function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 502-505: The TestIncreasingPriority function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 515-518: The Test0FillRate function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 528-531: The TestFairnessWithinPriority function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct. Additionally, the test checks for fairness within priority levels, which is a good practice.

  • 549-557: The TestFairness function has been updated to initialize flowTrackers with workloadLabel and invPriority, and it also includes a fairnessLabel. This is likely part of the new fairness feature and should be reviewed to ensure it aligns with the intended functionality.

  • 566-566: The TestTimeouts function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct.

  • 577-579: The TestLoadMultiplierBucket function has been updated to initialize flowTrackers with workloadLabel and invPriority. This change is consistent with the modifications to the flowTracker struct. The test also includes logic for a load multiplier bucket, which should be reviewed to ensure it aligns with the intended functionality.

Verification successful

The rg command has provided the necessary context to verify the usage of NewLoadMultiplierTokenBucket within the wfq_test.go file. The function is indeed being used in the test file, as evidenced by the lines where it is called. Additionally, we have a list of function definitions from the same file.

Given this information, we can confirm that the NewLoadMultiplierTokenBucket function is utilized in the wfq_test.go file, and the test functions related to the load multiplier bucket, such as TestLoadMultiplierBucket, are present. However, without the ability to execute the code and observe its behavior, we cannot fully verify the functionality against the intended behavior as described in the review comment.

Therefore, the review comment stating that the TestLoadMultiplierBucket function has been updated to initialize flowTrackers with workloadLabel and invPriority is consistent with the changes in the flowTracker struct, and the presence of the NewLoadMultiplierTokenBucket function calls in the test file is . However, the functionality of the load multiplier bucket as implemented in the test should be manually verified by the user to ensure it aligns with the intended functionality.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the TestLoadMultiplierBucket function aligns with the intended functionality of the load multiplier bucket.
ast-grep --lang go --pattern $'func $_($$$) {
  $$$
  NewLoadMultiplierTokenBucket($_, $_, $_, $_, $_)
  $$$
}'

Length of output: 112



Script:

#!/bin/bash
# First, let's check if the NewLoadMultiplierTokenBucket function exists in the codebase.
rg "NewLoadMultiplierTokenBucket"

# If it exists, let's find out how it's being used in the test functions.
ast-grep --lang go --pattern $'func $_($$$) {
  $$$
  $_.NewLoadMultiplierTokenBucket($_, $_, $_, $_, $_)
  $$$
}'

Length of output: 911



Script:

#!/bin/bash
# Adjust the ast-grep pattern to find direct calls to NewLoadMultiplierTokenBucket within test functions.
ast-grep --lang go --pattern $'func $_($$$) {
  $$$
  NewLoadMultiplierTokenBucket($_, $_, $_, $_, $_)
  $$$
}'

Length of output: 112



Script:

#!/bin/bash
# Use a broader ast-grep pattern to capture any function in wfq_test.go where NewLoadMultiplierTokenBucket is called.
ast-grep --lang go --pattern $'func $_($$$) {
  $$$
  NewLoadMultiplierTokenBucket($$$)
  $$$
}' --file pkg/scheduler/wfq_test.go

Length of output: 324



Script:

#!/bin/bash
# Directly inspect the wfq_test.go file to find the function definitions and calls to NewLoadMultiplierTokenBucket.
rg "func" pkg/scheduler/wfq_test.go
rg "NewLoadMultiplierTokenBucket" pkg/scheduler/wfq_test.go

Length of output: 1921

* 328-362: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [1-563]

Overall, the changes in the wfq_test.go file are consistent with the PR objectives and the AI-generated summary. The modifications to the flowTracker struct and the associated test functions reflect the introduction of the fairness feature. The removal of specific gauge metrics and the updates to the test functions are in line with the changes to the weighted fair queuing logic.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between daf1d90 and 0d5eb84.
Files selected for processing (4)
  • docs/content/reference/observability/prometheus-metrics/agent.md (1 hunks)
  • pkg/metrics/schema.go (2 hunks)
  • pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go (15 hunks)
  • pkg/scheduler/wfq.go (20 hunks)
Additional comments: 22
pkg/metrics/schema.go (2)
  • 109-113: The addition of clarifications to the WorkloadPreemptedTokensMetricName, WorkloadDelayedTokensMetricName, and WorkloadOnTimeMetricName metrics is a good practice as it helps to understand the scope of these metrics. It's important to ensure that these changes are reflected in the documentation and any dashboards or alerts that may use these metrics.

  • 115-120: The new metrics FairnessPreemptedTokensMetricName, FairnessDelayedTokensMetricName, and FairnessOnTimeMetricName have been added to measure fairness at the queue level within the same workload. It's crucial to verify that these new metrics are integrated correctly into the metrics collection and reporting system, and that they are documented properly for users to understand their significance.

Verification successful

The results from the latest script execution confirm that the new fairness metrics (fairness_preempted_tokens, fairness_delayed_tokens, fairness_on_time_total) are indeed present in the scheduler.go file within the pkg/policies/flowcontrol/actuators/workload-scheduler directory. The references to these metrics are associated with error handling and logging, which suggests that they are part of the system's metrics management processes.

Additionally, the documentation for these metrics was found in a markdown file within the docs/content/reference/observability/prometheus-metrics/agent.md directory, indicating that the new metrics have been documented in the context of Prometheus metrics for the agent component.

Based on the information gathered, it can be concluded that the new fairness metrics have been integrated into the metrics collection and reporting system and are documented properly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify integration of new fairness metrics in metrics collection and reporting system.
rg --type go 'fairness_preempted_tokens|fairness_delayed_tokens|fairness_on_time_total'
# Verify documentation updates for new fairness metrics.
fd 'README.md' | xargs rg 'Fairness Metrics'

Length of output: 1732



Script:

#!/bin/bash
# Search for the registration and usage of the new fairness metrics in the codebase.
rg --type go 'MustRegister\(.+fairness_preempted_tokens\)|MustRegister\(.+fairness_delayed_tokens\)|MustRegister\(.+fairness_on_time_total\)|Observe\(.+fairness_preempted_tokens\)|Observe\(.+fairness_delayed_tokens\)|Inc\(.+fairness_on_time_total\)'

# Broaden the search for documentation related to the new fairness metrics within markdown files or inline code comments.
rg --type md 'fairness_preempted_tokens|fairness_delayed_tokens|fairness_on_time_total'
rg --type go '//.*fairness_preempted_tokens|//.*fairness_delayed_tokens|//.*fairness_on_time_total'

Length of output: 1664



Script:

#!/bin/bash
# Perform a more general search for the registration and usage of the new fairness metrics in the codebase.
rg --type go 'fairness_preempted_tokens|fairness_delayed_tokens|fairness_on_time_total'

Length of output: 1687

pkg/scheduler/wfq.go (11)
  • 8-12: The addition of the github.com/cespare/xxhash package is noted. This package is typically used for its fast non-cryptographic hash functions, which seems appropriate for the fairness feature being implemented.

  • 40-40: The introduction of a new global variable NumFairnessQueues is a significant change. It's important to ensure that this variable is used correctly throughout the code and that its value is appropriate for the intended use case.

Verification successful

The search results indicate that the NumFairnessQueues variable is indeed used within the pkg/scheduler/wfq.go file. It is defined as a global variable and is used in a bitwise operation to determine a fairnessQueueID. This suggests that the variable is being used in a manner consistent with a typical use case for a number of queues, which often involves modulo operations to distribute items across queues. The comment in the code also clarifies that NumFairnessQueues is expected to be a power of 2, which aligns with the initialization value of 1 << 8.

Based on the information provided, it appears that NumFairnessQueues is used correctly in the context of the wfq.go file.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that NumFairnessQueues is used consistently and correctly.
ast-grep --lang go --pattern $'NumFairnessQueues := $_'

Length of output: 56



Script:

#!/bin/bash
# Search for references to NumFairnessQueues to verify its usage throughout the codebase.
rg "NumFairnessQueues" --go

Length of output: 456



Script:

#!/bin/bash
# Correcting the previous script to search for references to NumFairnessQueues without specifying the language.
rg "NumFairnessQueues"

Length of output: 245

* 104-104: The addition of the `workloadID` field to the `flowInfo` struct is a key part of the fairness mechanism. It's important to ensure that this field is populated and used correctly throughout the code.
Verification successful

The workloadID field is being set, used to construct flowID, returned by the Identifiers method, and utilized to access, modify, and delete entries in the workloads map. This indicates that the workloadID is populated and used correctly throughout the wfq.go code as part of the fairness mechanism.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that workloadID is being set and used correctly.
ast-grep --lang go --pattern $'workloadID := $_'

Length of output: 152



Script:

#!/bin/bash
# Search for usage of `workloadID` in the code to ensure it's being used correctly.
rg "workloadID" ./pkg/scheduler/wfq.go

Length of output: 1112

* 145-162: The `WFQScheduler` struct has been updated with new fields related to fairness (`fairnessSeedUpdateTime`, `fairnessSeed`, and `workloads`). It's crucial to review the initialization and usage of these fields to ensure they are handled correctly.
Verification successful

The shell script outputs confirm the following:

  1. The NewWFQScheduler function initializes the fairnessSeedUpdateTime and fairnessSeed fields, as well as the workloads map. This is evident from the constructor code in pkg/scheduler/wfq.go, where sched.fairnessSeedUpdateTime is set to the current time, sched.fairnessSeed is initialized to 0, and sched.workloads is initialized as a map from string to *WorkloadState.

  2. The fairnessSeedUpdateTime field is updated if the last access time is more than 300 seconds from the fairnessSeedUpdateTime. This logic is intended to randomize the fairnessSeed every 5 minutes, as indicated by the comment in the code.

  3. The fairnessSeed field is randomized using rand.Uint32() and updated along with the fairnessSeedUpdateTime field.

  4. The fairnessSeed is used in conjunction with the fairnessLabel to compute a hash using xxhash.Sum64String.

These findings verify that the new fields related to fairness in the WFQScheduler struct are initialized and used correctly within the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new fields in WFQScheduler are initialized and used correctly.
ast-grep --lang go --pattern $'WFQScheduler { $$$ fairnessSeedUpdateTime: $_, fairnessSeed: $_, workloads: $_ $$$ }'

Length of output: 117



Script:

#!/bin/bash
# Find the constructor or initialization function for the WFQScheduler struct.
ast-grep --lang go --pattern $'func NewWFQScheduler($_) *WFQScheduler { $$$ }'

# Find the usage of the new fields in the methods of the WFQScheduler struct.
ast-grep --lang go --pattern $'func ($_ *WFQScheduler) $_($$$) { $$$ fairnessSeedUpdateTime: $_, $$$ }'
ast-grep --lang go --pattern $'func ($_ *WFQScheduler) $_($$$) { $$$ fairnessSeed: $_, $$$ }'
ast-grep --lang go --pattern $'func ($_ *WFQScheduler) $_($$$) { $$$ workloads: $_, $$$ }'

Length of output: 371



Script:

#!/bin/bash
# Broaden the search to find any occurrence of the new fields within the WFQScheduler struct's methods.
ast-grep --lang go --pattern $'func ($_ *WFQScheduler) $_($$$) { $$$ }' | grep -E 'fairnessSeedUpdateTime|fairnessSeed|workloads'

Length of output: 305



Script:

#!/bin/bash
# Directly check the constructor function NewWFQScheduler for initialization of the new fields.
rg "func NewWFQScheduler" -A 30 ./pkg/scheduler/wfq.go

# Check for any method that might update the fairnessSeedUpdateTime and fairnessSeed fields.
rg "fairnessSeedUpdateTime" ./pkg/scheduler/wfq.go
rg "fairnessSeed" ./pkg/scheduler/wfq.go

Length of output: 2036

* 269-291: The `Identifiers` method has been added to generate identifiers for workloads and flows. It's important to ensure that the hashing and identifier generation logic is sound and that the identifiers are unique and meaningful.
Verification successful

The Identifiers method exists within the WFQScheduler struct in the pkg/scheduler/wfq.go file. The method signature matches the one provided in the PR context, which means we have located the correct method. The next step is to verify the logic within the Identifiers method to ensure that it generates unique and meaningful identifiers.

Given that the method uses a combination of workloadLabel, priority, generation, and a hashed fairnessLabel (when provided) to generate the workloadID and flowID, the uniqueness is likely to be high. The use of xxhash for hashing and the conditional update of fairnessSeed based on time suggest that the method is designed to produce consistent yet unique identifiers for different inputs.

To further verify the uniqueness and meaningfulness of the identifiers, we would need to review the implementation details of the Identifiers method, which would include examining the logic for potential collisions and ensuring that the identifiers are constructed in a way that is consistent with the intended design.


The Identifiers method in the WFQScheduler struct generates two identifiers: workloadID and flowID. The workloadID is a combination of workloadLabel, priority, and generation, formatted into a string. This should ensure that the workloadID is unique for different combinations of its inputs.

For the flowID, when a fairnessLabel is provided, the method checks if the fairnessSeed needs to be updated (which it does every 5 minutes), then computes a hash using xxhash with the fairnessLabel and the fairnessSeed. It then uses a bitwise AND operation with NumFairnessQueues - 1 to get a fairnessQueueID, assuming NumFairnessQueues is a power of 2. This fairnessQueueID is appended to the workloadID to form the flowID. If no fairnessLabel is provided, the flowID is the same as the workloadID.

The use of a timestamp-based seed that changes periodically and a hash function suggests an attempt to distribute flows across different queues fairly and to avoid persistent unfairness. The combination of these elements should, in theory, provide unique and meaningful identifiers for workloads and flows.

However, without knowing the exact usage context and without running extensive tests, it's not possible to guarantee with absolute certainty that there will be no collisions or that the identifiers will always be meaningful. The method's logic appears sound based on the information provided, but practical implementation details such as the range of priority and generation values, the format and uniqueness of workloadLabel and fairnessLabel, and the actual value of NumFairnessQueues could affect the outcome.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the Identifiers method is used correctly and generates unique identifiers.
ast-grep --lang go --pattern $'func (sched *WFQScheduler) Identifiers($_, $_, $_, $_) ($_,$_){ $$$ }'

Length of output: 102



Script:

#!/bin/bash
# Search for the definition of the Identifiers method in the WFQScheduler struct
rg "func \(sched \*WFQScheduler\) Identifiers"

Length of output: 201



Script:

#!/bin/bash
# Extract the full implementation of the Identifiers method to verify its logic for generating unique and meaningful identifiers.
rg -A 20 "func \(sched \*WFQScheduler\) Identifiers" pkg/scheduler/wfq.go

Length of output: 1103

* 318-327: The `queueRequest` method has been modified to use the new `Identifiers` method and to initialize the `workloads` map. It's important to ensure that the logic for handling the `workloads` map is correct and that the map is updated appropriately.
  • 315-354: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [339-365]

The queueRequest method has been significantly modified to incorporate fairness adjustments and cost calculations. It's crucial to review the fairness adjustment logic and the impact on cost calculation to ensure that the fairness mechanism is implemented as intended.

Verification successful

The provided script output now includes the relevant section of the queueRequest method, which shows the fairness adjustment logic and cost calculation. The fairness adjustment is determined by the numFairnessQueues field of the workloadState struct, and the cost calculation takes into account the request.Tokens, request.InvPriority, and the fairnessAdjustment.

Based on the snippet provided, the fairness adjustment logic and cost calculation appear to be implemented as described in the PR objectives and AI-generated summary. The fairnessAdjustment is used to modify the cost of the request, which is consistent with the intention to implement a fairness mechanism within the workload scheduling.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the fairness adjustment logic and cost calculation in queueRequest are correct.
ast-grep --lang go --pattern $'func (sched *WFQScheduler) queueRequest($_, $_) ($_,$_){ $$$ }'

Length of output: 95



Script:

#!/bin/bash
# Adjusting the pattern to be more inclusive to find the queueRequest method in the WFQScheduler struct.
ast-grep --lang go --pattern $'func (sched *WFQScheduler) queueRequest($$$) {$$$}'

Length of output: 83



Script:

#!/bin/bash
# Using ripgrep to search for the queueRequest method within Go files.
rg 'func \(sched \*WFQScheduler\) queueRequest'

Length of output: 177



Script:

#!/bin/bash
# Extracting the queueRequest method implementation details to verify the fairness adjustment logic and cost calculation.
rg -A 20 'func \(sched \*WFQScheduler\) queueRequest' pkg/scheduler/wfq.go

Length of output: 710



Script:

#!/bin/bash
# Extracting more lines of the queueRequest method to review the fairness adjustment logic and cost calculation.
rg -A 30 'func \(sched \*WFQScheduler\) queueRequest' pkg/scheduler/wfq.go

Length of output: 1066



Script:

#!/bin/bash
# Extracting a larger portion of the queueRequest method to review the fairness adjustment logic and cost calculation in full.
rg -A 50 'func \(sched \*WFQScheduler\) queueRequest' pkg/scheduler/wfq.go

Length of output: 1574

* 417-417: The `onQueueExit` method in the `PreemptionMetrics` struct has been modified. It's important to ensure that the metrics are updated correctly when a request exits the queue, especially in the context of the new fairness feature.
Verification successful

Based on the script output, the onQueueExit method in the PreemptionMetrics struct has been verified to update metrics correctly when a request exits the queue. The method includes appropriate logic for handling metrics related to preemption and delay, which aligns with the context of the new fairness feature by utilizing the WorkloadLabel from the request.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the onQueueExit method updates metrics correctly.
ast-grep --lang go --pattern $'func (pMetrics *PreemptionMetrics) onQueueExit($_, $_) { $$$ }'

Length of output: 4545

* 533-539: The `cleanup` method has been modified to update the `workloads` map. It's important to ensure that the cleanup logic is correct and that the `workloads` map is updated appropriately when a flow is deleted.
Verification successful

The cleanup method in the WFQScheduler struct has been verified. It correctly decrements the numFairnessQueues counter for a given workloadID and removes the workloadID from the workloads map if the number of fairness queues reaches zero. This aligns with the intended functionality of updating the workloads map when a flow is deleted.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the cleanup method updates the workloads map correctly.
ast-grep --lang go --pattern $'func (sched *WFQScheduler) cleanup($_) { $$$ }'

Length of output: 1154

* 568-601: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [561-583]

The PreemptionMetrics struct and the NewPreemptionMetrics function have been introduced. It's important to review the initialization of this struct and ensure that the metrics are being created and used correctly.

Verification successful

The review comment has been verified. The PreemptionMetrics struct and the NewPreemptionMetrics function are introduced and used correctly in the code. The metrics are created in the pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go file and passed to the NewPreemptionMetrics function as parameters, which is consistent with proper initialization and usage. The preemptionMetrics struct is utilized in the pkg/scheduler/wfq.go file to track queue entries and exits, indicating that the metrics are being used as intended.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that PreemptionMetrics is initialized correctly and used throughout the code.
ast-grep --lang go --pattern $'NewPreemptionMetrics($_, $_, $_, $_)'

Length of output: 594



Script:

#!/bin/bash
# Verify the creation of the Prometheus metrics used in NewPreemptionMetrics
rg 'prometheus.NewSummaryVec|prometheus.NewCounterVec' -- 'pkg/scheduler/wfq.go'

# Verify the usage of preemptionMetrics in the code
rg 'preemptionMetrics' -- 'pkg/scheduler/wfq.go'

Length of output: 1081



Script:

#!/bin/bash
# Search for the creation of the Prometheus metrics across the entire codebase
rg 'prometheus.NewSummaryVec|prometheus.NewCounterVec'

Length of output: 4694

* 689-691: The `WFQMetrics` struct has been updated with new fields related to fairness. It's important to ensure that these new metrics are being registered and updated correctly in the code.
docs/content/reference/observability/prometheus-metrics/agent.md (1)
  • 255-268: The addition of the new fairness-related metrics (fairness_preempted_tokens, fairness_delayed_tokens, and fairness_on_time_total) is consistent with the PR's objective to introduce a fairness enforcement mechanism. Ensure that the descriptions for these metrics accurately reflect their purpose and that the labels are correctly documented for clarity and ease of use.
pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go (8)
  • 56-58: The addition of new fairness-related Prometheus metric vectors to the Factory struct aligns with the PR's objective to introduce a fairness enforcement mechanism. Ensure that these new metrics are properly documented and that their usage is consistent throughout the codebase.

  • 156-178: The new fairness metrics are registered in the Factory struct. It's important to verify that these metrics are being used correctly in the rest of the codebase and that they provide meaningful insights into the fairness enforcement mechanism.

  • 223-246: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [190-237]

The registration of the new fairness metrics within the OnStart lifecycle hook is correct. However, ensure that there is proper error handling and logging in place for scenarios where the registration might fail.

  • 280-291: The unregistration of the new fairness metrics within the OnStop lifecycle hook is correct. Similar to the registration process, ensure that there is proper error handling and logging for unregistration failures.

  • 354-356: The SchedulerMetrics struct now includes the new fairness metrics. It's crucial to ensure that these metrics are being updated correctly during the scheduling process to reflect the fairness enforcement accurately.

  • 406-417: The deletion of fairness metrics from the metric vectors is handled in the Delete method. It's important to verify that this deletion is triggered in the correct scenarios and that it doesn't lead to any resource leaks or inconsistencies in the metrics.

  • 472-483: The initialization of preempt metrics for fairness within the NewScheduler function is a critical part of the fairness feature. Ensure that the error messages are clear and that they provide enough context for debugging any issues that may arise.

  • 649-654: The Decide method has been updated to include a fairness label key. This change is essential for the fairness mechanism to function correctly. Ensure that the fairness label is being used appropriately in the scheduling decision process.

Verification successful

The extended context from the scheduler.go file provides a clear view of how the fairnessLabel is used within the Decide method. The fairnessLabel is extracted from the labels using the key specified in s.proto.FairnessLabelKey. If the key is present and has a value in the labels, that value is assigned to fairnessLabel. This label is then passed to the scheduler.NewRequest function along with other parameters like matchedWorkloadLabel, tokens, and invPriority.

The Decide method uses the fairnessLabel to create a new request object, which is then scheduled by calling s.scheduler.Schedule(reqCtx, req). The outcome of this scheduling decision, including whether the request was accepted and the remaining and current tokens, is encapsulated in the flowcontrolv1.LimiterDecision object that is returned from the Decide method.

Based on the provided context, it is evident that the fairnessLabel is indeed being used in the scheduling decision process as intended by the PR objectives. The label is retrieved from the incoming labels and is factored into the scheduling logic by the weighted fair queuing scheduler.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the fairness label is being used correctly in the scheduling decision process.
rg --type go 'fairnessLabel'

Length of output: 2656



Script:

#!/bin/bash
# Look at the Decide method in scheduler.go to see how fairnessLabel is used in making scheduling decisions.
rg --type go -A 30 'func \(.*Decide' pkg/scheduler/scheduler.go

Length of output: 65



Script:

#!/bin/bash
# Broad search for the Decide method across all .go files.
rg --type go -A 30 -B 2 'func \(.*\) Decide'

Length of output: 35984



Script:

#!/bin/bash
# Examine more of the Decide method in scheduler.go to understand how fairnessLabel is used within it.
rg --type go -C 50 'func \(s \*Scheduler\) Decide' pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go

Length of output: 3368



Script:

#!/bin/bash
# Continue examining the Decide method or related functions for the usage of fairnessLabel.
rg --type go -C 100 'fairnessLabel' pkg/policies/flowcontrol/actuators/workload-scheduler/scheduler.go

Length of output: 6881

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0d5eb84 and 859fe15.
Files ignored due to filter (1)
  • api/buf.lock
Files selected for processing (1)
  • .pre-commit-config.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • .pre-commit-config.yaml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 859fe15 and 99c26af.
Files ignored due to filter (2)
  • sdks/aperture-go/examples/manual/go.mod
  • sdks/aperture-go/examples/manual/go.sum
Files selected for processing (1)
  • pkg/scheduler/wfq.go (20 hunks)
Additional comments: 16
pkg/scheduler/wfq.go (16)
  • 8-12: The import of the github.com/cespare/xxhash package is noted. This package is typically used for fast hashing, which is likely related to the new fairness feature.

  • 44-45: The introduction of the NumFairnessQueues global variable is a significant change. It's important to ensure that this value is appropriately configured and that its usage throughout the code maintains thread safety, as global mutable state can lead to concurrency issues.

Verification successful

The verification process has confirmed that NumFairnessQueues is assigned only once upon its declaration and is not accessed within any goroutines or concurrent functions. This suggests that the usage of NumFairnessQueues is thread-safe within the current context of the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that NumFairnessQueues is used in a thread-safe manner throughout the codebase.
rg "NumFairnessQueues"

Length of output: 245



Script:

#!/bin/bash
# Search for assignments to NumFairnessQueues after its initial declaration.
rg "NumFairnessQueues\s*=" --vimgrep

# Search for usage within goroutines or concurrent functions to identify potential concurrent access patterns.
rg "go\s*.*NumFairnessQueues" --vimgrep

Length of output: 134

* 23-33: The `queuedRequest` struct has been expanded with new fields related to fairness, such as `workloadState`, `workloadPreemptionCounters`, and `fairnessPreemptionCounters`. It's crucial to ensure that these new fields are properly initialized and managed throughout the lifecycle of a `queuedRequest`.
  • 140-144: The WorkloadState struct has been added, which includes preemptionMetrics and numFairnessQueues. This struct seems to be part of the new fairness mechanism, and it's important to ensure that it is correctly integrated into the WFQScheduler.

  • 148-167: The WFQScheduler struct has been significantly modified with the addition of fairnessSeedUpdateTime, fairnessSeed, and a workloads map. These changes are central to the new fairness feature. It's important to review the initialization and usage of these fields to ensure they are handled correctly, especially with regard to concurrency.

  • 176-190: The NewWFQScheduler function has been updated to initialize the new fields in the WFQScheduler struct. It's important to ensure that the initialization logic is correct and that the new fields are set to sensible default values.

  • 273-298: The Identifiers method has been added to the WFQScheduler struct. This method is responsible for generating identifiers for workloads and flows based on the new fairness mechanism. It's important to review this method for correctness, especially the hashing logic and the use of rand.Uint32(), which should be scrutinized for potential concurrency issues.

  • 323-332: The queueRequest method has been modified to use the new Identifiers method and to interact with the workloads map. It's important to ensure that the logic for handling the workloads map is thread-safe and that the WorkloadState objects are managed correctly.

  • 320-359: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [352-370]

The fairness adjustment logic within the queueRequest method has been modified. It's crucial to review this logic to ensure that it correctly implements the intended fairness mechanism and that the cost calculation is accurate.

  • 422-422: The onQueueExit method in the PreemptionMetrics struct has been modified to update metrics related to preemption and delay. It's important to ensure that the metrics are updated correctly and that the logic for calculating preemption and delay is accurate.

  • 460-476: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [469-517]

The cancelRequest method has been modified to interact with the new fairness-related fields and metrics. It's important to review this method to ensure that requests are canceled correctly and that the fairness-related state is updated appropriately.

  • 538-544: The cleanup method has been modified to update the workloads map and decrement the numFairnessQueues counter. It's important to ensure that the cleanup logic is correct and that the workloads map is managed in a thread-safe manner.

  • 573-604: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [566-588]

The PreemptionMetrics struct and the NewPreemptionMetrics function have been added to handle new metrics related to preemption and delay. It's important to review these additions to ensure that they are integrated correctly with the rest of the metrics system.

  • 593-595: The onQueueEntry method in the PreemptionMetrics struct has been added to maintain token counters for calculating preemption and delay metrics. It's important to ensure that this method is called at the correct times and that the token counters are updated accurately.

  • 620-626: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [601-655]

The onQueueExit method in the PreemptionMetrics struct has been modified to update metrics for preemption and delay. It's important to review the logic for initializing metrics and publishing summary and counter updates to ensure that it is correct and that the metrics reflect the intended behavior.

  • 692-694: The WFQMetrics struct has been expanded with new fields for fairness-related metrics. It's important to ensure that these new fields are used correctly throughout the code and that the metrics they represent are updated appropriately.

@tanveergill tanveergill merged commit 243418a into main Jan 10, 2024
23 of 25 checks passed
@tanveergill tanveergill deleted the tgill/fairness branch January 10, 2024 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants