ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [07/27] ignite git commit: IGNITE-6182 Change default max memory size from 80% to 20%
Date Tue, 05 Sep 2017 08:33:21 GMT
IGNITE-6182 Change default max memory size from 80% to 20%


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

Branch: refs/heads/ignite-3478-1
Commit: bd7bd226d959fbc686f6104a048106b7b944347b
Parents: 55e0b5c
Author: Igor Seliverstov <gvvinblade@gmail.com>
Authored: Fri Sep 1 12:56:56 2017 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Fri Sep 1 12:56:56 2017 +0300

----------------------------------------------------------------------
 .../configuration/MemoryConfiguration.java      |  4 +-
 .../apache/ignite/internal/IgniteKernal.java    | 21 +++++++--
 .../ignite/internal/IgniteNodeAttributes.java   |  3 ++
 .../discovery/GridDiscoveryManager.java         | 49 +++++++++++++++++++-
 .../GridCacheDatabaseSharedManager.java         | 39 +++++++++-------
 .../Configuration/MemoryPolicyConfiguration.cs  |  4 +-
 6 files changed, 95 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bd7bd226/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index f83d7d0..8b59c4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@ -67,9 +67,9 @@ public class MemoryConfiguration implements Serializable {
     public static final long DFLT_MEMORY_POLICY_INITIAL_SIZE = 256L * 1024 * 1024;
 
     /** Fraction of available memory to allocate for default MemoryPolicy. */
-    private static final double DFLT_MEMORY_POLICY_FRACTION = 0.8;
+    private static final double DFLT_MEMORY_POLICY_FRACTION = 0.2;
 
-    /** Default memory policy's size is 80% of physical memory available on current machine.
*/
+    /** Default memory policy's size is 20% of physical memory available on current machine.
*/
     public static final long DFLT_MEMORY_POLICY_MAX_SIZE = Math.max(
         (long)(DFLT_MEMORY_POLICY_FRACTION * U.getTotalMemoryAvailable()),
         DFLT_MEMORY_POLICY_INITIAL_SIZE);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bd7bd226/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index e926653..549fcb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -233,6 +233,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTE
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_OFFHEAP_SIZE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_RESTART_ENABLED;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS;
@@ -1383,19 +1384,33 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
             String macs = ctx.discovery().localNode().attribute(ATTR_MACS);
 
             long totalHeap = 0;
+            long totalOffheap = 0;
 
             for (ClusterNode node : ctx.discovery().allNodes()) {
                 if (macs.equals(node.attribute(ATTR_MACS))) {
                     long heap = node.metrics().getHeapMemoryMaximum();
+                    Long offheap = node.<Long>attribute(ATTR_OFFHEAP_SIZE);
 
                     if (heap != -1)
                         totalHeap += heap;
+
+                    if (offheap != null)
+                        totalOffheap += offheap;
                 }
             }
 
-            if (totalHeap > ram) {
-                U.quietAndWarn(log, "Attempting to start more nodes than physical RAM " +
-                    "available on current host (this can cause significant slowdown)");
+            long total = totalHeap + totalOffheap;
+
+            if (total < 0)
+                total = Long.MAX_VALUE;
+
+            // 4GB or 20% of available memory is expected to be used by OS and user applications
+            long safeToUse = ram - Math.max(4L << 30, (long)(ram * 0.2));
+
+            if (total > safeToUse) {
+                U.quietAndWarn(log, "Attempting to start more nodes than physical RAM available
on the host " +
+                    "what can lead to significant slowdown (please decrease JVM heap size,
memory policy size or " +
+                    "checkpoint buffer size) [required=" + (total >> 20) + "MB, available="
+ (ram >> 20) + "MB]");
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bd7bd226/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index ab6c290..024f339 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -124,6 +124,9 @@ public final class IgniteNodeAttributes {
     public static final String ATTR_PHY_RAM = ATTR_PREFIX + ".phy.ram";
 
     /** Internal attribute name constant. */
+    public static final String ATTR_OFFHEAP_SIZE = ATTR_PREFIX + ".offheap.size";
+
+    /** Internal attribute name constant. */
     public static final String ATTR_JVM_PID = ATTR_PREFIX + ".jvm.pid";
 
     /** Internal attribute name constant. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bd7bd226/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index d426ca5..74f7fa6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -55,6 +55,8 @@ import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cluster.ClusterMetrics;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.events.Event;
 import org.apache.ignite.internal.ClusterMetricsSnapshot;
@@ -64,7 +66,6 @@ import org.apache.ignite.internal.GridNodeOrderComparator;
 import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.IgniteNodeAttributes;
 import org.apache.ignite.internal.events.DiscoveryCustomEvent;
 import org.apache.ignite.internal.managers.GridManagerAdapter;
 import org.apache.ignite.internal.managers.communication.GridIoManager;
@@ -76,6 +77,7 @@ import org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest;
 import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
 import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
 import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
 import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
@@ -141,7 +143,9 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LATE_AFFINITY
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_DFLT_SUID;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_OFFHEAP_SIZE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SECURITY_COMPATIBILITY_MODE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SERVICES_COMPATIBILITY_MODE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME;
@@ -485,7 +489,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
             // No-op.
         }
 
-        ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_PHY_RAM, totSysMemory);
+        ctx.addNodeAttribute(ATTR_PHY_RAM, totSysMemory);
+        ctx.addNodeAttribute(ATTR_OFFHEAP_SIZE, requiredOffheap());
 
         DiscoverySpi spi = getSpi();
 
@@ -1518,6 +1523,46 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
     }
 
     /**
+     * @return Required offheap memory in bytes.
+     */
+    private long requiredOffheap() {
+        if(ctx.config().isClientMode())
+            return 0;
+
+        MemoryConfiguration memCfg = ctx.config().getMemoryConfiguration();
+
+        assert memCfg != null;
+
+        long res = memCfg.getSystemCacheMaxSize();
+
+        // Add memory policies.
+        MemoryPolicyConfiguration[] memPlcCfgs = memCfg.getMemoryPolicies();
+
+        if (memPlcCfgs != null) {
+            String dfltMemPlcName = memCfg.getDefaultMemoryPolicyName();
+
+            boolean customDflt = false;
+
+            for (MemoryPolicyConfiguration memPlcCfg : memPlcCfgs) {
+                if(F.eq(dfltMemPlcName, memPlcCfg.getName()))
+                    customDflt = true;
+
+                res += memPlcCfg.getMaxSize();
+            }
+
+            if(!customDflt)
+                res += memCfg.getDefaultMemoryPolicySize();
+        }
+        else
+            res += memCfg.getDefaultMemoryPolicySize();
+
+        // Add persistence (if any).
+        res += GridCacheDatabaseSharedManager.checkpointBufferSize(ctx.config());
+
+        return res;
+    }
+
+    /**
      * @param topVer Topology version.
      * @param srvNodesNum Server nodes number.
      * @param clientNodesNum Client nodes number.

http://git-wip-us.apache.org/repos/asf/ignite/blob/bd7bd226/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index c59cccc..4db0bf8 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -380,8 +380,6 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
      *
      */
     private void initDataBase() {
-        long cpBufSize = persistenceCfg.getCheckpointingPageBufferSize();
-
         if (persistenceCfg.getCheckpointingThreads() > 1)
             asyncRunner = new IgniteThreadPoolExecutor(
                 "checkpoint-runner",
@@ -392,12 +390,27 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
                 new LinkedBlockingQueue<Runnable>()
             );
 
-        // Intentionally use identity comparison to check if configuration default has changed.
-        //noinspection NumberEquality
-        if (cpBufSize == 0L) {
-            cpBufSize = DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE;
+        checkpointPageBufSize = checkpointBufferSize(cctx.kernalContext().config());
+    }
+
+    /**
+     * Get checkpoint buffer size for the given configuration.
+     *
+     * @param cfg Configuration.
+     * @return Checkpoint buffer size.
+     */
+    public static long checkpointBufferSize(IgniteConfiguration cfg) {
+        PersistentStoreConfiguration persistenceCfg = cfg.getPersistentStoreConfiguration();
 
-            MemoryConfiguration memCfg = cctx.kernalContext().config().getMemoryConfiguration();
+        if (persistenceCfg == null)
+            return 0L;
+
+        long res = persistenceCfg.getCheckpointingPageBufferSize();
+
+        if (res == 0L) {
+            res = DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE;
+
+            MemoryConfiguration memCfg = cfg.getMemoryConfiguration();
 
             assert memCfg != null;
 
@@ -424,17 +437,11 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
 
             long adjusted = Math.min(totalSize / 4, dfltSize);
 
-            if (cpBufSize < adjusted) {
-                U.quietAndInfo(log,
-                    "Default checkpoint page buffer size is too small, setting to an adjusted
value: "
-                        + U.readableSize(adjusted, false)
-                );
-
-                cpBufSize = adjusted;
-            }
+            if (res < adjusted)
+                res = adjusted;
         }
 
-        checkpointPageBufSize = cpBufSize;
+        return res;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bd7bd226/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
index c1fcaa2..16d8dcc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@ -45,9 +45,9 @@ namespace Apache.Ignite.Core.Cache.Configuration
         public const long DefaultInitialSize = 256 * 1024 * 1024;
 
         /// <summary>
-        /// The default maximum size, equals to 80% of total RAM.
+        /// The default maximum size, equals to 20% of total RAM.
         /// </summary>
-        public static readonly long DefaultMaxSize = (long) ((long) NativeMethods.GetTotalPhysicalMemory()
* 0.8);
+        public static readonly long DefaultMaxSize = (long) ((long) NativeMethods.GetTotalPhysicalMemory()
* 0.2);
 
         /// <summary>
         /// The default sub intervals.


Mime
View raw message