Skip to content

feat(manager): support preheating by percentage#4053

Merged
gaius-qi merged 1 commit intomainfrom
feature/preheat
May 12, 2025
Merged

feat(manager): support preheating by percentage#4053
gaius-qi merged 1 commit intomainfrom
feature/preheat

Conversation

@gaius-qi
Copy link
Copy Markdown
Member

Description

This pull request introduces a new feature to support preheating a configurable percentage of peers or seed peers in the job scheduler. The changes include adding a Percentage field to relevant data structures, updating logic to handle percentage-based selection, and introducing utility methods for selecting peers based on the specified percentage.

Feature: Percentage-based Preheating

  • Added Percentage Field to Data Structures:

    • Introduced a Percentage field in PreheatRequest and PreheatArgs structs to specify the percentage of peers or seed peers to preheat. This field is validated to accept values between 1 and 100. (internal/job/types.go [1] manager/types/job.go [2]
  • Updated Preheat Logic:

    • Incorporated the Percentage field into the preheat logic in methods like CreatePreheat and parseLayers, ensuring the percentage value is passed through the workflow. (manager/job/preheat.go [1] [2]
  • Implemented Peer Selection Utilities:

    • Added selectSeedPeers and selectPeers utility functions to select a subset of seed peers or peers based on the specified percentage. These methods ensure at least one peer is selected if the percentage is greater than zero. (scheduler/job/job.go [1] [2]

Code Refactoring

  • Removed Redundant Checks:

    • Removed redundant checks for seed peer availability in preheatAllSeedPeers and preheatAllPeers, replacing them with calls to the new peer selection utilities. (scheduler/job/job.go [1] [2]
  • Updated Imports:

Related Issue

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@gaius-qi gaius-qi added this to the v2.3.0 milestone May 12, 2025
@gaius-qi gaius-qi requested a review from Copilot May 12, 2025 03:49
@gaius-qi gaius-qi self-assigned this May 12, 2025
@gaius-qi gaius-qi requested a review from a team as a code owner May 12, 2025 03:49
@gaius-qi gaius-qi added the enhancement New feature or request label May 12, 2025
Copy link
Copy Markdown

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 pull request introduces a percentage-based preheating feature by adding a Percentage field and updating related peer selection logic. Key changes include:

  • Adding Percentage field to PreheatRequest, PreheatArgs, and related structures.
  • Updating preheat logic to use new selectSeedPeers and selectPeers utilities for percentage-based selection.
  • Propagating the Percentage field in the preheat workflow via updated utility methods and refactored control flow.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
scheduler/job/job.go Refactored seed and peer selection to implement percentage-based selection logic.
manager/types/job.go Added the Percentage field with validation rules.
manager/job/preheat.go Updated preheat functions to pass along the Percentage field.
internal/job/types.go Added the Percentage field to the preheat request structure.
Comments suppressed due to low confidence (1)

Comment thread scheduler/job/job.go
Comment thread scheduler/job/job.go
Signed-off-by: Gaius <gaius.qi@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2025

Codecov Report

Attention: Patch coverage is 2.22222% with 44 lines in your changes missing coverage. Please review.

Project coverage is 34.31%. Comparing base (80d109e) to head (c4d2803).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
scheduler/job/job.go 0.00% 43 Missing ⚠️
manager/job/preheat.go 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4053      +/-   ##
==========================================
- Coverage   34.40%   34.31%   -0.10%     
==========================================
  Files         344      344              
  Lines       40299    40334      +35     
==========================================
- Hits        13866    13841      -25     
- Misses      25520    25575      +55     
- Partials      913      918       +5     
Flag Coverage Δ
unittests 34.31% <2.22%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
manager/job/preheat.go 44.05% <50.00%> (+0.04%) ⬆️
scheduler/job/job.go 0.00% <0.00%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@gaius-qi gaius-qi enabled auto-merge (squash) May 12, 2025 04:14
@gaius-qi gaius-qi merged commit ff59f21 into main May 12, 2025
28 of 36 checks passed
@gaius-qi gaius-qi deleted the feature/preheat branch May 12, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants