Skip to content

Conversation

peteralfonsi
Copy link
Contributor

Description

Adds convenience methods allowing min/max values for MemorySizeSetting (settings which are parsed from either byte value strings like "500kb" or percentages of the total heap size like "1%"). The min/max arguments are strings which are parsed by the same parser as the default value, so they can also be either byte value strings or percentage strings.

Related Issues

Didn't raise an issue for this as it's pretty minor, but came up in review for #19152. Separated it out as it was not really that related to the original PR and required its own tests, etc.

Check List

  • Functionality includes testing.
  • [N/A] API changes companion pull request created, if applicable.
  • [N/A] Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@peteralfonsi peteralfonsi requested a review from a team as a code owner September 3, 2025 20:23
Signed-off-by: Peter Alfonsi <[email protected]>
public static Setting<ByteSizeValue> memorySizeSetting(
String key,
String defaultPercentage,
String minPercentage,
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if there are really any real use cases of specifying the minPercentage for memorySizeSetting. Why would be make something use minimum memory, the objective is mostly limiting the maximum amount of consumed memory by a component. Probably, that is the reason we never required explicit min/max and the default value kind of served as the maximum limit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd be ok with just having it be maximum. However while checking I did find one setting BlobStoreRepository.SNAPSHOT_REPOSITORY_DATA_CACHE_THRESHOLD (link) where they shove the parser logic into a lambda in the setting definition themselves, so that they can define a nonzero minimum of 500b, and a maximum of 0.01% of heap, so I guess there is at least some use case for a minimum memory setting.

Copy link
Contributor

Choose a reason for hiding this comment

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

That still seems like arbitrary low value to me, not minimum threshold that user really needs to set. Maybe we can assume nonzero minimum of 500b as the hardcoded minimum for memorySizeSetting. Are you planning to use any different value for fielddatacache use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems strange to add an arbitrary 500 mb floor for a convenience method, right? Shouldn't we just make it as general as possible and users can choose what floor they need? Either that or only having maximum with a minimum of 0 makes sense to me.

Copy link
Contributor

github-actions bot commented Sep 3, 2025

❌ Gradle check result for 9dc7c6b: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Peter Alfonsi <[email protected]>
Copy link
Contributor

github-actions bot commented Sep 4, 2025

✅ Gradle check result for cd44c41: SUCCESS

Copy link

codecov bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.84%. Comparing base (074b9d3) to head (cd44c41).
⚠️ Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/org/opensearch/common/settings/Setting.java 78.57% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19230      +/-   ##
============================================
+ Coverage     72.80%   72.84%   +0.04%     
- Complexity    69599    69678      +79     
============================================
  Files          5656     5656              
  Lines        320002   320027      +25     
  Branches      46338    46343       +5     
============================================
+ Hits         232968   233132     +164     
+ Misses        68140    68042      -98     
+ Partials      18894    18853      -41     

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants