Browse Source

[ML] Rename increased_memory_estimate_bytes (#58614)

... to memory_reestimate_bytes in DF Analytics
memory usage.

Relates #58588
Dimitris Athanasiou 5 years ago
parent
commit
96853df6af

+ 12 - 12
client/rest-high-level/src/main/java/org/elasticsearch/client/ml/dataframe/stats/common/MemoryUsage.java

@@ -38,7 +38,7 @@ public class MemoryUsage implements ToXContentObject {
     static final ParseField TIMESTAMP = new ParseField("timestamp");
     static final ParseField PEAK_USAGE_BYTES = new ParseField("peak_usage_bytes");
     static final ParseField STATUS = new ParseField("status");
-    static final ParseField INCREASED_MEMORY_ESTIMATE_BYTES = new ParseField("increased_memory_estimate_bytes");
+    static final ParseField MEMORY_REESTIMATE_BYTES = new ParseField("memory_reestimate_bytes");
 
     public static final ConstructingObjectParser<MemoryUsage, Void> PARSER = new ConstructingObjectParser<>("analytics_memory_usage",
         true, a -> new MemoryUsage((Instant) a[0], (long) a[1], (Status) a[2], (Long) a[3]));
@@ -55,20 +55,20 @@ public class MemoryUsage implements ToXContentObject {
             }
             throw new IllegalArgumentException("Unsupported token [" + p.currentToken() + "]");
         }, STATUS, ObjectParser.ValueType.STRING);
-        PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), INCREASED_MEMORY_ESTIMATE_BYTES);
+        PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), MEMORY_REESTIMATE_BYTES);
     }
 
     @Nullable
     private final Instant timestamp;
     private final long peakUsageBytes;
     private final Status status;
-    private final Long increasedMemoryEstimateBytes;
+    private final Long memoryReestimateBytes;
 
-    public MemoryUsage(@Nullable Instant timestamp, long peakUsageBytes, Status status, @Nullable Long increasedMemoryEstimateBytes) {
+    public MemoryUsage(@Nullable Instant timestamp, long peakUsageBytes, Status status, @Nullable Long memoryReestimateBytes) {
         this.timestamp = timestamp == null ? null : Instant.ofEpochMilli(Objects.requireNonNull(timestamp).toEpochMilli());
         this.peakUsageBytes = peakUsageBytes;
         this.status = status;
-        this.increasedMemoryEstimateBytes = increasedMemoryEstimateBytes;
+        this.memoryReestimateBytes = memoryReestimateBytes;
     }
 
     @Nullable
@@ -84,8 +84,8 @@ public class MemoryUsage implements ToXContentObject {
         return status;
     }
 
-    public Long getIncreasedMemoryEstimateBytes() {
-        return increasedMemoryEstimateBytes;
+    public Long getMemoryReestimateBytes() {
+        return memoryReestimateBytes;
     }
 
     @Override
@@ -96,8 +96,8 @@ public class MemoryUsage implements ToXContentObject {
         }
         builder.field(PEAK_USAGE_BYTES.getPreferredName(), peakUsageBytes);
         builder.field(STATUS.getPreferredName(), status);
-        if (increasedMemoryEstimateBytes != null) {
-            builder.field(INCREASED_MEMORY_ESTIMATE_BYTES.getPreferredName(), increasedMemoryEstimateBytes);
+        if (memoryReestimateBytes != null) {
+            builder.field(MEMORY_REESTIMATE_BYTES.getPreferredName(), memoryReestimateBytes);
         }
         builder.endObject();
         return builder;
@@ -112,12 +112,12 @@ public class MemoryUsage implements ToXContentObject {
         return Objects.equals(timestamp, other.timestamp)
             && peakUsageBytes == other.peakUsageBytes
             && Objects.equals(status, other.status)
-            && Objects.equals(increasedMemoryEstimateBytes, other.increasedMemoryEstimateBytes);
+            && Objects.equals(memoryReestimateBytes, other.memoryReestimateBytes);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(timestamp, peakUsageBytes, status, increasedMemoryEstimateBytes);
+        return Objects.hash(timestamp, peakUsageBytes, status, memoryReestimateBytes);
     }
 
     @Override
@@ -126,7 +126,7 @@ public class MemoryUsage implements ToXContentObject {
             .add(TIMESTAMP.getPreferredName(), timestamp == null ? null : timestamp.getEpochSecond())
             .add(PEAK_USAGE_BYTES.getPreferredName(), peakUsageBytes)
             .add(STATUS.getPreferredName(), status)
-            .add(INCREASED_MEMORY_ESTIMATE_BYTES.getPreferredName(), increasedMemoryEstimateBytes)
+            .add(MEMORY_REESTIMATE_BYTES.getPreferredName(), memoryReestimateBytes)
             .toString();
     }
 

+ 1 - 1
client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java

@@ -1539,7 +1539,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
         assertThat(progress.get(3), equalTo(new PhaseProgress("writing_results", 0)));
         assertThat(stats.getMemoryUsage().getPeakUsageBytes(), equalTo(0L));
         assertThat(stats.getMemoryUsage().getStatus(), equalTo(MemoryUsage.Status.OK));
-        assertThat(stats.getMemoryUsage().getIncreasedMemoryEstimateBytes(), is(nullValue()));
+        assertThat(stats.getMemoryUsage().getMemoryReestimateBytes(), is(nullValue()));
         assertThat(stats.getDataCounts(), equalTo(new DataCounts(0, 0, 0)));
     }
 

+ 1 - 1
client/rest-high-level/src/test/java/org/elasticsearch/client/ml/dataframe/stats/common/MemoryUsageTests.java

@@ -55,6 +55,6 @@ public class MemoryUsageTests extends AbstractXContentTestCase<MemoryUsage> {
     public void testToString_GivenNullTimestamp() {
         MemoryUsage memoryUsage = new MemoryUsage(null, 42L, MemoryUsage.Status.OK, null);
         assertThat(memoryUsage.toString(), equalTo(
-            "MemoryUsage[timestamp=null, peak_usage_bytes=42, status=ok, increased_memory_estimate_bytes=null]"));
+            "MemoryUsage[timestamp=null, peak_usage_bytes=42, status=ok, memory_reestimate_bytes=null]"));
     }
 }

+ 5 - 0
docs/reference/ml/df-analytics/apis/get-dfanalytics-stats.asciidoc

@@ -431,6 +431,11 @@ job is started and memory usage is reported.
 .Properties of `memory_usage`
 [%collapsible%open]
 =====
+`memory_reestimate_bytes`::::
+(long)
+This value is present when the `status` is `hard_limit` and it
+is a new estimate of how much memory the job needs.
+
 `peak_usage_bytes`::::
 (long)
 The number of bytes used at the highest peak of memory usage.

+ 12 - 12
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/dataframe/stats/common/MemoryUsage.java

@@ -33,7 +33,7 @@ public class MemoryUsage implements Writeable, ToXContentObject {
 
     public static final ParseField PEAK_USAGE_BYTES = new ParseField("peak_usage_bytes");
     public static final ParseField STATUS = new ParseField("status");
-    public static final ParseField INCREASED_MEMORY_ESTIMATE_BYTES = new ParseField("increased_memory_estimate_bytes");
+    public static final ParseField MEMORY_REESTIMATE_BYTES = new ParseField("memory_reestimate_bytes");
 
     public static final ConstructingObjectParser<MemoryUsage, Void> STRICT_PARSER = createParser(false);
     public static final ConstructingObjectParser<MemoryUsage, Void> LENIENT_PARSER = createParser(true);
@@ -55,7 +55,7 @@ public class MemoryUsage implements Writeable, ToXContentObject {
             }
             throw new IllegalArgumentException("Unsupported token [" + p.currentToken() + "]");
         }, STATUS, ObjectParser.ValueType.STRING);
-        parser.declareLong(ConstructingObjectParser.optionalConstructorArg(), INCREASED_MEMORY_ESTIMATE_BYTES);
+        parser.declareLong(ConstructingObjectParser.optionalConstructorArg(), MEMORY_REESTIMATE_BYTES);
         return parser;
     }
 
@@ -66,7 +66,7 @@ public class MemoryUsage implements Writeable, ToXContentObject {
     private final Instant timestamp;
     private final long peakUsageBytes;
     private final Status status;
-    @Nullable private final Long increasedMemoryEstimateBytes;
+    @Nullable private final Long memoryReestimateBytes;
 
     /**
      * Creates a zero usage object
@@ -76,7 +76,7 @@ public class MemoryUsage implements Writeable, ToXContentObject {
     }
 
     public MemoryUsage(String jobId, Instant timestamp, long peakUsageBytes, @Nullable Status status,
-                       @Nullable Long increasedMemoryEstimateBytes) {
+                       @Nullable Long memoryReestimateBytes) {
         this.jobId = Objects.requireNonNull(jobId);
         // We intend to store this timestamp in millis granularity. Thus we're rounding here to ensure
         // internal representation matches toXContent
@@ -84,7 +84,7 @@ public class MemoryUsage implements Writeable, ToXContentObject {
             ExceptionsHelper.requireNonNull(timestamp, Fields.TIMESTAMP).toEpochMilli());
         this.peakUsageBytes = peakUsageBytes;
         this.status = status == null ? Status.OK : status;
-        this.increasedMemoryEstimateBytes = increasedMemoryEstimateBytes;
+        this.memoryReestimateBytes = memoryReestimateBytes;
     }
 
     public MemoryUsage(StreamInput in) throws IOException {
@@ -93,10 +93,10 @@ public class MemoryUsage implements Writeable, ToXContentObject {
         peakUsageBytes = in.readVLong();
         if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
             status = Status.readFromStream(in);
-            increasedMemoryEstimateBytes = in.readOptionalVLong();
+            memoryReestimateBytes = in.readOptionalVLong();
         } else {
             status = Status.OK;
-            increasedMemoryEstimateBytes = null;
+            memoryReestimateBytes = null;
         }
     }
 
@@ -111,7 +111,7 @@ public class MemoryUsage implements Writeable, ToXContentObject {
         out.writeVLong(peakUsageBytes);
         if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
             status.writeTo(out);
-            out.writeOptionalVLong(increasedMemoryEstimateBytes);
+            out.writeOptionalVLong(memoryReestimateBytes);
         }
     }
 
@@ -128,8 +128,8 @@ public class MemoryUsage implements Writeable, ToXContentObject {
         }
         builder.field(PEAK_USAGE_BYTES.getPreferredName(), peakUsageBytes);
         builder.field(STATUS.getPreferredName(), status);
-        if (increasedMemoryEstimateBytes != null) {
-            builder.field(INCREASED_MEMORY_ESTIMATE_BYTES.getPreferredName(), increasedMemoryEstimateBytes);
+        if (memoryReestimateBytes != null) {
+            builder.field(MEMORY_REESTIMATE_BYTES.getPreferredName(), memoryReestimateBytes);
         }
         builder.endObject();
         return builder;
@@ -145,12 +145,12 @@ public class MemoryUsage implements Writeable, ToXContentObject {
             && Objects.equals(timestamp, other.timestamp)
             && peakUsageBytes == other.peakUsageBytes
             && Objects.equals(status, other.status)
-            && Objects.equals(increasedMemoryEstimateBytes, other.increasedMemoryEstimateBytes);
+            && Objects.equals(memoryReestimateBytes, other.memoryReestimateBytes);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(jobId, timestamp, peakUsageBytes, status, increasedMemoryEstimateBytes);
+        return Objects.hash(jobId, timestamp, peakUsageBytes, status, memoryReestimateBytes);
     }
 
     @Override