dant3 commented on code in PR #7422:
URL: https://github.com/apache/ignite-3/pull/7422#discussion_r2852828454


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/RunConsistentlyMetrics.java:
##########
@@ -17,62 +17,77 @@
 
 package org.apache.ignite.internal.storage.pagememory.mv;
 
-import org.apache.ignite.internal.metrics.AtomicIntMetric;
+import java.util.concurrent.TimeUnit;
 import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.LongAdderMetric;
+import org.apache.ignite.internal.metrics.LongGauge;
+import org.apache.ignite.internal.metrics.LongMetric;
 import org.apache.ignite.internal.pagememory.metrics.CollectionMetricSource;
+import org.jetbrains.annotations.TestOnly;
 
 /**
  * Metrics for runConsistently operation.
  *
- * <p>Tracks runConsistently closure execution performance including duration
- * and active call count.
+ * <p>Tracks runConsistently closure execution performance including duration,
+ * active call count, and total invocation count.
  */
 public class RunConsistentlyMetrics {
-    /**
-     * Histogram buckets for runConsistently duration in nanoseconds.
-     *
-     * <p>Covers operations from fast single-row writes to slow bulk 
operations with checkpoint contention:
-     * <ul>
-     *   <li>10µs: Fast single-row operations without lock contention</li>
-     *   <li>100µs: Multi-row operations, small index operations</li>
-     *   <li>1ms: Medium-sized operations</li>
-     *   <li>10ms: Larger operations, small vacuum operations</li>
-     *   <li>100ms: Large operations, significant vacuum work</li>
-     *   <li>1s: Very slow operations, likely checkpoint write lock 
contention</li>
-     *   <li>10s: Pathological cases requiring investigation</li>
-     * </ul>
-     */
-    private static final long[] RUN_CONSISTENTLY_NANOS = {
-            10_000,          // 10µs
-            100_000,         // 100µs
-            1_000_000,       // 1ms
-            10_000_000,      // 10ms
-            100_000_000,     // 100ms
-            1_000_000_000,   // 1s
-            10_000_000_000L, // 10s
+    /** Histogram bucket bounds for runConsistently duration in nanoseconds. */
+    private static final long[] RUN_CONSISTENTLY_DURATION_BOUNDS = {
+            TimeUnit.MICROSECONDS.toNanos(10),
+            TimeUnit.MICROSECONDS.toNanos(100),
+            TimeUnit.MILLISECONDS.toNanos(1),
+            TimeUnit.MILLISECONDS.toNanos(10),
+            TimeUnit.MILLISECONDS.toNanos(100),
+            TimeUnit.SECONDS.toNanos(1),
+            TimeUnit.SECONDS.toNanos(10),
     };
 
     private final DistributionMetric runConsistentlyDuration;
-    private final AtomicIntMetric runConsistentlyActiveCount;
+    private final LongAdderMetric runConsistentlyStarted;
+    private final LongAdderMetric runConsistentlyFinished;
+    private final LongGauge runConsistentlyActiveCount;
+
+    private final CollectionMetricSource metricSource;
 
     /**
      * Constructor.
      *
      * @param metricSource Metric source to register metrics with.
      */
     public RunConsistentlyMetrics(CollectionMetricSource metricSource) {
+        this.metricSource = metricSource;
+
         runConsistentlyDuration = metricSource.addMetric(new 
DistributionMetric(
                 "RunConsistentlyDuration",
                 "Time spent in runConsistently closures in nanoseconds.",
-                RUN_CONSISTENTLY_NANOS
+                RUN_CONSISTENTLY_DURATION_BOUNDS
+        ));
+
+        runConsistentlyStarted = metricSource.addMetric(new LongAdderMetric(
+                "RunConsistentlyStarted",
+                "Total number of runConsistently invocations started."
+        ));
+
+        runConsistentlyFinished = metricSource.addMetric(new LongAdderMetric(

Review Comment:
   I think I cant follow that. How do we do 1 CAS in that case?
   
   > But we could do just 1 increment on entry (incrementing total number of 
entries) and 1 increment on exit (incrementing total number of exits);



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to