public void test_smallSlotRecycling(){
  final Journal store=(Journal)getSmallSlotStore(1024);
  try {
    final RWStrategy bufferStrategy=(RWStrategy)store.getBufferStrategy();
    final RWStore rw=bufferStrategy.getStore();
    final int cSlotSize=128;
    final int cAllocSize=99;
    int breaks=0;
    int contiguous=0;
    ArrayList<Integer> recycle=new ArrayList<Integer>();
    long pap=rw.physicalAddress(rw.alloc(cAllocSize,null));
    for (int i=0; i < 500000; i++) {
      final int a=rw.alloc(cSlotSize,null);
      final long pa=rw.physicalAddress(a);
      if (r.nextInt(7) < 5) {
        recycle.add(a);
      }
      if (pa == (pap + cSlotSize)) {
        contiguous++;
      }
 else {
        breaks++;
      }
      pap=pa;
      if (recycle.size() > 5000) {
        log.warn("Transient Frees for immediate recyling");
        for (        int e : recycle) {
          rw.free(e,cAllocSize);
        }
        recycle.clear();
      }
    }
    store.commit();
    final StringBuilder sb=new StringBuilder();
    rw.showAllocators(sb);
    log.warn("Contiguous: " + contiguous + ", breaks: "+ breaks+ "\n"+ sb.toString());
  }
  finally {
    store.destroy();
  }
}

public void test_smallSlotRecycling ( ) { final Journal store = ( Journal ) getSmallSlotStore ( 1024 ) ; try { final RWStrategy bufferStrategy = ( RWStrategy ) store . getBufferStrategy ( ) ; final RWStore rw = bufferStrategy . getStore ( ) ; final int cSlotSize = 128 ; final int cAllocSize = 99 ; int breaks = 0 ; int contiguous = 0 ; ArrayList < Integer > recycle = new ArrayList < Integer > ( ) ; long pap = rw . physicalAddress ( rw . alloc ( cAllocSize , null ) ) ; for ( int i = 0 ; i < 500000 ; i ++ ) { final int a = rw . alloc ( cSlotSize , null ) ; final long pa = rw . physicalAddress ( a ) ; if ( r . nextInt ( 7 ) < 5 ) { recycle . add ( a ) ; } if ( pa == ( pap + cSlotSize ) ) { contiguous ++ ; } else { breaks ++ ; } pap = pa ; if ( recycle . size ( ) > 5000 ) { log . warn ( "Transient Frees for immediate recyling" ) ; for ( int e : recycle ) { rw . free ( e , cAllocSize ) ; } recycle . clear ( ) ; } } store . commit ( ) ; final StringBuilder sb = new StringBuilder ( ) ; rw . showAllocators ( sb ) ; log . warn ( "Contiguous: " + contiguous + ", breaks: " + breaks + "\n" + sb . toString ( ) ) ; } finally { store . destroy ( ) ; } }
tests the recycling of small slot alloctors and outputs statistics related to contiguous allocations indicative of reduced iops .
