ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [16/50] [abbrv] ignite git commit: IGNITE-4534: Detailed javadocs added + Tests now run faster
Date Fri, 14 Apr 2017 06:28:38 GMT
IGNITE-4534: Detailed javadocs added + Tests now run faster


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

Branch: refs/heads/master
Commit: 0390391870c759e1c5d65605b94a9bcbf3e9e67c
Parents: d69a594
Author: Ivan Rakov <ivan.glukos@gmail.com>
Authored: Tue Apr 11 19:06:54 2017 +0300
Committer: Ivan Rakov <ivan.glukos@gmail.com>
Committed: Tue Apr 11 19:06:54 2017 +0300

----------------------------------------------------------------------
 .../configuration/DataPageEvictionMode.java       | 16 ++++++++++++++--
 .../configuration/MemoryPolicyConfiguration.java  | 18 ++++++++++++------
 .../eviction/paged/PageEvictionAbstractTest.java  |  4 ++--
 .../eviction/paged/PageEvictionMultinodeTest.java |  4 ++--
 .../paged/PageEvictionReadThroughTest.java        |  2 +-
 5 files changed, 31 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/03903918/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
index bada68e..da3dbdf 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/DataPageEvictionMode.java
@@ -24,9 +24,21 @@ public enum DataPageEvictionMode {
     /** Disabled. */
     DISABLED,
 
-    /** Random lru. */
+    /**
+     * Random-LRU algorithm. In a nutshell:
+     * 1) During memory policy initialization, off-heap array is allocated to track timestamp
of last usage for each
+     * data page.
+     * 2) When data page on address X is accessed, current timestamp is stored in X / PAGE_SIZE
array position.
+     * 3) When there's a need for eviction, we randomly choose 5 indices of array (if some
of indices point to
+     * non-data pages, re-choose them) and evict data page with minimum timestamp.
+     */
     RANDOM_LRU,
 
-    /** Random 2-lru. */
+    /**
+     * Random-2-LRU algorithm. Scan-resistant version of Random-LRU. The only difference
is that we store two
+     * previous timestamps for each data page, and choose minimum between "older" timestamps.
LRU-2 outperforms LRU by
+     * resolving "one-hit wonder" problem: if page is accessed very rarely, but accidentally
accessed once, it's
+     * protected from eviction for long time.
+     */
     RANDOM_2_LRU
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/03903918/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
index d6203c6..6fe373d 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@ -17,10 +17,9 @@
 package org.apache.ignite.configuration;
 
 import java.io.Serializable;
+import org.apache.ignite.internal.mem.OutOfMemoryException;
 import org.apache.ignite.internal.pagemem.PageMemory;
 import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
-import org.apache.ignite.internal.processors.cache.database.freelist.FreeList;
-import org.apache.ignite.internal.processors.cache.database.tree.io.DataPageIO;
 
 /**
  * Configuration bean used for creating {@link MemoryPolicy} instances.
@@ -48,12 +47,19 @@ public final class MemoryPolicyConfiguration implements Serializable {
     /** Algorithm for per-page eviction. If {@link DataPageEvictionMode#DISABLED} set, eviction
is not performed. */
     private DataPageEvictionMode pageEvictionMode = DataPageEvictionMode.DISABLED;
 
-    /** Allocation of new {@link DataPageIO} pages is stopped when this percentage of pages
are allocated. */
+    /** Threshold for per-page eviction.
+     * When this percentage of memory pages of the current policy is allocated (90% by default),
+     * system starts page eviction.
+     * Decrease this parameter if {@link OutOfMemoryException} occurred with enabled page
eviction.
+     */
     private double evictionThreshold = 0.9;
 
-    /** Allocation of new {@link DataPageIO} pages is stopped by maintaining this amount
of empty pages in
-     * corresponding {@link FreeList} bucket. Pages get into the bucket through evicting
all data entries one by one.
-     * Higher load and contention require larger pool size.
+    /** When {@link #evictionThreshold} is reached, allocation of new data pages is prevented
by maintaining this
+     * amount of evicted data pages in the pool. If any thread needs free page to store cache
entry,
+     * it will take empty page from the pool instead of allocating a new one.
+     * Increase this parameter if cache can contain very big entries (total size of pages
in the pool should be enough
+     * to contain largest cache entry).
+     * Increase this parameter if {@link OutOfMemoryException} occurred with enabled page
eviction.
      */
     private int emptyPagesPoolSize = 100;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/03903918/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java
index bf05146..20edd4e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionAbstractTest.java
@@ -38,13 +38,13 @@ public class PageEvictionAbstractTest extends GridCommonAbstractTest {
     protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
     /** Offheap size for memory policy. */
-    private static final int SIZE = 256 * 1024 * 1024;
+    private static final int SIZE = 96 * 1024 * 1024;
 
     /** Page size. */
     static final int PAGE_SIZE = 2048;
 
     /** Number of entries. */
-    static final int ENTRIES = 400_000;
+    static final int ENTRIES = 80_000;
 
     /** Empty pages pool size. */
     private static final int EMPTY_PAGES_POOL_SIZE = 100;

http://git-wip-us.apache.org/repos/asf/ignite/blob/03903918/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeTest.java
index 2302de1..7a58dd4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionMultinodeTest.java
@@ -102,8 +102,8 @@ public abstract class PageEvictionMultinodeTest extends PageEvictionAbstractTest
 
         System.out.println(">>> Resulting size: " + resultingSize);
 
-        // More than half of entries evicted, no OutOfMemory occurred, success.
-        assertTrue(resultingSize < ENTRIES / 2);
+        // Eviction started, no OutOfMemory occurred, success.
+        assertTrue(resultingSize < ENTRIES);
 
         ignite(0).destroyCache(cfg.getName());
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/03903918/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java
index c8cd7c9..ff71361 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/paged/PageEvictionReadThroughTest.java
@@ -73,7 +73,7 @@ public class PageEvictionReadThroughTest extends PageEvictionAbstractTest
{
      * @throws Exception If failed.
      */
     private void testEvictionWithReadThrough(CacheAtomicityMode atomicityMode, CacheMode
cacheMode) throws Exception {
-        startGridsMultiThreaded(4);
+        startGrid(0);
 
         CacheConfiguration<Object, Object> cfg = cacheConfig("evict-rebalance", null,
cacheMode, atomicityMode,
             CacheWriteSynchronizationMode.PRIMARY_SYNC);


Mime
View raw message