Skip to content

Use hashing for targets list comparison and enable scheduler tests #11870

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

Conversation

YuliiaKovalova
Copy link
Member

@YuliiaKovalova YuliiaKovalova commented May 20, 2025

Context

AssignGlobalRequestId is a critical method in Scheduler. This change attempts to optimize the scenario in it.

Changes Made

Switch from 2 string list comparison to hashset against the second list of strings.

Testing

Covered by existing tests.

@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 12:44
@YuliiaKovalova YuliiaKovalova self-assigned this May 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the way AssignGlobalRequestId matches target lists by using hash-based comparison and re-enables previously skipped scheduler tests.

  • Replaced sorting-based list comparison in AssignGlobalRequestId with ComputeTargetsHash and TargetsMatch helpers
  • Adjusted early exit and new-ID assignment logic
  • Enabled all scheduler unit tests by removing [Fact(Skip=…)] attributes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Build/BackEnd/Components/Scheduler/Scheduler.cs Swapped list sorting for hash checks, added hashing/matching methods, and updated assignment logic
src/Build.UnitTests/BackEnd/Scheduler_Tests.cs Removed Skip on [Fact] attributes to enable scheduler tests
Comments suppressed due to low confidence (2)

src/Build/BackEnd/Components/Scheduler/Scheduler.cs:2249

  • The combined condition incorrectly reassigns a new GlobalRequestId even when one is already set. Consider first returning immediately if GlobalRequestId is already valid, then handling the case where there are no existing requests separately.
if (request.GlobalRequestId != BuildRequest.InvalidGlobalRequestId || _schedulingData.GetRequestsAssignedToConfigurationCount(request.ConfigurationId) == 0)

src/Build.UnitTests/BackEnd/Scheduler_Tests.cs:104

  • The new ComputeTargetsHash and TargetsMatch methods introduce order‐ and case‐agnostic comparisons that aren’t explicitly tested. Add unit tests covering varied target orders and casing to ensure correctness.
[Fact]

@YuliiaKovalova YuliiaKovalova requested a review from Erarndt May 20, 2025 12:57
@YuliiaKovalova YuliiaKovalova requested a review from surayya-MS May 20, 2025 16:15
Copy link
Member

@surayya-MS surayya-MS left a comment

Choose a reason for hiding this comment

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

Looks great!

@YuliiaKovalova YuliiaKovalova merged commit 585b873 into dotnet:main May 29, 2025
10 checks passed
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.

4 participants