You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/11/11 11:46:15 UTC
ignite git commit: Ignite-perftest - Optimizations.
Repository: ignite
Updated Branches:
refs/heads/ignite-perftest 8bf2e386f -> 5e2e120f0
Ignite-perftest - Optimizations.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5e2e120f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5e2e120f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5e2e120f
Branch: refs/heads/ignite-perftest
Commit: 5e2e120f0c4e5806b091d966c76743c713726b2f
Parents: 8bf2e38
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Nov 11 13:46:05 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Nov 11 13:46:05 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMvcc.java | 15 +++----
.../processors/cache/GridCacheMvccManager.java | 42 --------------------
.../cache/distributed/near/GridNearTxLocal.java | 21 +++++-----
.../near/GridNearTxPrepareFutureAdapter.java | 11 ++++-
.../clock/GridClockSyncProcessor.java | 30 +++++++++++---
5 files changed, 51 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5e2e120f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index 12583ad..543923a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -348,9 +348,6 @@ public final class GridCacheMvcc {
reassign();
- if (cand.local())
- cctx.mvcc().removeLocal(cand);
-
return true;
}
}
@@ -596,8 +593,6 @@ public final class GridCacheMvcc {
);
if (serOrder == null) {
- cctx.mvcc().addLocal(cand);
-
boolean add = add0(cand);
assert add : cand;
@@ -605,8 +600,6 @@ public final class GridCacheMvcc {
else {
if (!add0(cand))
return null;
-
- cctx.mvcc().addLocal(cand);
}
return cand;
@@ -1377,4 +1370,12 @@ public final class GridCacheMvcc {
@Override public String toString() { // Synchronize to ensure one-thread at a time.
return S.toString(GridCacheMvcc.class, this);
}
+
+ public static void main(String[] args) {
+ ArrayList<String> col1 = new ArrayList<>(5);
+
+ for (int i = 0; i < 5; i++) {
+ col1.add("" + i);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5e2e120f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 2c14209..8562f37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -29,7 +29,6 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentSkipListSet;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -92,9 +91,6 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
private GridBoundedConcurrentLinkedHashSet<GridCacheVersion> rmvLocks =
new GridBoundedConcurrentLinkedHashSet<>(MAX_REMOVED_LOCKS, MAX_REMOVED_LOCKS, 0.75f, 16, PER_SEGMENT_Q);
- /** Current local candidates. */
- private Collection<GridCacheMvccCandidate> dhtLocCands = new ConcurrentSkipListSet<>();
-
/** Locked keys. */
@GridToStringExclude
private final ConcurrentMap<IgniteTxKey, GridDistributedCacheEntry> locked = newMap();
@@ -707,43 +703,6 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
}
/**
- * @param cand Local lock.
- * @return {@code True} if added.
- */
- public boolean addLocal(GridCacheMvccCandidate cand) {
- assert cand.key() != null : cand;
- assert cand.local() : cand;
-
- if (cand.dhtLocal() && dhtLocCands.add(cand)) {
- if (log.isDebugEnabled())
- log.debug("Added local candidate: " + cand);
-
- return true;
- }
-
- return false;
- }
-
- /**
- *
- * @param cand Local candidate to remove.
- * @return {@code True} if removed.
- */
- public boolean removeLocal(GridCacheMvccCandidate cand) {
- assert cand.key() != null : cand;
- assert cand.local() : cand;
-
- if (cand.dhtLocal() && dhtLocCands.remove(cand)) {
- if (log.isDebugEnabled())
- log.debug("Removed local candidate: " + cand);
-
- return true;
- }
-
- return false;
- }
-
- /**
* @param cacheCtx Cache context.
* @param cand Cache lock candidate to add.
* @return {@code True} if added as a result of this operation,
@@ -953,7 +912,6 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
X.println(">>> ");
X.println(">>> Mvcc manager memory stats [grid=" + cctx.gridName() + ']');
X.println(">>> rmvLocksSize: " + rmvLocks.sizex());
- X.println(">>> dhtLocCandsSize: " + dhtLocCands.size());
X.println(">>> lockedSize: " + locked.size());
X.println(">>> futsSize: " + futs.size());
X.println(">>> near2dhtSize: " + near2dht.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/5e2e120f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index db4a4b8..93abee5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -481,9 +481,6 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
* @param writeVer Write version.
*/
void addDhtVersion(UUID nodeId, GridCacheVersion dhtVer, GridCacheVersion writeVer) {
- // This step is very important as near and DHT versions grow separately.
- cctx.versions().onReceived(nodeId, dhtVer);
-
GridDistributedTxMapping m = mappings.get(nodeId);
if (m != null)
@@ -567,18 +564,20 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
GridDistributedTxMapping m = mappings.get(n.id());
if (m == null) {
- m = F.addIfAbsent(mappings, n.id(), new GridDistributedTxMapping(n));
+ GridDistributedTxMapping old = mappings.putIfAbsent(map.node().id(), map);
- m.near(map.near());
+ assert old == null : "Failed to add mapping to transaction: " + this;
+ }
+ else {
+ if (map.near())
+ m.near(map.near());
if (map.explicitLock())
m.markExplicitLock();
- }
-
- assert m != null;
- for (IgniteTxEntry entry : map.entries())
- m.add(entry);
+ for (IgniteTxEntry entry : map.entries())
+ m.add(entry);
+ }
}
if (log.isDebugEnabled())
@@ -623,7 +622,7 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
Collection<GridCacheVersion> committedVers,
Collection<GridCacheVersion> rolledbackVers)
{
- Collection<IgniteTxEntry> entries = F.concat(false, mapping.writes(), mapping.reads());
+ Collection<IgniteTxEntry> entries = mapping.entries();
for (IgniteTxEntry txEntry : entries) {
while (true) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/5e2e120f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
index 45477a0..57a8a18 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareFutureAdapter.java
@@ -172,6 +172,8 @@ public abstract class GridNearTxPrepareFutureAdapter extends GridCompoundFuture<
assert res.error() == null : res;
assert F.isEmpty(res.invalidPartitions()) : res;
+ UUID nodeId = m.node().id();
+
for (Map.Entry<IgniteTxKey, CacheVersionedValue> entry : res.ownedValues().entrySet()) {
IgniteTxEntry txEntry = tx.entry(entry.getKey());
@@ -187,7 +189,7 @@ public abstract class GridNearTxPrepareFutureAdapter extends GridCompoundFuture<
CacheVersionedValue tup = entry.getValue();
nearEntry.resetFromPrimary(tup.value(), tx.xidVersion(),
- tup.version(), m.node().id(), tx.topologyVersion());
+ tup.version(), nodeId, tx.topologyVersion());
}
else if (txEntry.cached().detached()) {
GridDhtDetachedCacheEntry detachedEntry = (GridDhtDetachedCacheEntry)txEntry.cached();
@@ -230,7 +232,12 @@ public abstract class GridNearTxPrepareFutureAdapter extends GridCompoundFuture<
writeVer = res.dhtVersion();
// Register DHT version.
- tx.addDhtVersion(m.node().id(), res.dhtVersion(), writeVer);
+ tx.addDhtVersion(nodeId, res.dhtVersion(), writeVer);
+
+ assert tx.mappings().get(nodeId) == m;
+
+ // This step is very important as near and DHT versions grow separately.
+ cctx.versions().onReceived(nodeId, res.dhtVersion());
m.dhtVersion(res.dhtVersion(), writeVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5e2e120f/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java
index 21d3fb6..a33c35e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockSyncProcessor.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.util.GridBoundedConcurrentOrderedMap;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
@@ -71,6 +72,9 @@ public class GridClockSyncProcessor extends GridProcessorAdapter {
private NavigableMap<GridClockDeltaVersion, GridClockDeltaSnapshot> timeSyncHist =
new GridBoundedConcurrentOrderedMap<>(MAX_TIME_SYNC_HISTORY);
+ /** Last recorded. */
+ private volatile T2<GridClockDeltaVersion, GridClockDeltaSnapshot> lastSnapshot;
+
/** Time source. */
private GridClockSource clockSrc;
@@ -99,7 +103,11 @@ public class GridClockSyncProcessor extends GridProcessorAdapter {
GridClockDeltaVersion ver = msg0.snapshotVersion();
- timeSyncHist.put(ver, new GridClockDeltaSnapshot(ver, msg0.deltas()));
+ GridClockDeltaSnapshot snap = new GridClockDeltaSnapshot(ver, msg0.deltas());
+
+ lastSnapshot = new T2<>(ver, snap);
+
+ timeSyncHist.put(ver, snap);
}
});
@@ -265,15 +273,23 @@ public class GridClockSyncProcessor extends GridProcessorAdapter {
* @return Adjusted time.
*/
public long adjustedTime(long topVer) {
- // Get last synchronized time on given topology version.
- Map.Entry<GridClockDeltaVersion, GridClockDeltaSnapshot> entry = timeSyncHistory().lowerEntry(
- new GridClockDeltaVersion(0, topVer + 1));
+ T2<GridClockDeltaVersion, GridClockDeltaSnapshot> fastSnap = lastSnapshot;
+
+ GridClockDeltaSnapshot snap;
- GridClockDeltaSnapshot snap = entry == null ? null : entry.getValue();
+ if (fastSnap != null && fastSnap.get1().topologyVersion() == topVer)
+ snap = fastSnap.get2();
+ else {
+ // Get last synchronized time on given topology version.
+ Map.Entry<GridClockDeltaVersion, GridClockDeltaSnapshot> entry = timeSyncHistory().lowerEntry(
+ new GridClockDeltaVersion(0, topVer + 1));
+
+ snap = entry == null ? null : entry.getValue();
+ }
long now = clockSrc.currentTimeMillis();
- if (snap == null)
+ if (snap == null)
return now;
Long delta = snap.deltas().get(ctx.localNodeId());
@@ -295,6 +311,8 @@ public class GridClockSyncProcessor extends GridProcessorAdapter {
return;
try {
+ lastSnapshot = new T2<>(snapshot.version(), snapshot);
+
timeSyncHist.put(snapshot.version(), snapshot);
for (ClusterNode n : top.topologyNodes()) {