Skip to content

feat(cfg): add safe configuration and storage API for MRD connection pool autoscaling#4739

Open
PranjalC100 wants to merge 3 commits into
masterfrom
pr1-mrd-config-storage-api
Open

feat(cfg): add safe configuration and storage API for MRD connection pool autoscaling#4739
PranjalC100 wants to merge 3 commits into
masterfrom
pr1-mrd-config-storage-api

Conversation

@PranjalC100

@PranjalC100 PranjalC100 commented May 27, 2026

Copy link
Copy Markdown
Member

Description

This PR introduces the new configuration parameters, validation logic, and storage layer interface fields for the Multi-Range Downloader (MRD) connection pool autoscaling feature.

Specifically, it adds:

  • mrd.target-pending-bytes (hidden): The target threshold for pending bytes to trigger autoscaling.
  • mrd.target-pending-ranges (hidden): The target threshold for pending ranges to trigger autoscaling.

Note: In this simplified approach, the min-connections and max-connections configuration options are not exposed to the user. Instead:

  • min-connections defaults to 1 internally.
  • max-connections defaults to the user-configured mrd.pool-size.
    This ensures that the connection pool autoscaling behavior is controlled safely through the existing pool-size config.

Default Values

If the user does not explicitly override the settings, GCSFuse defaults to the following autoscaling parameters:

  • mrd.pool-size (acting as maximum connections): 4
  • Minimum connections: 1
  • mrd.target-pending-ranges: 20
  • mrd.target-pending-bytes: 10MB (10,485,760 bytes)

This PR is the first of a multi-part series splitting the overall connection pool autoscaling implementation. It is purely declarative and safe; because these fields are not yet wired up in the downloader wrapper or instance code, they have zero functional runtime impact on existing codepaths.

Link to the issue in case of a bug fix.

b/504489809

Testing details

  1. Manual - Verified clean compilation of the entire codebase (go build ./... and basic layout validation).
  2. Unit tests - Verified that all cfg package unit tests pass successfully, covering the new configuration boundaries and combinations.
  3. Integration tests - NA

Any backward incompatible change? If so, please explain.

N/A

@PranjalC100 PranjalC100 added execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. labels May 27, 2026
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.68%. Comparing base (0ac71b7) to head (0522490).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4739      +/-   ##
==========================================
- Coverage   83.69%   83.68%   -0.01%     
==========================================
  Files         168      168              
  Lines       20782    20796      +14     
==========================================
+ Hits        17393    17403      +10     
- Misses       2740     2743       +3     
- Partials      649      650       +1     
Flag Coverage Δ
unittests 83.68% <100.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@PranjalC100 PranjalC100 force-pushed the pr1-mrd-config-storage-api branch from a45d385 to f043adf Compare June 9, 2026 10:19
@PranjalC100 PranjalC100 requested a review from abhishek10004 June 9, 2026 10:19
@PranjalC100 PranjalC100 marked this pull request as ready for review June 9, 2026 10:19
@PranjalC100 PranjalC100 requested a review from a team as a code owner June 9, 2026 10:19
@github-actions github-actions Bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Jun 9, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes the foundational configuration and validation framework for the Multi-Range Downloader (MRD) connection pool autoscaling feature. By introducing new configuration parameters and updating the storage request interface, this change sets the stage for future implementation of dynamic connection management while ensuring that all new settings are safely validated at the configuration level.

Highlights

  • Configuration Schema Update: Added new configuration fields for MRD connection pool autoscaling, including min/max connections and target thresholds for pending bytes and ranges.
  • Validation Logic: Implemented validation rules to ensure autoscaling parameters are non-negative and logically consistent (e.g., min connections cannot exceed max connections).
  • Storage Interface: Updated the MultiRangeDownloaderRequest struct to include the new autoscaling settings, preparing the storage layer for future implementation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new configuration parameters for Multi-Range Downloader (MRD) autoscaling, including minimum/maximum connections and target pending bytes/ranges, along with their command-line flags, validation logic, and unit tests. The feedback suggests strengthening the validation logic to enforce consistency checks—specifically ensuring that MaxConnections is specified when scaling triggers are set, and that at least one scaling trigger is provided when the connection pool is dynamic—and adding corresponding unit tests for these new validation rules.

Comment thread cfg/validate.go Outdated
Comment thread cfg/validate_test.go Outdated
@github-actions

Copy link
Copy Markdown

Hi @abhishek10004, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@PranjalC100 PranjalC100 force-pushed the pr1-mrd-config-storage-api branch from 23776fc to 3016fde Compare June 10, 2026 12:32
@PranjalC100

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces configuration parameters (TargetPendingBytes and TargetPendingRanges) for Multi-Range Downloader (MRD) autoscaling, including command-line flags, YAML parameters, validation logic, and unit tests. A bug was identified in the configuration rationalization logic (resolveMrdConfig) where explicitly setting mrd-target-pending-ranges to its default value of 20 would incorrectly trigger the fallback logic for TargetPendingBytes. A cleaner implementation using v.IsSet directly was suggested to resolve this issue.

Comment thread cfg/rationalize.go
@PranjalC100 PranjalC100 force-pushed the pr1-mrd-config-storage-api branch from 3016fde to 0522490 Compare June 10, 2026 12:51
@PranjalC100

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new configuration parameters, target-pending-bytes and target-pending-ranges, for the Multi-Range Downloader (MRD) to support multistream autoscaling. These parameters are exposed as hidden command-line flags, integrated into the configuration rationalization and validation processes, and added to the MRD request structure. The review feedback suggests using flagSet.Int64P instead of flagSet.IntP to avoid potential value truncation on 32-bit systems since the underlying struct fields are int64. Additionally, it is recommended to simplify the default value resolution logic in resolveMrdConfig to ensure consistent and predictable behavior when only one of the parameters is configured.

Comment thread cfg/config.go
Comment on lines +1280 to +1290
flagSet.IntP("mrd-target-pending-bytes", "", 10485760, "The target threshold for pending bytes to trigger Multi-Range Downloader autoscaling.")

if err := flagSet.MarkHidden("mrd-target-pending-bytes"); err != nil {
return err
}

flagSet.IntP("mrd-target-pending-ranges", "", 20, "The target threshold for pending ranges to trigger Multi-Range Downloader autoscaling.")

if err := flagSet.MarkHidden("mrd-target-pending-ranges"); err != nil {
return err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The flags mrd-target-pending-bytes and mrd-target-pending-ranges are defined using flagSet.IntP, which corresponds to an int type. However, the associated fields in the MrdConfig struct (TargetPendingBytes and TargetPendingRanges) are of type int64.

On a 32-bit system, an int is 32 bits, which could lead to value truncation if a user provides a value larger than math.MaxInt32.

To ensure correctness and prevent potential data loss on 32-bit architectures, it's better to use flagSet.Int64P, which corresponds to the int64 type of the struct fields.

Suggested change
flagSet.IntP("mrd-target-pending-bytes", "", 10485760, "The target threshold for pending bytes to trigger Multi-Range Downloader autoscaling.")
if err := flagSet.MarkHidden("mrd-target-pending-bytes"); err != nil {
return err
}
flagSet.IntP("mrd-target-pending-ranges", "", 20, "The target threshold for pending ranges to trigger Multi-Range Downloader autoscaling.")
if err := flagSet.MarkHidden("mrd-target-pending-ranges"); err != nil {
return err
}
flagSet.Int64P("mrd-target-pending-bytes", "", 10485760, "The target threshold for pending bytes to trigger Multi-Range Downloader autoscaling.")
if err := flagSet.MarkHidden("mrd-target-pending-bytes"); err != nil {
return err
}
flagSet.Int64P("mrd-target-pending-ranges", "", 20, "The target threshold for pending ranges to trigger Multi-Range Downloader autoscaling.")
if err := flagSet.MarkHidden("mrd-target-pending-ranges"); err != nil {
return err
}

Comment thread cfg/rationalize.go
Comment on lines +169 to +180
func resolveMrdConfig(v *viper.Viper, c *MrdConfig) {
if !v.IsSet("mrd.target-pending-ranges") && c.TargetPendingRanges == 0 {
if c.TargetPendingBytes == 0 {
c.TargetPendingRanges = 20
}
}
if !v.IsSet("mrd.target-pending-bytes") && c.TargetPendingBytes == 0 {
if c.TargetPendingRanges == 0 || c.TargetPendingRanges == 20 {
c.TargetPendingBytes = 10 * 1024 * 1024 // 10MB
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic in resolveMrdConfig for setting default values is complex and has an asymmetric behavior that could be confusing for users.

Specifically:

  • If a user sets mrd.target-pending-ranges to its default value (20) but not mrd.target-pending-bytes, then mrd.target-pending-bytes is automatically set to its default of 10MB.
  • However, if a user sets mrd.target-pending-bytes to its default (10MB) but not mrd.target-pending-ranges, mrd.target-pending-ranges remains 0.

This inconsistency is unintuitive. A simpler and more predictable approach is to set both defaults only when neither parameter is configured by the user. This makes the behavior consistent.

Here is a suggested simplification that passes all existing tests and removes the asymmetry:

Suggested change
func resolveMrdConfig(v *viper.Viper, c *MrdConfig) {
if !v.IsSet("mrd.target-pending-ranges") && c.TargetPendingRanges == 0 {
if c.TargetPendingBytes == 0 {
c.TargetPendingRanges = 20
}
}
if !v.IsSet("mrd.target-pending-bytes") && c.TargetPendingBytes == 0 {
if c.TargetPendingRanges == 0 || c.TargetPendingRanges == 20 {
c.TargetPendingBytes = 10 * 1024 * 1024 // 10MB
}
}
}
func resolveMrdConfig(v *viper.Viper, c *MrdConfig) {
rangesSet := v.IsSet("mrd.target-pending-ranges")
bytesSet := v.IsSet("mrd.target-pending-bytes")
// If neither is set by the user (e.g. not in config file), and they have
// their zero values, set them to the defaults. This handles cases where
// config is not from flags, which have their own defaults.
if !rangesSet && !bytesSet && c.TargetPendingRanges == 0 && c.TargetPendingBytes == 0 {
c.TargetPendingRanges = 20
c.TargetPendingBytes = 10 * 1024 * 1024 // 10MB
}
}

@github-actions

Copy link
Copy Markdown

Hi @abhishek10004, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

3 similar comments
@github-actions

Copy link
Copy Markdown

Hi @abhishek10004, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@github-actions

Copy link
Copy Markdown

Hi @abhishek10004, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@github-actions

Copy link
Copy Markdown

Hi @abhishek10004, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests execute-integration-tests-on-zb To run E2E tests on zonal bucket. remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant