Skip to content

Commit d15539f

Browse files
committed
Added more comments
Signed-off-by: Sriram Ganesh <[email protected]>
1 parent 38138d2 commit d15539f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

server/src/main/java/org/opensearch/index/AdaptiveTieredMergePolicyProvider.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* This addresses the issue described in https://github.com/opensearch-project/OpenSearch/issues/11163
2323
* by providing more intelligent default merge settings that adapt to the actual shard size.
2424
*
25+
* Implementation notes:
26+
* - Uses smooth interpolation (log/linear across size decades) instead of hard categories
27+
* to avoid abrupt parameter jumps as shards grow.
28+
* - Caps the max merged segment size at 5GB to align with Lucene defaults.
29+
*
2530
* @opensearch.api
2631
*/
2732
@PublicApi(since = "3.3.0")
@@ -41,6 +46,7 @@ public class AdaptiveTieredMergePolicyProvider implements MergePolicyProvider {
4146
private static final ByteSizeValue SMALL_SHARD_MAX_SEGMENT = new ByteSizeValue(50, ByteSizeUnit.MB);
4247
private static final ByteSizeValue MEDIUM_SHARD_MAX_SEGMENT = new ByteSizeValue(200, ByteSizeUnit.MB);
4348
private static final ByteSizeValue LARGE_SHARD_MAX_SEGMENT = new ByteSizeValue(1, ByteSizeUnit.GB);
49+
// Cap aligned with Lucene default (5GB)
4450
private static final ByteSizeValue VERY_LARGE_SHARD_MAX_SEGMENT = new ByteSizeValue(5, ByteSizeUnit.GB);
4551

4652
// Adaptive floor segment sizes
@@ -115,7 +121,7 @@ private long estimateShardSize() {
115121
}
116122
try {
117123
// Try to get a rough estimate of shard size from the store
118-
// This is a best-effort estimation - using directory size as proxy
124+
// Best-effort approximation using directory listing as proxy (not exact)
119125
return store.directory().listAll().length * 1024 * 1024; // Rough estimate
120126
} catch (Exception e) {
121127
// Fallback to a reasonable default
@@ -136,7 +142,8 @@ private ShardSizeCategory categorizeShardSize(long sizeBytes) {
136142
}
137143

138144
private void applyAdaptiveSettings(ShardSizeCategory category) {
139-
// Use smooth interpolation instead of discrete categories to avoid dramatic parameter jumps
145+
// Use smooth interpolation instead of discrete categories to avoid dramatic parameter jumps.
146+
// The category is retained for logging/backward-compatibility but does not gate the settings below.
140147
long shardSizeBytes = estimateShardSize();
141148

142149
ByteSizeValue maxSegmentSize = calculateSmoothMaxSegmentSize(shardSizeBytes);
@@ -164,7 +171,7 @@ private void applyAdaptiveSettings(ShardSizeCategory category) {
164171

165172
/**
166173
* Calculate smooth max segment size using logarithmic interpolation
167-
* to avoid dramatic jumps at category boundaries
174+
* to avoid dramatic jumps at category boundaries. Values are capped at 5GB.
168175
*/
169176
private ByteSizeValue calculateSmoothMaxSegmentSize(long shardSizeBytes) {
170177
// Use logarithmic interpolation between reference points

server/src/main/java/org/opensearch/index/analysis/SegmentTopologyAnalyzer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
* This addresses the problem described in:
2828
* https://github.com/opensearch-project/OpenSearch/issues/11163
2929
*
30+
* Implementation notes:
31+
* - Recommendations use smooth interpolation across shard-size decades to avoid
32+
* stepwise jumps at category thresholds.
33+
* - Max segment size recommendations are capped at 5GB to align with Lucene.
34+
*
3035
* @opensearch.api
3136
*/
3237
@PublicApi(since = "3.3.0")
@@ -174,7 +179,7 @@ private long calculateRecommendedMaxSegmentSize() {
174179

175180
/**
176181
* Calculate smooth max segment size using logarithmic interpolation
177-
* to avoid dramatic jumps at category boundaries
182+
* to avoid dramatic jumps at category boundaries. Values are capped at 5GB.
178183
*/
179184
private long calculateSmoothMaxSegmentSize(long shardSizeBytes) {
180185
// Reference points: 50MB@100MB, 200MB@1GB, 1GB@10GB, 5GB@100GB

0 commit comments

Comments
 (0)