rpuch commented on code in PR #7320:
URL: https://github.com/apache/ignite-3/pull/7320#discussion_r2651009084


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemoryMetrics.java:
##########
@@ -17,17 +17,40 @@
 
 package org.apache.ignite.internal.pagememory.persistence;
 
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.HitRateMetric;
 import org.apache.ignite.internal.metrics.IntGauge;
 import org.apache.ignite.internal.metrics.LongAdderMetric;
 import org.apache.ignite.internal.metrics.LongGauge;
 import 
org.apache.ignite.internal.pagememory.configuration.PersistentDataRegionConfiguration;
 
 /** Persistent page memory metrics. */
-class PersistentPageMemoryMetrics {
+class PersistentPageMemoryMetrics implements PageCacheMetrics {
+    private static final long[] PAGE_ACQUIRE_NANOS = {
+            500,           // 500ns - L3 cache hit
+            1_000,         // 1µs   - memory access, cache hit

Review Comment:
   They are both memory accesses, right? So what's the exact difference?



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/replacement/MeteredPageReplacementPolicyFactory.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.pagememory.persistence.replacement;
+
+import org.apache.ignite.internal.lang.IgniteInternalCheckedException;
+import org.apache.ignite.internal.pagememory.persistence.PageCacheMetrics;
+import 
org.apache.ignite.internal.pagememory.persistence.PersistentPageMemory.Segment;
+
+/** A factory that wraps page replacement policies with metrics collection. */

Review Comment:
   ```suggestion
   /** A factory that augments page replacement policies with metrics 
collection. */
   ```



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemoryMetrics.java:
##########
@@ -17,17 +17,40 @@
 
 package org.apache.ignite.internal.pagememory.persistence;
 
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.internal.metrics.DistributionMetric;
+import org.apache.ignite.internal.metrics.HitRateMetric;
 import org.apache.ignite.internal.metrics.IntGauge;
 import org.apache.ignite.internal.metrics.LongAdderMetric;
 import org.apache.ignite.internal.metrics.LongGauge;
 import 
org.apache.ignite.internal.pagememory.configuration.PersistentDataRegionConfiguration;
 
 /** Persistent page memory metrics. */
-class PersistentPageMemoryMetrics {
+class PersistentPageMemoryMetrics implements PageCacheMetrics {
+    private static final long[] PAGE_ACQUIRE_NANOS = {

Review Comment:
   This defines distribution intervals/bounds. Let's name it appropriately



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemory.java:
##########
@@ -1029,6 +1037,28 @@ public long loadedPages() {
         return total;
     }
 
+    /**
+     * Returns the count of dirty pages across all segments.
+     */
+    public long dirtyPagesCount() {
+        Segment[] segments = this.segments;
+        if (segments == null) {
+            return 0;
+        }
+
+        long total = 0;
+
+        for (Segment seg : segments) {
+            if (seg == null) {

Review Comment:
   I guess this is a copy-paste. Looking at other places, we never have this 
null check anywhere except for `loadedPages()`, so I guess we don't need it 
here either. Let's remove it from `loadedPages()` as well



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/PersistentPageMemory.java:
##########
@@ -785,6 +791,8 @@ grpId, hexLong(pageId)
                 waitUntilPageIsFullyInitialized = true;
             }
 
+            metrics.recordPageAcquireTime(System.nanoTime() - startTime);

Review Comment:
   A lot is done in the `finally` block that follows, so the duration we 
register here is too optimistic



-- 
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