Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F24B188E9 for ; Wed, 2 Dec 2015 00:19:58 +0000 (UTC) Received: (qmail 29049 invoked by uid 500); 2 Dec 2015 00:19:53 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 29011 invoked by uid 500); 2 Dec 2015 00:19:53 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 28998 invoked by uid 99); 2 Dec 2015 00:19:53 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2015 00:19:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A48981A08B5 for ; Wed, 2 Dec 2015 00:06:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.227 X-Spam-Level: * X-Spam-Status: No, score=1.227 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id BE_r1AbLzqoa for ; Wed, 2 Dec 2015 00:06:11 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 3FD1959659 for ; Wed, 2 Dec 2015 00:06:10 +0000 (UTC) Received: (qmail 89885 invoked by uid 99); 2 Dec 2015 00:06:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2015 00:06:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 54BBFE0C6D; Wed, 2 Dec 2015 00:06:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dschneider@apache.org To: commits@geode.incubator.apache.org Date: Wed, 02 Dec 2015 00:06:14 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/13] incubator-geode git commit: more smai test methods and test cleanupp more smai test methods and test cleanupp Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/2e83b6cf Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/2e83b6cf Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/2e83b6cf Branch: refs/heads/feature/GEODE-607 Commit: 2e83b6cf1c23b1e061881d5cd6aa011fa762c894 Parents: bf91a60 Author: Darrel Schneider Authored: Wed Nov 25 15:35:31 2015 -0800 Committer: Darrel Schneider Committed: Wed Nov 25 15:35:31 2015 -0800 ---------------------------------------------------------------------- .../offheap/SimpleMemoryAllocatorJUnitTest.java | 42 ++++++++------------ 1 file changed, 17 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/2e83b6cf/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java index d2c24f5..b09087d 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/offheap/SimpleMemoryAllocatorJUnitTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.fail; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; @@ -52,12 +53,9 @@ public class SimpleMemoryAllocatorJUnitTest { public void testBasics() { int BATCH_SIZE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.BATCH_SIZE; int TINY_MULTIPLE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.TINY_MULTIPLE; -// int BIG_MULTIPLE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.FreeListManager.BIG_MULTIPLE; int HUGE_MULTIPLE = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.HUGE_MULTIPLE; int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE; int maxTiny = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.MAX_TINY-perObjectOverhead; -// int MIN_BIG_SIZE = round(BIG_MULTIPLE, maxTiny+perObjectOverhead+1)-perObjectOverhead; -// int maxBig = com.gemstone.gemfire.internal.offheap.SimpleMemoryAllocatorImpl.FreeListManager.MAX_BIG-perObjectOverhead; int minHuge = maxTiny+1; int TOTAL_MEM = (maxTiny+perObjectOverhead)*BATCH_SIZE /*+ (maxBig+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+1+perObjectOverhead)*BATCH_SIZE + (TINY_MULTIPLE+perObjectOverhead)*BATCH_SIZE /*+ (MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE*/ + round(TINY_MULTIPLE, minHuge+perObjectOverhead+1); UnsafeMemoryChunk slab = new UnsafeMemoryChunk(TOTAL_MEM); @@ -66,14 +64,10 @@ public class SimpleMemoryAllocatorJUnitTest { assertEquals(TOTAL_MEM, ma.getFreeMemory()); assertEquals(TOTAL_MEM, ma.freeList.getFreeFragmentMemory()); assertEquals(0, ma.freeList.getFreeTinyMemory()); -// assertEquals(0, ma.freeList.getFreeBigMemory()); assertEquals(0, ma.freeList.getFreeHugeMemory()); MemoryChunk tinymc = ma.allocate(maxTiny, null); assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)*(BATCH_SIZE-1), ma.freeList.getFreeTinyMemory()); -// MemoryChunk bigmc = ma.allocate(maxBig); -// assertEquals(TOTAL_MEM-round(BIG_MULTIPLE, maxBig+perObjectOverhead)-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); -// assertEquals(round(BIG_MULTIPLE, maxBig+perObjectOverhead)*(BATCH_SIZE-1), ma.getFreeList().getFreeBigMemory()); MemoryChunk hugemc = ma.allocate(minHuge, null); assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); long freeSlab = ma.freeList.getFreeFragmentMemory(); @@ -82,9 +76,6 @@ public class SimpleMemoryAllocatorJUnitTest { hugemc.release(); assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory); assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); -// long oldFreeBigMemory = ma.freeList.getFreeBigMemory(); -// bigmc.free(); -// assertEquals(round(BIG_MULTIPLE, maxBig+perObjectOverhead), ma.freeList.getFreeBigMemory()-oldFreeBigMemory); assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); long oldFreeTinyMemory = ma.freeList.getFreeTinyMemory(); tinymc.release(); @@ -94,17 +85,12 @@ public class SimpleMemoryAllocatorJUnitTest { tinymc = ma.allocate(maxTiny, null); assertEquals(oldFreeTinyMemory, ma.freeList.getFreeTinyMemory()); assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); -// bigmc = ma.allocate(maxBig); -// assertEquals(oldFreeBigMemory, ma.freeList.getFreeBigMemory()); -// assertEquals(TOTAL_MEM-round(BIG_MULTIPLE, maxBig+perObjectOverhead)-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); hugemc = ma.allocate(minHuge, null); assertEquals(oldFreeHugeMemory, ma.freeList.getFreeHugeMemory()); assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, minHuge+perObjectOverhead)/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); hugemc.release(); assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead), ma.freeList.getFreeHugeMemory()-oldFreeHugeMemory); assertEquals(TOTAL_MEM/*-round(BIG_MULTIPLE, maxBig+perObjectOverhead)*/-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); -// bigmc.free(); -// assertEquals(round(BIG_MULTIPLE, maxBig+perObjectOverhead), ma.freeList.getFreeBigMemory()-oldFreeBigMemory); assertEquals(TOTAL_MEM-round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.getFreeMemory()); tinymc.release(); assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory); @@ -117,9 +103,6 @@ public class SimpleMemoryAllocatorJUnitTest { freeSlab = ma.freeList.getFreeFragmentMemory(); tinymc.release(); assertEquals(round(TINY_MULTIPLE, maxTiny+perObjectOverhead)+(round(TINY_MULTIPLE, 1+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeTinyMemory()-oldFreeTinyMemory); -// bigmc = ma.allocate(MIN_BIG_SIZE); -// assertEquals(MIN_BIG_SIZE+perObjectOverhead, bigmc.getSize()); -// assertEquals(freeSlab-((MIN_BIG_SIZE+perObjectOverhead)*BATCH_SIZE), ma.freeList.getFreeFragmentMemory()); hugemc = ma.allocate(minHuge+1, null); assertEquals(round(TINY_MULTIPLE, minHuge+1+perObjectOverhead), hugemc.getSize()); @@ -138,13 +121,6 @@ public class SimpleMemoryAllocatorJUnitTest { assertEquals(round(TINY_MULTIPLE, minHuge+perObjectOverhead)*BATCH_SIZE, ma.freeList.getFreeHugeMemory()); // now that we do compaction the following allocate works. hugemc = ma.allocate(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1, null); - - // assertEquals(minHuge+minHuge+1, ma.freeList.getFreeHugeMemory()); -// hugemc.free(); -// assertEquals(minHuge+minHuge+1+minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1, ma.freeList.getFreeHugeMemory()); -// hugemc = ma.allocate(minHuge + HUGE_MULTIPLE); -// assertEquals(minHuge + HUGE_MULTIPLE + HUGE_MULTIPLE-1, hugemc.getSize()); -// assertEquals(minHuge+minHuge+1, ma.freeList.getFreeHugeMemory()); } finally { SimpleMemoryAllocatorImpl.freeOffHeapMemory(); } @@ -174,6 +150,22 @@ public class SimpleMemoryAllocatorJUnitTest { } @Test + public void testDebugLog() { + SimpleMemoryAllocatorImpl.debugLog("test debug log", false); + SimpleMemoryAllocatorImpl.debugLog("test debug log", true); + } + @Test + public void testGetLostChunks() { + UnsafeMemoryChunk slab = new UnsafeMemoryChunk(1024*1024); + try { + SimpleMemoryAllocatorImpl ma = SimpleMemoryAllocatorImpl.create(new NullOutOfOffHeapMemoryListener(), new NullOffHeapMemoryStats(), new UnsafeMemoryChunk[]{slab}); + assertEquals(Collections.emptyList(), ma.getLostChunks()); + } finally { + SimpleMemoryAllocatorImpl.freeOffHeapMemory(); + } + } + + @Test public void testCompaction() { final int perObjectOverhead = com.gemstone.gemfire.internal.offheap.Chunk.OFF_HEAP_HEADER_SIZE; final int BIG_ALLOC_SIZE = 150000;