Phillippko commented on code in PR #5709:
URL: https://github.com/apache/ignite-3/pull/5709#discussion_r2063677990


##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/CompactionStatisticsHolder.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metastorage.server.persistence;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Helper class to hold compaction statistics while it's running, and then to 
get the message with accumulated statistics.
+ */
+class CompactionStatisticsHolder {
+    /** Compaction revision. */
+    private final long revision;
+    /** {@link System#nanoTime()} at the moment of compaction start. */
+    private final long startNanoTime;
+
+    /** Whether compaction has been stopped in the process. */
+    private boolean stopped;

Review Comment:
   could it be "interrupted", or something like that? I was confused, thinking 
that it should be set when compaction finishes normally



##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/persistence/CompactionStatisticsHolder.java:
##########
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.metastorage.server.persistence;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Helper class to hold compaction statistics while it's running, and then to 
get the message with accumulated statistics.
+ */
+class CompactionStatisticsHolder {
+    /** Compaction revision. */
+    private final long revision;
+    /** {@link System#nanoTime()} at the moment of compaction start. */
+    private final long startNanoTime;
+
+    /** Whether compaction has been stopped in the process. */
+    private boolean stopped;
+
+    /** Total number of keys read from rocksb iterator.*/
+    private int totalKeysScanned;
+    /** Total number of keys read from metastorage, this metric excludes 
duplicates.*/
+    private int totalKeysRead;
+
+    /** Total number of individual revisions for all keys that were compacted. 
*/
+    private int totalKeyRevisionsCompacted;
+    /** Total number of keys that had at least one revision compacted. */
+    private int totalKeysCompacted;
+    /** Total number compacted tombstones. */
+    private int totalTombstonesCompacted;
+
+    /** Total number of committed batches. */
+    private int batchesCommitted;
+    /** Total number of retries while trying to commit a batch. */
+    private int batchesAborted;
+
+    /** {@link #totalKeysRead} accumulator for current batch. */
+    private int batchKeysRead;
+
+    /** {@link #totalKeyRevisionsCompacted} accumulator for current batch. */
+    private int batchKeyRevisionsCompacted;
+    /** {@link #totalKeysCompacted} accumulator for current batch. */
+    private int batchKeysCompacted;
+    /** {@link #totalTombstonesCompacted} accumulator for current batch. */
+    private int batchTombstonesCompacted;
+
+    /** Total number of auxiliary mappings compacted. Matches a total number 
of compacted revisions. */
+    private int auxiliaryMappingsCompacted;
+
+    /** Temporary value for calculating {@link #maxLockWaitNanos} and {@link 
#maxLockHoldNanos}. */
+    private long lastLockNanoTime;
+    /** Max time of lock wait acquisition, in nanoseconds. */
+    private long maxLockWaitNanos;
+    /** Max time of lock holding, in nanoseconds. */
+    private long maxLockHoldNanos;
+
+    CompactionStatisticsHolder(long revision) {
+        this.revision = revision;
+        this.startNanoTime = System.nanoTime();
+    }
+
+    String info() {
+        return "stopped=" + stopped
+                + ", compactedRevision=" + revision
+                + ", duration=" + 
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanoTime) + "ms"

Review Comment:
   Ideally duration shouldn't depend on when info() is called
   
   ```suggestion
                   + ", duration=" + 
TimeUnit.NANOSECONDS.toMillis(finishedNanoTime - startNanoTime) + "ms"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to