Repository: ignite Updated Branches: refs/heads/ignite-db-x-opt [created] a54009102
ignite-db-x-opt Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7493f23b Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7493f23b Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7493f23b Branch: refs/heads/ignite-db-x-opt Commit: 7493f23ba1c5578aacaa9d49aef9ff3e826f323b Parents: 8290c8b Author: sboikov <[email protected]> Authored: Wed Dec 14 10:24:03 2016 +0300 Committer: sboikov <[email protected]> Committed: Wed Dec 14 10:24:03 2016 +0300 ---------------------------------------------------------------------- .../ignite/internal/GridKernalContext.java | 3 + .../ignite/internal/GridKernalContextImpl.java | 35 +++++++++ .../cache/GridCacheConcurrentMapImpl.java | 83 ++++++++++---------- .../processors/cache/GridCacheMapEntry.java | 12 +-- .../cache/IgniteCacheOffheapManagerImpl.java | 69 +++++++++++++--- .../processors/cache/IgniteCacheProxy.java | 10 +++ .../binary/CacheObjectBinaryProcessorImpl.java | 2 +- .../cache/database/CacheDataRowAdapter.java | 2 +- .../cache/database/MetadataStorage.java | 2 +- .../cache/database/tree/BPlusTree.java | 12 +-- .../cache/database/tree/io/DataPageIO.java | 2 +- .../dht/atomic/GridDhtAtomicCache.java | 19 +++++ .../GridNearAtomicSingleUpdateFuture.java | 4 +- .../ignite/internal/util/DebugStatistic.java | 60 ++++++++++++++ .../ignite/internal/util/DebugStatistics.java | 47 +++++++++++ .../processors/database/BPlusTreeSelfTest.java | 2 +- .../processors/query/h2/database/H2Tree.java | 2 +- .../query/h2/database/H2TreeIndex.java | 2 +- 18 files changed, 292 insertions(+), 76 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index a4397c5..556d8d8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -63,6 +63,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor; import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor; import org.apache.ignite.internal.processors.task.GridTaskProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.DebugStatistic; import org.apache.ignite.internal.util.IgniteExceptionRegistry; import org.apache.ignite.internal.util.tostring.GridToStringExclude; import org.apache.ignite.plugin.PluginNotFoundException; @@ -604,4 +605,6 @@ public interface GridKernalContext extends Iterable<GridComponent> { * @return Platform processor. */ public PlatformProcessor platform(); + + public DebugStatistic addStatistic(String name); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index 28f0907..0db19bd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -80,6 +80,8 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor; import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor; import org.apache.ignite.internal.processors.task.GridTaskProcessor; import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor; +import org.apache.ignite.internal.util.DebugStatistic; +import org.apache.ignite.internal.util.DebugStatistics; import org.apache.ignite.internal.util.IgniteExceptionRegistry; import org.apache.ignite.internal.util.spring.IgniteSpringHelper; import org.apache.ignite.internal.util.tostring.GridToStringExclude; @@ -353,6 +355,9 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable /** */ private volatile boolean disconnected; + /** */ + private DebugStatistics debugStatistics; + /** * No-arg constructor is required by externalization. */ @@ -429,6 +434,31 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable log.debug("Failed to load spring component, will not be able to extract userVersion from " + "META-INF/ignite.xml."); } + + debugStatistics = new DebugStatistics(); + + final DebugStatistics stat0 = debugStatistics; + + final IgniteLogger log0 = log(getClass()); + + Thread thread = new Thread() { + @Override public void run() { + try { + while (true) { + stat0.dump(log0); + + Thread.sleep(5000); + } + } + catch (Exception e) { + e.printStackTrace(); + } + } + }; + + thread.setDaemon(true); + + thread.start(); } /** {@inheritDoc} */ @@ -1014,6 +1044,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable } /** {@inheritDoc} */ + @Override public DebugStatistic addStatistic(String name) { + return debugStatistics.add(name); + } + + /** {@inheritDoc} */ @Override public String toString() { return S.toString(GridKernalContextImpl.class, this); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java index 48dae76..5f21c42 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapImpl.java @@ -111,7 +111,6 @@ public class GridCacheConcurrentMapImpl implements GridCacheConcurrentMap { /** {@inheritDoc} */ @Nullable @Override public GridCacheMapEntry putEntryIfObsoleteOrAbsent(final AffinityTopologyVersion topVer, KeyCacheObject key, @Nullable final CacheObject val, final boolean create, final boolean touch) { - GridCacheMapEntry cur = null; GridCacheMapEntry created = null; GridCacheMapEntry created0 = null; @@ -127,7 +126,7 @@ public class GridCacheConcurrentMapImpl implements GridCacheConcurrentMap { if (entry == null) { if (create) { if (created0 == null) - created0 = factory.create(ctx, topVer, key, key.hashCode(), val); + created0 = factory.create(ctx, topVer, key, 0, val); cur = created = created0; @@ -142,7 +141,7 @@ public class GridCacheConcurrentMapImpl implements GridCacheConcurrentMap { if (create) { if (created0 == null) - created0 = factory.create(ctx, topVer, key, key.hashCode(), val); + created0 = factory.create(ctx, topVer, key, 0, val); cur = created = created0; @@ -162,46 +161,46 @@ public class GridCacheConcurrentMapImpl implements GridCacheConcurrentMap { int sizeChange = 0; if (doomed != null) { - synchronized (doomed) { - if (!doomed.deleted()) - sizeChange--; - } - - if (ctx.events().isRecordable(EVT_CACHE_ENTRY_DESTROYED)) - ctx.events().addEvent(doomed.partition(), - doomed.key(), - ctx.localNodeId(), - (IgniteUuid)null, - null, - EVT_CACHE_ENTRY_DESTROYED, - null, - false, - null, - false, - null, - null, - null, - true); +// synchronized (doomed) { +// if (!doomed.deleted()) +// sizeChange--; +// } +// +// if (ctx.events().isRecordable(EVT_CACHE_ENTRY_DESTROYED)) +// ctx.events().addEvent(doomed.partition(), +// doomed.key(), +// ctx.localNodeId(), +// (IgniteUuid)null, +// null, +// EVT_CACHE_ENTRY_DESTROYED, +// null, +// false, +// null, +// false, +// null, +// null, +// null, +// true); } if (created != null) { - sizeChange++; - - if (ctx.events().isRecordable(EVT_CACHE_ENTRY_CREATED)) - ctx.events().addEvent(created.partition(), - created.key(), - ctx.localNodeId(), - (IgniteUuid)null, - null, - EVT_CACHE_ENTRY_CREATED, - null, - false, - null, - false, - null, - null, - null, - true); + //sizeChange++; + +// if (ctx.events().isRecordable(EVT_CACHE_ENTRY_CREATED)) +// ctx.events().addEvent(created.partition(), +// created.key(), +// ctx.localNodeId(), +// (IgniteUuid)null, +// null, +// EVT_CACHE_ENTRY_CREATED, +// null, +// false, +// null, +// false, +// null, +// null, +// null, +// true); if (touch) ctx.evicts().touch( @@ -209,8 +208,8 @@ public class GridCacheConcurrentMapImpl implements GridCacheConcurrentMap { topVer); } - if (sizeChange != 0) - pubSize.addAndGet(sizeChange); +// if (sizeChange != 0) +// pubSize.addAndGet(sizeChange); return cur; } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/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 ddded58..7a577d6 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 @@ -2798,15 +2798,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme return true; } - /** - * Gets hash value for the entry key. - * - * @return Hash value. - */ - int hash() { - return hash; - } - /** {@inheritDoc} */ @Nullable @Override public CacheObject peek( boolean heap, @@ -4071,6 +4062,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme /** {@inheritDoc} */ @Override public boolean equals(Object o) { + if (true) + throw new IgniteException("Error"); + // Identity comparison left on purpose. return o == this; } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java index 9ba785c..084b938 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java @@ -50,6 +50,7 @@ import org.apache.ignite.internal.processors.cache.local.GridLocalCache; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.GridQueryProcessor; +import org.apache.ignite.internal.util.DebugStatistic; import org.apache.ignite.internal.util.GridAtomicLong; import org.apache.ignite.internal.util.GridCloseableIteratorAdapter; import org.apache.ignite.internal.util.GridEmptyCloseableIterator; @@ -93,6 +94,18 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple /** */ private final GridAtomicLong globalRmvId = new GridAtomicLong(U.currentTimeMillis() * 1000_000); + /** */ + private DebugStatistic storeAddStat; + + /** */ + private DebugStatistic storeRmvStat; + + /** */ + private DebugStatistic treePutStat; + + /** */ + private DebugStatistic treeFindOneStat; + /** {@inheritDoc} */ @Override public GridAtomicLong globalRemoveId() { return globalRmvId; @@ -120,6 +133,11 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple cctx.shared().database().checkpointReadUnlock(); } } + + storeAddStat = cctx.kernalContext().addStatistic(cctx.name() + "-storeAdd"); + storeRmvStat = cctx.kernalContext().addStatistic(cctx.name() + "-storeRmv"); + treePutStat = cctx.kernalContext().addStatistic(cctx.name() + "-treePut"); + treeFindOneStat = cctx.kernalContext().addStatistic(cctx.name() + "-treeFindOne"); } /** @@ -833,16 +851,27 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple key.valueBytes(cctx.cacheObjectContext()); val.valueBytes(cctx.cacheObjectContext()); + long start = storeAddStat.start(); + rowStore.addRow(dataRow); + storeAddStat.addTime(start); + assert dataRow.link() != 0 : dataRow; + start = treePutStat.start(); + DataRow old = dataTree.put(dataRow); + treePutStat.addTime(start); + if (old == null) storageSize.incrementAndGet(); if (indexingEnabled) { + if (true) + throw new IgniteException("Error"); + GridCacheQueryManager qryMgr = cctx.queries(); assert qryMgr.enabled(); @@ -856,14 +885,26 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple if (old != null) { assert old.link() != 0 : old; - if (pendingEntries != null && old.expireTime() != 0) + if (pendingEntries != null && old.expireTime() != 0) { + if (true) + throw new IgniteException("Error"); + pendingEntries.remove(new PendingRow(old.expireTime(), old.link())); + } + + start = storeRmvStat.start(); rowStore.removeRow(old.link()); + + storeRmvStat.addTime(start); } - if (pendingEntries != null && expireTime != 0) + if (pendingEntries != null && expireTime != 0) { + if (true) + throw new IgniteException("Error"); + pendingEntries.put(new PendingRow(expireTime, dataRow.link())); + } } /** {@inheritDoc} */ @@ -901,7 +942,14 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple /** {@inheritDoc} */ @Override public CacheDataRow find(KeyCacheObject key) throws IgniteCheckedException { - return dataTree.findOne(new KeySearchRow(key.hashCode(), key, 0)); + long start = treeFindOneStat.start(); + + try { + return dataTree.findOne(new KeySearchRow(key.hashCode(), key, 0)); + } + finally { + treeFindOneStat.addTime(start); + } } /** {@inheritDoc} */ @@ -1006,13 +1054,14 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple * @param hash Hash code. * @param link Link. */ - DataRow(int hash, long link) { + DataRow(int hash, long link, boolean put) { super(hash, null, link); part = PageIdUtils.partId(link); // We can not init data row lazily because underlying buffer can be concurrently cleared. - initData(false); + if (!put) + initData(false); } /** @@ -1100,12 +1149,12 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple } /** {@inheritDoc} */ - @Override protected DataRow getRow(BPlusIO<KeySearchRow> io, ByteBuffer buf, int idx) + @Override protected DataRow getRow(BPlusIO<KeySearchRow> io, ByteBuffer buf, int idx, boolean put) throws IgniteCheckedException { int hash = ((RowLinkIO)io).getHash(buf, idx); long link = ((RowLinkIO)io).getLink(buf, idx); - return rowStore.dataRow(hash, link); + return rowStore.dataRow(hash, link, put); } /** @@ -1158,8 +1207,8 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple * @param link Link. * @return Data row. */ - private DataRow dataRow(int hash, long link) { - return new DataRow(hash, link); + private DataRow dataRow(int hash, long link, boolean put) { + return new DataRow(hash, link, put); } } @@ -1406,7 +1455,7 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple } /** {@inheritDoc} */ - @Override protected PendingRow getRow(BPlusIO<PendingRow> io, ByteBuffer buf, int idx) + @Override protected PendingRow getRow(BPlusIO<PendingRow> io, ByteBuffer buf, int idx, boolean put) throws IgniteCheckedException { return io.getLookupRow(this, buf, idx); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 789bfd2..8908a11 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -70,6 +70,7 @@ import org.apache.ignite.internal.processors.cache.query.CacheQuery; import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; import org.apache.ignite.internal.processors.query.GridQueryProcessor; +import org.apache.ignite.internal.util.DebugStatistic; import org.apache.ignite.internal.util.GridCloseableIteratorAdapter; import org.apache.ignite.internal.util.GridEmptyIterator; import org.apache.ignite.internal.util.future.IgniteFutureImpl; @@ -135,6 +136,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V @GridToStringExclude private boolean lock; + /** */ + private DebugStatistic putStat; + /** * Empty constructor required for {@link Externalizable}. */ @@ -185,6 +189,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V internalProxy = new GridCacheProxyImpl<>(ctx, delegate, opCtx); this.lock = lock; + + putStat = ctx.kernalContext().addStatistic(ctx.name() + "-put"); } /** @@ -1345,6 +1351,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V /** {@inheritDoc} */ @Override public void put(K key, V val) { try { + long start = putStat.start(); + GridCacheGateway<K, V> gate = this.gate; CacheOperationContext prev = onEnter(gate, opCtx); @@ -1373,6 +1381,8 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V } finally { onLeave(gate, prev); + + putStat.addTime(start); } } catch (IgniteCheckedException e) { http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java index 608e194..aecbc5f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java @@ -203,7 +203,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm assert metaDataCache != null; - CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(binaryCtx)); + //CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(binaryCtx)); } @Override public BinaryType metadata(int typeId) throws BinaryObjectException { http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java index b5babc4..b1390c9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/CacheDataRowAdapter.java @@ -55,7 +55,7 @@ public class CacheDataRowAdapter implements CacheDataRow { protected CacheObject val; /** */ - protected long expireTime = -1; + protected long expireTime; /** */ @GridToStringInclude http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java index 26151ac..6f085fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/MetadataStorage.java @@ -213,7 +213,7 @@ public class MetadataStorage implements MetaStore { /** {@inheritDoc} */ @Override protected IndexItem getRow(final BPlusIO<IndexItem> io, final ByteBuffer buf, - final int idx) throws IgniteCheckedException { + final int idx, boolean put) throws IgniteCheckedException { return readRow(buf, ((IndexIO)io).getOffset(idx)); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java index 0e41307..dafff25 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/BPlusTree.java @@ -319,7 +319,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure { assert p.oldRow == null; // Get old row in leaf page to reduce contention at upper level. - p.oldRow = getRow(io, buf, idx); + p.oldRow = getRow(io, buf, idx, true); p.finish(); @@ -1181,7 +1181,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure { if (i != 0) b.append(','); - b.append(io.isLeaf() || canGetRowFromInner ? getRow(io, buf, i) : io.getLookupRow(this, buf, i)); + b.append(io.isLeaf() || canGetRowFromInner ? getRow(io, buf, i, false) : io.getLookupRow(this, buf, i)); } b.append(']'); @@ -2032,7 +2032,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure { if (lvl != 0 && !canGetRowFromInner) return false; - row = getRow(io, buf, idx); + row = getRow(io, buf, idx, false); return true; } @@ -2779,7 +2779,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure { assert !isRemoved(): "already removed"; // Detach the row. - removed = getRow(io, buf, idx); + removed = getRow(io, buf, idx, false); doRemove(page, io, buf, cnt, idx); @@ -3440,7 +3440,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure { * @return Full detached data row. * @throws IgniteCheckedException If failed. */ - protected abstract T getRow(BPlusIO<L> io, ByteBuffer buf, int idx) throws IgniteCheckedException; + protected abstract T getRow(BPlusIO<L> io, ByteBuffer buf, int idx, boolean put) throws IgniteCheckedException; /** * Forward cursor. @@ -3584,7 +3584,7 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure { rows = (T[])new Object[cnt]; for (int i = 0; i < cnt; i++) { - T r = getRow(io, buf, startIdx + i); + T r = getRow(io, buf, startIdx + i, false); rows = GridArrays.set(rows, i, r); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/DataPageIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/DataPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/DataPageIO.java index a69caab..6d05cd8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/DataPageIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/io/DataPageIO.java @@ -1125,7 +1125,7 @@ public class DataPageIO extends PageIO { * @return New first entry offset. */ private int compactDataEntries(ByteBuffer buf, int directCnt) { - assert checkCount(directCnt): directCnt; + assert checkCount(directCnt) : directCnt; int[] offs = new int[directCnt]; http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index 1a02a2c..c3a7ca1 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -81,6 +81,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext; import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx; +import org.apache.ignite.internal.util.DebugStatistic; import org.apache.ignite.internal.util.GridUnsafe; import org.apache.ignite.internal.util.future.GridEmbeddedFuture; import org.apache.ignite.internal.util.future.GridFinishedFuture; @@ -228,6 +229,12 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { }; } + /** */ + private DebugStatistic updateStat; + + /** */ + private DebugStatistic lockStat; + /** {@inheritDoc} */ @SuppressWarnings({"IfMayBeConditional", "SimplifiableIfStatement"}) @Override public void start() throws IgniteCheckedException { @@ -291,6 +298,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { preldr.start(); + updateStat = ctx.kernalContext().addStatistic("update-" + cacheCfg.getName()); + lockStat = ctx.kernalContext().addStatistic("lock-" + cacheCfg.getName()); + ctx.io().addHandler( ctx.cacheId(), GridNearGetRequest.class, @@ -1689,6 +1699,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { GridNearAtomicAbstractUpdateRequest req, CI2<GridNearAtomicAbstractUpdateRequest, GridNearAtomicUpdateResponse> completionCb ) { + long start = updateStat.start(); + GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(ctx.cacheId(), nodeId, req.futureVersion(), ctx.deploymentEnabled()); @@ -1705,8 +1717,12 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { try { // If batch store update is enabled, we need to lock all entries. // First, need to acquire locks on cache entries, then check filter. + long lockStart = lockStat.start(); + List<GridDhtCacheEntry> locked = lockEntries(req, req.topologyVersion()); + lockStat.addTime(lockStart); + Collection<IgniteBiTuple<GridDhtCacheEntry, GridCacheVersion>> deleted = null; try { @@ -1876,6 +1892,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { return; } + finally { + updateStat.addTime(start); + } if (remap) { assert dhtFut == null; http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java index fcf1ecd..ea3bd43 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateFuture.java @@ -384,7 +384,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda /** {@inheritDoc} */ @Override protected void mapOnTopology() { - cache.topology().readLock(); + //cache.topology().readLock(); AffinityTopologyVersion topVer = null; @@ -430,7 +430,7 @@ public class GridNearAtomicSingleUpdateFuture extends GridNearAtomicAbstractUpda } } finally { - cache.topology().readUnlock(); + //cache.topology().readUnlock(); } map(topVer); http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistic.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistic.java b/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistic.java new file mode 100644 index 0000000..e1f0619 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistic.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.util; + +import org.jsr166.LongAdder8; + +/** + * + */ +public class DebugStatistic { + /** */ + private final String name; + + /** */ + private final LongAdder8 time = new LongAdder8(); + + /** */ + private final LongAdder8 cnt = new LongAdder8(); + + DebugStatistic(String name) { + this.name = name; + } + + public long start() { + return System.nanoTime(); + } + + public String name() { + return name; + } + + public void addTime(long start) { + time.add(System.nanoTime() - start); + + cnt.increment(); + } + + public LongAdder8 time() { + return time; + } + + public LongAdder8 count() { + return cnt; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistics.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistics.java b/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistics.java new file mode 100644 index 0000000..c094192 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/DebugStatistics.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.util; + +import java.util.concurrent.CopyOnWriteArrayList; +import org.apache.ignite.IgniteLogger; + +/** + * + */ +public class DebugStatistics { + /** */ + private final CopyOnWriteArrayList<DebugStatistic> stats = new CopyOnWriteArrayList<>(); + + public DebugStatistic add(String name) { + DebugStatistic stat = new DebugStatistic(name); + + stats.add(stat); + + return stat; + } + + public void dump(IgniteLogger log) { + for (DebugStatistic stat : stats) { + long cnt = stat.count().sumThenReset(); + long time = stat.time().sumThenReset(); + + if (cnt > 0) + log.info("Statistic [name=" + stat.name() + ", cnt=" + time + ", avg=" + (time / (double)cnt) + ']'); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java index 4bc39ea..e1f66a9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/BPlusTreeSelfTest.java @@ -1207,7 +1207,7 @@ public class BPlusTreeSelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ - @Override protected Long getRow(BPlusIO<Long> io, ByteBuffer buf, int idx) throws IgniteCheckedException { + @Override protected Long getRow(BPlusIO<Long> io, ByteBuffer buf, int idx, boolean put) throws IgniteCheckedException { assert io.canGetRow() : io; return io.getLookupRow(this, buf, idx); http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java index 0593c60..d5c6337 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2Tree.java @@ -76,7 +76,7 @@ public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row> { } /** {@inheritDoc} */ - @Override protected GridH2Row getRow(BPlusIO<SearchRow> io, ByteBuffer buf, int idx) + @Override protected GridH2Row getRow(BPlusIO<SearchRow> io, ByteBuffer buf, int idx, boolean put) throws IgniteCheckedException { return (GridH2Row)io.getLookupRow(this, buf, idx); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7493f23b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java index 8bd8ebe..e1babc7 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/database/H2TreeIndex.java @@ -90,7 +90,7 @@ public class H2TreeIndex extends GridH2IndexBase { tbl.rowFactory(), page.pageId().pageId(), page.isAllocated()) { @Override protected int compare(BPlusIO<SearchRow> io, ByteBuffer buf, int idx, SearchRow row) throws IgniteCheckedException { - return compareRows(getRow(io, buf, idx), row); + return compareRows(getRow(io, buf, idx, false), row); } };
