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
0 commit comments