ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [25/50] [abbrv] ignite git commit: IGNITE-6710 Added pages replace age metric
Date Wed, 25 Oct 2017 09:59:17 GMT
IGNITE-6710 Added pages replace age metric


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bb31a8a4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bb31a8a4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bb31a8a4

Branch: refs/heads/ignite-5937
Commit: bb31a8a4e67190435d4cbfc98a63f2de2e000291
Parents: 5d90b8f
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Mon Oct 23 16:34:59 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Mon Oct 23 16:34:59 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/DataRegionMetrics.java    | 11 +++++++
 .../persistence/DataRegionMetricsImpl.java      | 30 ++++++++++++++++----
 .../DataRegionMetricsMXBeanImpl.java            |  5 ++++
 .../persistence/DataRegionMetricsSnapshot.java  |  9 ++++++
 .../persistence/DataStorageMetricsImpl.java     |  4 +--
 .../persistence/pagemem/PageMemoryImpl.java     | 11 +++++--
 .../ignite/mxbean/DataRegionMetricsMXBean.java  |  4 +++
 7 files changed, 63 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java b/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java
index 86b91f4..ce5a122 100644
--- a/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/DataRegionMetrics.java
@@ -110,6 +110,17 @@ public interface DataRegionMetrics {
     public float getPagesReplaceRate();
 
     /**
+     * Gets average age (in milliseconds) for the pages being replaced from the disk storage.
+     * This number effectively represents the average time between the moment when a page
is read
+     * from the disk and the time when the page is evicted. Note that if a page is never
evicted, it does
+     * not contribute to this metric.
+     * This metric is enabled only for Ignite nodes with enabled persistence.
+     *
+     * @return Replaced pages age in milliseconds.
+     */
+    public float getPagesReplaceAge();
+
+    /**
      * Gets total number of pages currently loaded to the RAM. When persistence is disabled,
this metric is equal
      * to {@link #getTotalAllocatedPages()}.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java
index 1d570f9..471ac94 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsImpl.java
@@ -59,6 +59,9 @@ public class DataRegionMetricsImpl implements DataRegionMetrics {
     private volatile HitRateMetrics pageReplaceRate = new HitRateMetrics(60_000, 5);
 
     /** */
+    private volatile HitRateMetrics pageReplaceAge = new HitRateMetrics(60_000, 5);
+
+    /** */
     private final DataRegionConfiguration memPlcCfg;
 
     /** */
@@ -103,7 +106,7 @@ public class DataRegionMetricsImpl implements DataRegionMetrics {
         if (!metricsEnabled)
             return 0;
 
-        return ((float) allocRate.getRate()) / rateTimeInterval;
+        return ((float)allocRate.getRate() * 1000) / rateTimeInterval;
     }
 
     /** {@inheritDoc} */
@@ -142,7 +145,17 @@ public class DataRegionMetricsImpl implements DataRegionMetrics {
         if (!metricsEnabled || !persistenceEnabled)
             return 0;
 
-        return ((float) pageReplaceRate.getRate()) / rateTimeInterval;
+        return ((float)pageReplaceRate.getRate() * 1000) / rateTimeInterval;
+    }
+
+    /** {@inheritDoc} */
+    @Override public float getPagesReplaceAge() {
+        if (!metricsEnabled || !persistenceEnabled)
+            return 0;
+
+        long rep = pageReplaceRate.getRate();
+
+        return rep == 0 ? 0 : ((float)pageReplaceAge.getRate() / rep);
     }
 
     /** {@inheritDoc} */
@@ -158,9 +171,12 @@ public class DataRegionMetricsImpl implements DataRegionMetrics {
     /**
      * Updates pageReplaceRate metric.
      */
-    public void updatePageReplaceRate() {
-        if (metricsEnabled)
+    public void updatePageReplaceRate(long pageAge) {
+        if (metricsEnabled) {
             pageReplaceRate.onHit();
+
+            pageReplaceAge.onHits(pageAge);
+        }
     }
 
     /**
@@ -263,7 +279,8 @@ public class DataRegionMetricsImpl implements DataRegionMetrics {
         this.rateTimeInterval = rateTimeInterval;
 
         allocRate = new HitRateMetrics((int) rateTimeInterval, subInts);
-        pageReplaceRate = new HitRateMetrics((int) rateTimeInterval, subInts);
+        pageReplaceRate = new HitRateMetrics((int)rateTimeInterval, subInts);
+        pageReplaceAge = new HitRateMetrics((int)rateTimeInterval, subInts);
     }
 
     /**
@@ -281,6 +298,7 @@ public class DataRegionMetricsImpl implements DataRegionMetrics {
             subInts = (int) rateTimeInterval / 10;
 
         allocRate = new HitRateMetrics((int) rateTimeInterval, subInts);
-        pageReplaceRate = new HitRateMetrics((int) rateTimeInterval, subInts);
+        pageReplaceRate = new HitRateMetrics((int)rateTimeInterval, subInts);
+        pageReplaceAge = new HitRateMetrics((int)rateTimeInterval, subInts);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsMXBeanImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsMXBeanImpl.java
index 141d0dc..86ea918 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsMXBeanImpl.java
@@ -77,6 +77,11 @@ class DataRegionMetricsMXBeanImpl implements DataRegionMetricsMXBean {
     }
 
     /** {@inheritDoc} */
+    @Override public float getPagesReplaceAge() {
+        return memMetrics.getPagesReplaceAge();
+    }
+
+    /** {@inheritDoc} */
     @Override public long getPhysicalMemoryPages() {
         return memMetrics.getPhysicalMemoryPages();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsSnapshot.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsSnapshot.java
index c39fdb0d..c9e3d08 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsSnapshot.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataRegionMetricsSnapshot.java
@@ -48,6 +48,9 @@ public class DataRegionMetricsSnapshot implements DataRegionMetrics {
     private float pageReplaceRate;
 
     /** */
+    private float pageReplaceAge;
+
+    /** */
     private long physicalMemoryPages;
 
     /**
@@ -62,6 +65,7 @@ public class DataRegionMetricsSnapshot implements DataRegionMetrics {
         pagesFillFactor = metrics.getPagesFillFactor();
         dirtyPages = metrics.getDirtyPages();
         pageReplaceRate = metrics.getPagesReplaceRate();
+        pageReplaceAge = metrics.getPagesReplaceAge();
         physicalMemoryPages = metrics.getPhysicalMemoryPages();
     }
 
@@ -106,6 +110,11 @@ public class DataRegionMetricsSnapshot implements DataRegionMetrics {
     }
 
     /** {@inheritDoc} */
+    @Override public float getPagesReplaceAge() {
+        return pageReplaceAge;
+    }
+
+    /** {@inheritDoc} */
     @Override public long getPhysicalMemoryPages() {
         return physicalMemoryPages;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStorageMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStorageMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStorageMetricsImpl.java
index 6d196dc..e871597 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStorageMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/DataStorageMetricsImpl.java
@@ -94,7 +94,7 @@ public class DataStorageMetricsImpl implements DataStorageMetricsMXBean
{
         if (!metricsEnabled)
             return 0;
 
-        return ((float)walLoggingRate.getRate()) / rateTimeInterval;
+        return ((float)walLoggingRate.getRate() * 1000) / rateTimeInterval;
     }
 
     /** {@inheritDoc} */
@@ -102,7 +102,7 @@ public class DataStorageMetricsImpl implements DataStorageMetricsMXBean
{
         if (!metricsEnabled)
             return 0;
 
-        return ((float)walWritingRate.getRate()) / rateTimeInterval;
+        return ((float)walWritingRate.getRate() * 1000) / rateTimeInterval;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
index 8c64e0e..4a4fe9e 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java
@@ -437,6 +437,8 @@ public class PageMemoryImpl implements PageMemoryEx {
 
         long pageId = storeMgr.allocatePage(cacheId, partId, flags);
 
+        memMetrics.incrementTotalAllocatedPages();
+
         assert PageIdUtils.pageIndex(pageId) > 0; //it's crucial for tracking pages (zero
page is super one)
 
         // We need to allocate page in memory for marking it dirty to save it in the next
checkpoint.
@@ -608,8 +610,6 @@ public class PageMemoryImpl implements PageMemoryEx {
                     try {
                         ByteBuffer buf = wrapPointer(pageAddr, pageSize());
 
-                        memMetrics.updatePageReplaceRate();
-
                         storeMgr.read(cacheId, pageId, buf);
                     }
                     catch (IgniteDataIntegrityViolationException ignore) {
@@ -1781,6 +1781,8 @@ public class PageMemoryImpl implements PageMemoryEx {
                 if (cpPages != null && cpPages.contains(fullPageId)) {
                     assert storeMgr != null;
 
+                    memMetrics.updatePageReplaceRate(U.currentTimeMillis() - PageHeader.readTimestamp(absPtr));
+
                     flushDirtyPage.applyx(
                         fullPageId,
                         wrapPointer(absPtr + PAGE_OVERHEAD, pageSize()),
@@ -1799,9 +1801,12 @@ public class PageMemoryImpl implements PageMemoryEx {
 
                 return false;
             }
-            else
+            else {
+                memMetrics.updatePageReplaceRate(U.currentTimeMillis() - PageHeader.readTimestamp(absPtr));
+
                 // Page was not modified, ok to evict.
                 return true;
+            }
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb31a8a4/modules/core/src/main/java/org/apache/ignite/mxbean/DataRegionMetricsMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/DataRegionMetricsMXBean.java
b/modules/core/src/main/java/org/apache/ignite/mxbean/DataRegionMetricsMXBean.java
index eeed496..16bc677 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/DataRegionMetricsMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/DataRegionMetricsMXBean.java
@@ -82,6 +82,10 @@ public interface DataRegionMetricsMXBean extends DataRegionMetrics {
     @Override public float getPagesReplaceRate();
 
     /** {@inheritDoc} */
+    @MXBeanDescription("Average age at which pages in memory are replaced with pages from
persistent storage (milliseconds).")
+    @Override public float getPagesReplaceAge();
+
+    /** {@inheritDoc} */
     @MXBeanDescription("Number of pages residing in physical RAM.")
     @Override public long getPhysicalMemoryPages();
 


Mime
View raw message