You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2016/02/01 15:27:39 UTC
[44/48] ignite git commit: IGNITE-2502: More precise ArrayList
allocation inside GridNearAtomicUpdateRequest.
IGNITE-2502: More precise ArrayList allocation inside GridNearAtomicUpdateRequest.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/732dd413
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/732dd413
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/732dd413
Branch: refs/heads/ignite-2454
Commit: 732dd4136f234036f390914a98aad8776514eb57
Parents: 881d5a8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Feb 1 15:06:18 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Feb 1 15:06:18 2016 +0300
----------------------------------------------------------------------
.../dht/atomic/GridNearAtomicUpdateFuture.java | 6 ++++--
.../dht/atomic/GridNearAtomicUpdateRequest.java | 22 +++++++++++++++-----
2 files changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/732dd413/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index c9e1a11..519df17 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -1100,7 +1100,8 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
skipStore,
keepBinary,
cctx.kernalContext().clientNode(),
- cctx.deploymentEnabled());
+ cctx.deploymentEnabled(),
+ keys.size());
pendingMappings.put(nodeId, mapped);
}
@@ -1199,7 +1200,8 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
skipStore,
keepBinary,
cctx.kernalContext().clientNode(),
- cctx.deploymentEnabled());
+ cctx.deploymentEnabled(),
+ 1);
req.addUpdateEntry(cacheKey,
val,
http://git-wip-us.apache.org/repos/asf/ignite/blob/732dd413/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index 9c4b486..1a7fa88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -158,6 +158,10 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
@GridDirectTransient
private GridNearAtomicUpdateResponse res;
+ /** Maximum possible size of inner collections. */
+ @GridDirectTransient
+ private int initSize;
+
/**
* Empty constructor required by {@link Externalizable}.
*/
@@ -187,6 +191,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
* @param keepBinary Keep binary flag.
* @param clientReq Client node request flag.
* @param addDepInfo Deployment info flag.
+ * @param maxEntryCnt Maximum entries count.
*/
public GridNearAtomicUpdateRequest(
int cacheId,
@@ -207,7 +212,8 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
boolean skipStore,
boolean keepBinary,
boolean clientReq,
- boolean addDepInfo
+ boolean addDepInfo,
+ int maxEntryCnt
) {
assert futVer != null;
@@ -232,7 +238,13 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
this.clientReq = clientReq;
this.addDepInfo = addDepInfo;
- keys = new ArrayList<>();
+ // By default ArrayList expands to array of 10 elements on first add. We cannot guess how many entries
+ // will be added to request because of unknown affinity distribution. However, we DO KNOW how many keys
+ // participate in request. As such, we know upper bound of all collections in request. If this bound is lower
+ // than 10, we use it.
+ initSize = Math.min(maxEntryCnt, 10);
+
+ keys = new ArrayList<>(initSize);
}
/** {@inheritDoc} */
@@ -380,7 +392,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
if (entryProcessor != null) {
if (entryProcessors == null)
- entryProcessors = new ArrayList<>();
+ entryProcessors = new ArrayList<>(initSize);
entryProcessors.add(entryProcessor);
}
@@ -388,7 +400,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
assert val instanceof CacheObject : val;
if (vals == null)
- vals = new ArrayList<>();
+ vals = new ArrayList<>(initSize);
vals.add((CacheObject)val);
}
@@ -398,7 +410,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
// In case there is no conflict, do not create the list.
if (conflictVer != null) {
if (conflictVers == null) {
- conflictVers = new ArrayList<>();
+ conflictVers = new ArrayList<>(initSize);
for (int i = 0; i < keys.size() - 1; i++)
conflictVers.add(null);