From: <mar...@us...> - 2010-12-22 09:50:03
|
Revision: 4040 http://bigdata.svn.sourceforge.net/bigdata/?rev=4040&view=rev Author: martyncutcher Date: 2010-12-22 09:49:57 +0000 (Wed, 22 Dec 2010) Log Message: ----------- 1) Fixes freeList management associated with releaseSession 2) Fixes AllocationContext freelist associations with FixedAllocators Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/AllocBlock.java branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/AllocBlock.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/AllocBlock.java 2010-12-21 23:07:08 UTC (rev 4039) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/AllocBlock.java 2010-12-22 09:49:57 UTC (rev 4040) @@ -313,8 +313,11 @@ * but not in the recalculated transient. Tested with new &= ~old; * * @param cache + * @return the number of allocations released */ - public void releaseSession(RWWriteCacheService cache) { + public int releaseSession(RWWriteCacheService cache) { + int freebits = 0; + if (m_addr != 0) { // check active! for (int i = 0; i < m_live.length; i++) { int chkbits = m_transients[i]; @@ -332,11 +335,15 @@ log.trace("releasing address: " + clr); cache.clearWrite(clr); + + freebits++; } } } } } + + return freebits; } public String show() { Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java 2010-12-21 23:07:08 UTC (rev 4039) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/FixedAllocator.java 2010-12-22 09:49:57 UTC (rev 4040) @@ -517,21 +517,8 @@ if (((AllocBlock) m_allocBlocks.get(block)) .freeBit(offset % nbits, m_sessionActive && !overideSession)) { // bit adjust - // Only add back to the free list this is a DirectFixedAllocator - // or the freeBits exceed the cDefaultFreeBitsThreshold - // If a DirectFixedAllocator then also ensure it is added to the - // front of the free list - if (m_freeBits++ == 0 && this instanceof DirectFixedAllocator) { - m_freeWaiting = false; - m_freeList.add(0, this); - } else if (m_freeWaiting && m_freeBits == m_store.cDefaultFreeBitsThreshold) { - m_freeWaiting = false; - - if (log.isDebugEnabled()) - log.debug("Returning Allocator to FreeList - " + m_size); - - m_freeList.add(this); - } + m_freeBits++; + checkFreeList(); } else { m_freeTransients++; } @@ -557,6 +544,22 @@ return false; } + private void checkFreeList() { + if (m_freeWaiting) { + if (m_freeBits > 0 && this instanceof DirectFixedAllocator) { + m_freeWaiting = false; + m_freeList.add(0, this); + } else if (m_freeBits >= m_store.cDefaultFreeBitsThreshold) { + m_freeWaiting = false; + + if (log.isDebugEnabled()) + log.debug("Returning Allocator to FreeList - " + m_size); + + m_freeList.add(this); + } + } + } + /** * The introduction of IAllocationContexts has added some complexity to * the older concept of a free list. With AllocationContexts it is @@ -803,9 +806,17 @@ if (this.m_sessionActive) { if (log.isTraceEnabled()) log.trace("Allocator: #" + m_index + " releasing session protection"); + + int releasedAllocations = 0; for (AllocBlock ab : m_allocBlocks) { - ab.releaseSession(cache); + releasedAllocations += ab.releaseSession(cache); } + + m_freeBits += releasedAllocations; + m_freeTransients -= releasedAllocations; + + checkFreeList(); + } } } Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2010-12-21 23:07:08 UTC (rev 4039) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/rwstore/RWStore.java 2010-12-22 09:49:57 UTC (rev 4040) @@ -3556,6 +3556,10 @@ } + /** + * Must return the shadowed allocators to the parent/global + * environment, resetting the freeList association. + */ void release() { final ArrayList<FixedAllocator> freeFixed[] = m_parent != null ? m_parent.m_freeFixed : m_store.m_freeFixed; @@ -3565,6 +3569,7 @@ for (FixedAllocator f : m_allFixed) { f.setAllocationContext(pcontext); + f.setFreeList(freeFixed[m_store.fixedAllocatorIndex(f.m_size)]); } for (int i = 0; i < m_freeFixed.length; i++) { @@ -3597,6 +3602,7 @@ if (free.size() == 0) { final FixedAllocator falloc = establishFixedAllocator(i); falloc.setAllocationContext(m_context); + falloc.setFreeList(free); free.add(falloc); m_allFixed.add(falloc); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |