ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [05/12] ignite git commit: GC pressure
Date Thu, 06 Apr 2017 17:02:51 GMT
GC pressure


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

Branch: refs/heads/ignite-3477-master
Commit: 682f3bed2e8c7dee4f13d11c8fc5d3cf856934c5
Parents: 37eed34
Author: Igor Seliverstov <gvvinblade@gmail.com>
Authored: Tue Mar 28 19:28:20 2017 +0300
Committer: Igor Seliverstov <gvvinblade@gmail.com>
Committed: Tue Mar 28 19:28:20 2017 +0300

----------------------------------------------------------------------
 .../ignite/internal/pagemem/PageSupport.java    |  6 ++--
 .../pagemem/impl/PageMemoryNoStoreImpl.java     | 18 +++++-----
 .../cache/database/freelist/FreeListImpl.java   |  4 +--
 .../cache/database/freelist/PagesList.java      | 38 ++++++++++----------
 .../cache/database/tree/BPlusTree.java          | 10 +++---
 .../cache/database/tree/util/PageHandler.java   | 24 ++++---------
 .../processors/query/h2/database/H2Tree.java    |  1 +
 7 files changed, 47 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageSupport.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageSupport.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageSupport.java
index 7d1f711..8076f28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageSupport.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/PageSupport.java
@@ -66,7 +66,8 @@ public interface PageSupport {
      * @param cacheId Cache ID.
      * @param pageId Page ID.
      * @param page Page pointer.
-     * @return ByteBuffer for modifying the page.
+     * @return Address of a buffer with contents of the given page or
+     *            {@code 0L} if attempt to take the write lock failed.
      */
     public long writeLock(int cacheId, long pageId, long page);
 
@@ -75,7 +76,8 @@ public interface PageSupport {
      * @param cacheId Cache ID.
      * @param pageId Page ID.
      * @param page Page pointer.
-     * @return ByteBuffer for modifying the page of {@code null} if failed to get write lock.
+     * @return Address of a buffer with contents of the given page or
+     *            {@code 0L} if attempt to take the write lock failed.
      */
     public long tryWriteLock(int cacheId, long pageId, long page);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
index 7afd5bd..0b65ce6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/impl/PageMemoryNoStoreImpl.java
@@ -66,7 +66,7 @@ import static org.apache.ignite.internal.util.GridUnsafe.wrapPointer;
 @SuppressWarnings({"LockAcquiredButNotSafelyReleased", "FieldAccessedSynchronizedAndUnsynchronized"})
 public class PageMemoryNoStoreImpl implements PageMemory {
     /** */
-    private static final long PAGE_MARKER = 0xBEEAAFDEADBEEF01L;
+    public static final long PAGE_MARKER = 0xBEEAAFDEADBEEF01L;
 
     /** Full relative pointer mask. */
     private static final long RELATIVE_PTR_MASK = 0xFFFFFFFFFFFFFFL;
@@ -84,16 +84,16 @@ public class PageMemoryNoStoreImpl implements PageMemory {
     private static final long COUNTER_INC = ADDRESS_MASK + 1;
 
     /** Page ID offset. */
-    private static final int PAGE_ID_OFFSET = 8;
+    public static final int PAGE_ID_OFFSET = 8;
 
     /** Page pin counter offset. */
-    private static final int LOCK_OFFSET = 16;
+    public static final int LOCK_OFFSET = 16;
 
     /**
      * Need a 8-byte pointer for linked list, 8 bytes for internal needs (flags),
      * 4 bytes cache ID, 8 bytes timestamp.
      */
-    static final int PAGE_OVERHEAD = LOCK_OFFSET + OffheapReadWriteLock.LOCK_SIZE;
+    public static final int PAGE_OVERHEAD = LOCK_OFFSET + OffheapReadWriteLock.LOCK_SIZE;
 
     /** Page size. */
     private int sysPageSize;
@@ -386,7 +386,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
 
         Segment seg = segment(pageIdx);
 
-        return seg.acquire(pageIdx);
+        return seg.acquirePage(pageIdx);
     }
 
     /** {@inheritDoc} */
@@ -505,7 +505,7 @@ public class PageMemoryNoStoreImpl implements PageMemory {
          * @param pageIdx Page index.
          * @return Page absolute pointer.
          */
-        private long acquire(int pageIdx) {
+        private long acquirePage(int pageIdx) {
             long absPtr = absolute(pageIdx);
 
             assert absPtr % 8 == 0 : absPtr;
@@ -589,12 +589,12 @@ public class PageMemoryNoStoreImpl implements PageMemory {
                 long cnt = ((freePageRelPtrMasked & COUNTER_MASK) + COUNTER_INC) &
COUNTER_MASK;
 
                 if (freePageRelPtr != INVALID_REL_PTR) {
-                    long freePage = absolute(PageIdUtils.pageIndex(freePageRelPtr));
+                    long freePageAbsPtr = absolute(PageIdUtils.pageIndex(freePageRelPtr));
 
-                    long nextFreePageRelPtr = GridUnsafe.getLong(freePage) & ADDRESS_MASK;
+                    long nextFreePageRelPtr = GridUnsafe.getLong(freePageAbsPtr) & ADDRESS_MASK;
 
                     if (GridUnsafe.compareAndSwapLong(null, freePageListPtr, freePageRelPtrMasked,
nextFreePageRelPtr | cnt)) {
-                        GridUnsafe.putLong(freePage, PAGE_MARKER);
+                        GridUnsafe.putLong(freePageAbsPtr, PAGE_MARKER);
 
                         allocatedPages.incrementAndGet();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeListImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeListImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeListImpl.java
index 4d3270c..8ca95f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeListImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/FreeListImpl.java
@@ -400,7 +400,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
      * @return Page ID.
      * @throws IgniteCheckedException If failed.
      */
-    private long allocate(int part) throws IgniteCheckedException {
+    private long allocateDataPage(int part) throws IgniteCheckedException {
         assert part <= PageIdAllocator.MAX_PARTITION_ID;
         assert part != PageIdAllocator.INDEX_PARTITION;
 
@@ -438,7 +438,7 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList
{
             boolean allocated = pageId == 0L;
 
             if(allocated)
-                pageId = allocate(row.partition());
+                pageId = allocateDataPage(row.partition());
 
             DataPageIO init = reuseBucket || allocated ? DataPageIO.VERSIONS.latest() : null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
index 6c51096..4cf38ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/freelist/PagesList.java
@@ -257,12 +257,12 @@ public abstract class PagesList extends DataStructure {
         assert metaPageId != 0;
 
         long curId = 0L;
-        long cur = 0L;
+        long curPage = 0L;
         long curAddr = 0L;
 
         PagesListMetaIO curIo = null;
 
-        long nextId = metaPageId;
+        long nextPageId = metaPageId;
 
         try {
             for (int bucket = 0; bucket < buckets; bucket++) {
@@ -275,36 +275,36 @@ public abstract class PagesList extends DataStructure {
                         int written = curAddr != 0L ? curIo.addTails(pageMem.pageSize(),
curAddr, bucket, tails, tailIdx) : 0;
 
                         if (written == 0) {
-                            if (nextId == 0L) {
-                                nextId = allocatePageNoReuse();
+                            if (nextPageId == 0L) {
+                                nextPageId = allocatePageNoReuse();
 
                                 if (curAddr != 0L) {
-                                    curIo.setNextMetaPageId(curAddr, nextId);
+                                    curIo.setNextMetaPageId(curAddr, nextPageId);
 
-                                    releaseAndClose(curId, cur, curAddr);
+                                    releaseAndClose(curId, curPage, curAddr);
                                 }
 
-                                curId = nextId;
-                                cur = acquirePage(curId);
-                                curAddr = writeLock(curId, cur);
+                                curId = nextPageId;
+                                curPage = acquirePage(curId);
+                                curAddr = writeLock(curId, curPage);
 
                                 curIo = PagesListMetaIO.VERSIONS.latest();
 
                                 curIo.initNewPage(curAddr, curId, pageSize());
                             }
                             else {
-                                releaseAndClose(curId, cur, curAddr);
+                                releaseAndClose(curId, curPage, curAddr);
 
-                                curId = nextId;
-                                cur = acquirePage(curId);
-                                curAddr = writeLock(curId, cur);
+                                curId = nextPageId;
+                                curPage = acquirePage(curId);
+                                curAddr = writeLock(curId, curPage);
 
                                 curIo = PagesListMetaIO.VERSIONS.forPage(curAddr);
 
                                 curIo.resetCount(curAddr);
                             }
 
-                            nextId = curIo.getNextMetaPageId(curAddr);
+                            nextPageId = curIo.getNextMetaPageId(curAddr);
                         }
                         else
                             tailIdx += written;
@@ -313,11 +313,11 @@ public abstract class PagesList extends DataStructure {
             }
         }
         finally {
-            releaseAndClose(curId, cur, curAddr);
+            releaseAndClose(curId, curPage, curAddr);
         }
 
-        while (nextId != 0L) {
-            long pageId = nextId;
+        while (nextPageId != 0L) {
+            long pageId = nextPageId;
 
             long page = acquirePage(pageId);
             try {
@@ -331,7 +331,7 @@ public abstract class PagesList extends DataStructure {
                     if (needWalDeltaRecord(pageId, page, null))
                         wal.log(new PageListMetaResetCountRecord(cacheId, pageId));
 
-                    nextId = io.getNextMetaPageId(pageAddr);
+                    nextPageId = io.getNextMetaPageId(pageAddr);
                 }
                 finally {
                     writeUnlock(pageId, page, pageAddr, true);
@@ -350,7 +350,7 @@ public abstract class PagesList extends DataStructure {
      * @throws IgniteCheckedException If failed.
      */
     private void releaseAndClose(long pageId, long page, long pageAddr) throws IgniteCheckedException
{
-        if (pageAddr != 0L) {
+        if (pageAddr != 0L && page != 0L) {
             try {
                 // No special WAL record because we most likely changed the whole page.
                 writeUnlock(pageId, page, pageAddr, TRUE, true);

http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/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 5a8c49c..7be8297 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
@@ -1835,10 +1835,10 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
         long cnt = 0;
 
         while (pageId != 0) {
-            long pageId0 = pageId;
-            long page = acquirePage(pageId0);
+            long curId = pageId;
+            long curPage = acquirePage(curId);
             try {
-                long curAddr = readLock(pageId0, page); // No correctness guaranties.
+                long curAddr = readLock(curId, curPage); // No correctness guaranties.
 
                 try {
                     if (io == null) {
@@ -1852,11 +1852,11 @@ public abstract class BPlusTree<L, T extends L> extends DataStructure
implements
                     pageId = io.getForward(curAddr);
                 }
                 finally {
-                    readUnlock(pageId0, page, curAddr);
+                    readUnlock(curId, curPage, curAddr);
                 }
             }
             finally {
-                releasePage(pageId0, page);
+                releasePage(curId, curPage);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
index f660686..0ca2abc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/tree/util/PageHandler.java
@@ -176,15 +176,11 @@ public abstract class PageHandler<X, R> {
         long pageId,
         long page,
         PageLockListener lsnr) {
-        boolean notifyLsnr = lsnr != null;
-
-        if(notifyLsnr)
-            lsnr.onBeforeReadLock(cacheId, pageId, page);
+        lsnr.onBeforeReadLock(cacheId, pageId, page);
 
         long pageAddr = pageMem.readLock(cacheId, pageId, page);
 
-        if(notifyLsnr)
-            lsnr.onReadLock(cacheId, pageId, page, pageAddr);
+        lsnr.onReadLock(cacheId, pageId, page, pageAddr);
 
         return pageAddr;
     }
@@ -204,8 +200,7 @@ public abstract class PageHandler<X, R> {
         long page,
         long pageAddr,
         PageLockListener lsnr) {
-        if(lsnr != null)
-            lsnr.onReadUnlock(cacheId, pageId, page, pageAddr);
+        lsnr.onReadUnlock(cacheId, pageId, page, pageAddr);
 
         pageMem.readUnlock(cacheId, pageId, page);
     }
@@ -294,7 +289,7 @@ public abstract class PageHandler<X, R> {
             }
         }
         finally {
-            if(releaseAfterWrite)
+            if (releaseAfterWrite)
                 pageMem.releasePage(cacheId, pageId, page);
         }
     }
@@ -379,8 +374,7 @@ public abstract class PageHandler<X, R> {
         PageLockListener lsnr,
         Boolean walPlc,
         boolean dirty) {
-        if(lsnr != null)
-            lsnr.onWriteUnlock(cacheId, pageId, page, pageAddr);
+        lsnr.onWriteUnlock(cacheId, pageId, page, pageAddr);
 
         pageMem.writeUnlock(cacheId, pageId, page, walPlc, dirty);
     }
@@ -401,15 +395,11 @@ public abstract class PageHandler<X, R> {
         long page,
         PageLockListener lsnr,
         boolean tryLock) {
-        boolean notifyLsnr = lsnr != null;
-
-        if(notifyLsnr)
-            lsnr.onBeforeWriteLock(cacheId, pageId, page);
+        lsnr.onBeforeWriteLock(cacheId, pageId, page);
 
         long pageAddr = tryLock ? pageMem.tryWriteLock(cacheId, pageId, page) : pageMem.writeLock(cacheId,
pageId, page);
 
-        if(notifyLsnr)
-            lsnr.onWriteLock(cacheId, pageId, page, pageAddr);
+        lsnr.onWriteLock(cacheId, pageId, page, pageAddr);
 
         return pageAddr;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/682f3bed/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 d7f5b29..f673717 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
@@ -136,6 +136,7 @@ public abstract class H2Tree extends BPlusTree<SearchRow, GridH2Row>
{
      */
     private int getMetaInlineSize() throws IgniteCheckedException {
         final long metaPage = acquirePage(metaPageId);
+
         try {
             long pageAddr = readLock(metaPageId, metaPage); // Meta can't be removed.
 


Mime
View raw message