ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [07/50] [abbrv] incubator-ignite git commit: ignite-848 Excessive memory and CPU consumption by TTL manager
Date Fri, 08 May 2015 14:13:47 GMT
ignite-848 Excessive memory and CPU consumption by TTL manager


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

Branch: refs/heads/ignite-709_2
Commit: 9008472c334bfa3f7411e896b1aeaf657acff6df
Parents: 54f9492
Author: agura <agura@gridgain.com>
Authored: Tue May 5 20:21:28 2015 +0300
Committer: agura <agura@gridgain.com>
Committed: Tue May 5 21:14:31 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     | 10 ++++--
 .../processors/cache/GridCacheTtlManager.java   | 36 +++++++-------------
 .../processors/cache/GridCacheUtils.java        |  1 -
 .../datastreamer/DataStreamerImpl.java          |  2 ++
 4 files changed, 23 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9008472c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 478e1be..334f2b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3305,7 +3305,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
                     if (!obsolete()) {
                         if (cctx.deferredDelete() && !detached() && !isInternal())
{
                             if (!deletedUnlocked()) {
-                                update(null, 0L, 0L, ver);
+                                update(null, 0L, 0L, obsoleteVer);
 
                                 deletedUnlocked(true);
 
@@ -3345,11 +3345,17 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
             U.error(log, "Failed to clean up expired cache entry: " + this, e);
         }
         finally {
-            if (obsolete)
+            if (obsolete) {
                 onMarkedObsolete();
 
+                cctx.cache().removeEntry(this);
+            }
+
             if (deferred)
                 cctx.onDeferredDelete(this, obsoleteVer);
+
+            if ((obsolete || deferred) && cctx.cache().configuration().isStatisticsEnabled())
+                cctx.cache().metrics0().onEvict();
         }
 
         return obsolete;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9008472c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
index 546cf57..ef5ac19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
@@ -30,7 +30,8 @@ import org.jetbrains.annotations.*;
 import org.jsr166.*;
 
 /**
- * Eagerly removes expired entries from cache when {@link org.apache.ignite.configuration.CacheConfiguration#isEagerTtl()}
flag is set.
+ * Eagerly removes expired entries from cache when
+ * {@link org.apache.ignite.configuration.CacheConfiguration#isEagerTtl()} flag is set.
  */
 @SuppressWarnings("NakedNotify")
 public class GridCacheTtlManager extends GridCacheManagerAdapter {
@@ -93,35 +94,24 @@ public class GridCacheTtlManager extends GridCacheManagerAdapter {
     public void expire(boolean sizeLimited) {
         long now = U.currentTimeMillis();
 
-        GridCacheVersion obsoleteVer = null;
+        int size = pendingEntries.sizex();
 
-        // Make sure that worker thread (e.g. sys pool) or user thread
-        // will not be trapped.
-        int size = Math.min(pendingEntries.sizex(), 1024);
+        GridCacheVersion obsoleteVer = null;
 
         while (!sizeLimited || size-- > 0) {
-            EntryWrapper e = pendingEntries.pollFirst();
-
-            if (e == null)
-                break;
-
-            if (e.expireTime > now) {
-                pendingEntries.add(e);
-
-                break;
-            }
+            EntryWrapper e = pendingEntries.firstx();
 
-            if (obsoleteVer == null)
-                obsoleteVer = cctx.versions().next();
+            if (e == null || e.expireTime > now)
+                return;
 
-            if (log.isDebugEnabled())
-                log.debug("Trying to remove expired entry from cache: " + e);
+            if (pendingEntries.remove(e)) {
+                if (obsoleteVer == null)
+                    obsoleteVer = cctx.versions().next();
 
-            if (e.entry.onTtlExpired(obsoleteVer)) {
-                e.entry.context().cache().removeEntry(e.entry);
+                if (log.isDebugEnabled())
+                    log.debug("Trying to remove expired entry from cache: " + e);
 
-                if (e.entry.context().cache().configuration().isStatisticsEnabled())
-                    e.entry.context().cache().metrics0().onEvict();
+                e.entry.onTtlExpired(obsoleteVer);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9008472c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index a0e45e7..9a98358 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -29,7 +29,6 @@ import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.cache.version.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.T2;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9008472c/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index a69e033..db3d350 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -1420,6 +1420,8 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K,
V>, Delayed
                         GridDrType.DR_LOAD);
 
                     cctx.evicts().touch(entry, topVer);
+
+                    CU.unwindEvicts(cctx);
                 }
                 catch (GridDhtInvalidPartitionException | GridCacheEntryRemovedException
ignored) {
                     // No-op.


Mime
View raw message