Changeset 483


Ignore:
Timestamp:
03/24/12 22:01:10 (9 years ago)
Author:
BegemoT
Message:
 
Location:
Tests/JAVA/test
Files:
13 edited
2 copied
1 moved

Legend:

Unmodified
Added
Removed
  • Tests/JAVA/test/config.properties.template

    r480 r483  
    77general.affinity            = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 
    88 
     9payload.ops-per-packet      = 1024 
     10payload.cache-messages      = true 
    911 
    1012task.buffer-size            = 32768 
    1113task.events-in-batch        = 512 
     14 
     15task.queue-factory          = test.threads.queue.unstressed.impl.ABQBusyWaitQueue 
    1216 
    1317pipeline.nodes              = 8 
  • Tests/JAVA/test/src/main/java/test/threads/queue/stressed/TaskBenchmark.java

    r482 r483  
    7474        ); 
    7575 
    76         options.addOption( OptionBuilder.withLongOpt( "opsPerPacket" ) 
    77                                    .withDescription( "operations per packet" ) 
    78                                    .hasArg() 
    79                                    .isRequired() 
    80                                    .withArgName( "opsPerPacket" ) 
    81                                    .create() 
    82         ); 
    8376        options.addOption( OptionBuilder.withLongOpt( "config" ) 
    8477                                   .withDescription( ".properties file containing configuration data (default is " + DEFAULT_CONFIG_FILE + ")" ) 
  • Tests/JAVA/test/src/main/java/test/threads/queue/stressed/cpu/CPUWasterFactory.java

    r482 r483  
    3030    public IUsefulWorkEmulator<LongValueMessage>[] createEmulators( final int count ) { 
    3131        checkArgument( opsPerPacket % count == 0, "opsPerPacket(%s) % workerCount(%s) must be 0", opsPerPacket, count ); 
    32         operationsPerNode = opsPerPacket/count; 
     32        operationsPerNode = opsPerPacket / count; 
    3333 
    3434        final IUsefulWorkEmulator<LongValueMessage>[] emulators = new IUsefulWorkEmulator[count]; 
     
    4949    @Override 
    5050    public String toString() { 
    51         return "cpu"; 
     51        return "cpu[" + operationsPerNode + " ops/node]"; 
    5252    } 
    5353 
  • Tests/JAVA/test/src/main/java/test/threads/queue/stressed/memory/CPUMemoryWasterFactory.java

    r482 r483  
    2424    } 
    2525 
    26     private int size = -1; 
     26    private int operationsPerNode = -1; 
    2727 
    2828    @Override 
    2929    public IUsefulWorkEmulator<LongArrayMessage>[] createEmulators( final int count ) { 
    3030        checkArgument( opsPerPacket % count == 0, "opsPerPacket(%s) % workerCount(%s) must be 0", opsPerPacket, count ); 
    31         size = opsPerPacket / count; 
     31        operationsPerNode = opsPerPacket / count; 
    3232 
    3333        final IUsefulWorkEmulator<LongArrayMessage>[] emulators = new IUsefulWorkEmulator[count]; 
     
    4343    @Override 
    4444    public LongArrayMessage newInstance() { 
    45         final long[] longs = new long[size]; 
     45        final long[] longs = new long[operationsPerNode]; 
    4646        longs[0] = index++; 
    4747//        for ( int i = 0; i < longs.length; i++ ) { 
     
    5353    @Override 
    5454    public String toString() { 
    55         return "cpu+memory"; 
     55        return "cpu+memory["+ operationsPerNode +" ops/node]"; 
    5656    } 
    5757 
  • Tests/JAVA/test/src/main/java/test/threads/queue/stressed/memory/MemoryWasterFactory.java

    r482 r483  
    2424    } 
    2525 
    26     private int size = -1; 
     26    private int operationsPerNode = -1; 
    2727 
    2828    @Override 
    2929    public IUsefulWorkEmulator<LongArrayMessage>[] createEmulators( final int count ) { 
    3030        checkArgument( opsPerPacket % count == 0, "opsPerPacket(%s) % workerCount(%s) must be 0", opsPerPacket, count ); 
    31         size = opsPerPacket / count; 
     31        operationsPerNode = opsPerPacket / count; 
    3232 
    3333        final IUsefulWorkEmulator<LongArrayMessage>[] emulators = new IUsefulWorkEmulator[count]; 
     
    4343    @Override 
    4444    public LongArrayMessage newInstance() { 
    45         final long[] longs = new long[size]; 
     45        final long[] longs = new long[operationsPerNode]; 
    4646        longs[0] = index++; 
    4747//        for ( int i = 0; i < longs.length; i++ ) { 
     
    5353    @Override 
    5454    public String toString() { 
    55         return "memory"; 
     55        return "memory["+ operationsPerNode +" ops/node]"; 
    5656    } 
    5757 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/AbstractBenchmarkingTask.java

    r417 r483  
    1313 * @since 27.09.11,  15:58 
    1414 */ 
     15@Deprecated 
    1516public abstract class AbstractBenchmarkingTask implements IBenchmarkingTask { 
    1617 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/DisruptorBenchmarkingTask.java

    r442 r483  
    1313 * @author cheremin 
    1414 * @since 27.09.11,  16:13 
     15 * @deprecated use {@link DisruptorTask} instead 
    1516 */ 
    1617public class DisruptorBenchmarkingTask extends AbstractBenchmarkingTask { 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/IBenchmarkingTask.java

    r417 r483  
    77 * @since 27.09.11,  15:57 
    88 */ 
     9@Deprecated 
    910public interface IBenchmarkingTask { 
    1011    public void run() throws Exception; 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/LongQueueBenchmarkingTask.java

    r482 r483  
    1010 * @author cheremin 
    1111 * @since 27.09.11,  16:06 
     12 * @deprecated use {@link LongQueueTask} 
    1213 */ 
    1314public class LongQueueBenchmarkingTask extends AbstractBenchmarkingTask { 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/LongQueueTask.java

    r482 r483  
    1111import test.threads.queue.stressed.IUsefulWorkEmulator; 
    1212import test.threads.queue.stressed.cpu.LongValueMessage; 
     13import test.threads.queue.unstressed.impl.CABSESDMaskedLongQueue; 
    1314 
    1415/** 
    15  * new version of {@link QueueBenchmarkingTask} 
     16 * new version of {@link test.threads.queue.unstressed.QueueBenchmarkingTask} 
    1617 * 
    1718 * @author cheremin 
    1819 * @since 24.03.12,  14:52 
    1920 */ 
    20 public class QueueTask extends AbstractTask<LongValueMessage> { 
    21     private static final Log log = LogFactory.getLog( QueueTask.class ); 
     21public class LongQueueTask extends AbstractTask<LongValueMessage> { 
     22    private static final Log log = LogFactory.getLog( LongQueueTask.class ); 
    2223 
    23     private final IBoundedQueueFactory<LongValueMessage, ? extends IQueue<LongValueMessage>> queueFactory; 
    24     private final IQueue<LongValueMessage> queue; 
     24    private final CABSESDMaskedLongQueue queue; 
    2525 
    26     public QueueTask( final Config config ) throws Exception { 
     26    public LongQueueTask( final Config config ) throws Exception { 
    2727        super( config ); 
    2828 
    29         final Class<IBoundedQueueFactory> clazz = config.getAsClass( "task.queue-factory" ); 
    30  
    31         this.queueFactory = ( IBoundedQueueFactory ) clazz.getField( "FACTORY" ).get( null ); 
    32  
    33         this.queue = queueFactory.create( bufferSize() ); 
     29        this.queue = new CABSESDMaskedLongQueue( bufferSize() ); 
    3430    } 
    3531 
     
    5753    public String toString() { 
    5854        return String.format( 
    59                 "%s[%s]", 
    60                 super.toString(), 
    61                 queueFactory 
     55                "%s[CABSESDMaskedLongQueue]", 
     56                super.toString() 
    6257        ); 
    6358    } 
     
    7065        @Override 
    7166        protected void enqueueEventsBatch( final int eventsInBatch ) throws Exception { 
    72             final EventFactory<LongValueMessage> factory = eventFactory(); 
    7367            for ( int i = 0; i < eventsInBatch; i++ ) { 
    74                 final LongValueMessage event = factory.newInstance(); 
    75                 event.value = i; 
    76                 queue.enqueue( event ); 
     68                queue.enqueue( i ); 
    7769            } 
    7870        } 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/QueuesVsDisruptorUnstressedBenchmark.java

    r482 r483  
    1313 * @since 21.09.11,  18:02 
    1414 */ 
     15@Deprecated 
    1516public class QueuesVsDisruptorUnstressedBenchmark { 
    1617 
     
    140141                case 4: 
    141142                    task = new QueueBenchmarkingTask( 
    142                             CABSESDMaskedQueueOptimized.<LongValueEntry>factory(), 
     143                            CABSESDMaskedQueueUnrolled.<LongValueEntry>factory(), 
    143144                            size, 
    144145                            eventFactory, 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/SequencerBenchmarkingTask.java

    r482 r483  
    1010 * @author cheremin 
    1111 * @since 27.09.11,  16:21 
     12 * @deprecated use {@link SequencerTask} 
    1213 */ 
    1314public class SequencerBenchmarkingTask extends AbstractBenchmarkingTask { 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/SequencerTask.java

    r482 r483  
    1111import test.threads.queue.stressed.IUsefulWorkEmulator; 
    1212import test.threads.queue.stressed.cpu.LongValueMessage; 
     13import test.threads.queue.unstressed.impl.SESDSequencer; 
    1314 
    1415/** 
    15  * new version of {@link QueueBenchmarkingTask} 
     16 * new version of {@link test.threads.queue.unstressed.SequencerBenchmarkingTask} 
    1617 * 
    1718 * @author cheremin 
    1819 * @since 24.03.12,  14:52 
    1920 */ 
    20 public class QueueTask extends AbstractTask<LongValueMessage> { 
    21     private static final Log log = LogFactory.getLog( QueueTask.class ); 
     21public class SequencerTask extends AbstractTask<LongValueMessage> { 
     22    private static final Log log = LogFactory.getLog( SequencerTask.class ); 
    2223 
    23     private final IBoundedQueueFactory<LongValueMessage, ? extends IQueue<LongValueMessage>> queueFactory; 
    24     private final IQueue<LongValueMessage> queue; 
     24    private final SESDSequencer sequencer; 
    2525 
    26     public QueueTask( final Config config ) throws Exception { 
     26    public SequencerTask( final Config config ) throws Exception { 
    2727        super( config ); 
    2828 
    29         final Class<IBoundedQueueFactory> clazz = config.getAsClass( "task.queue-factory" ); 
    30  
    31         this.queueFactory = ( IBoundedQueueFactory ) clazz.getField( "FACTORY" ).get( null ); 
    32  
    33         this.queue = queueFactory.create( bufferSize() ); 
     29        this.sequencer = new SESDSequencer( bufferSize() ); 
    3430    } 
    3531 
     
    4541    protected void dequeueBatchEvents( final int eventsInBatch ) throws Exception { 
    4642        for ( int i = 0; i < eventsInBatch; i++ ) { 
    47             queue.dequeue(); 
     43            sequencer.moveHead(); 
    4844        } 
    4945    } 
     
    5753    public String toString() { 
    5854        return String.format( 
    59                 "%s[%s]", 
    60                 super.toString(), 
    61                 queueFactory 
     55                "%s[SESDSequencer]", 
     56                super.toString() 
    6257        ); 
    6358    } 
     
    7065        @Override 
    7166        protected void enqueueEventsBatch( final int eventsInBatch ) throws Exception { 
    72             final EventFactory<LongValueMessage> factory = eventFactory(); 
    7367            for ( int i = 0; i < eventsInBatch; i++ ) { 
    74                 final LongValueMessage event = factory.newInstance(); 
    75                 event.value = i; 
    76                 queue.enqueue( event ); 
     68                sequencer.moveTail(); 
    7769            } 
    7870        } 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl/AbstractSESDSequencer.java

    r482 r483  
    2727     * на волатильном чтении 
    2828     */ 
    29     private static final boolean OPTIMIZE_SPIN_WAIT = false; 
     29    private static final boolean OPTIMIZE_SPIN_WAIT = true; 
    3030 
    3131    //====================================================== 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl/CABSESDMaskedQueueUnrolled.java

    r482 r483  
    1919 * Blocking (by spin-wait) 
    2020 * <p/> 
     21 * <p/> 
     22 * "Развернутая" версия {@link CABSESDMaskedQueue} -- без наследования, и прочих 
     23 * изысков, которые, предположительно, могут смутить JIT, и уменьшить степень 
     24 * оптимизации 
    2125 * 
    2226 * @author A.S. 
    2327 * @since 13.10.11,  15:06 
    2428 */ 
    25 public final class CABSESDMaskedQueueOptimized<T> implements IQueue<T> { 
     29public final class CABSESDMaskedQueueUnrolled<T> implements IQueue<T> { 
    2630    private static final boolean USE_TEST_AND_SET = false; 
    2731    private static final boolean USE_UNSAFE = true; 
     
    5458    public volatile long $h01, $h02, $h03, $h04, $h05, $h06, $h07, $h08; 
    5559 
    56     private static final AtomicLongFieldUpdater<CABSESDMaskedQueueOptimized> tailUpdater = AtomicLongFieldUpdater.newUpdater( 
    57             CABSESDMaskedQueueOptimized.class, 
     60    private static final AtomicLongFieldUpdater<CABSESDMaskedQueueUnrolled> tailUpdater = AtomicLongFieldUpdater.newUpdater( 
     61            CABSESDMaskedQueueUnrolled.class, 
    5862            "tailCursor" 
    5963    ); 
    60     private static final AtomicLongFieldUpdater<CABSESDMaskedQueueOptimized> headUpdater = AtomicLongFieldUpdater.newUpdater( 
    61             CABSESDMaskedQueueOptimized.class, 
     64    private static final AtomicLongFieldUpdater<CABSESDMaskedQueueUnrolled> headUpdater = AtomicLongFieldUpdater.newUpdater( 
     65            CABSESDMaskedQueueUnrolled.class, 
    6266            "headCursor" 
    6367    ); 
     
    6973    static { 
    7074        unsafe = UnsafeHelper.unsafe(); 
    71         final Class<CABSESDMaskedQueueOptimized> clazz = CABSESDMaskedQueueOptimized.class; 
     75        final Class<CABSESDMaskedQueueUnrolled> clazz = CABSESDMaskedQueueUnrolled.class; 
    7276        try { 
    7377            final Field headCursorField = clazz.getDeclaredField( "headCursor" ); 
     
    8084        System.out.printf( 
    8185                "%s: useUnsafe: %b, useTAS: %b\n", 
    82                 CABSESDMaskedQueueOptimized.class.getSimpleName(), 
     86                CABSESDMaskedQueueUnrolled.class.getSimpleName(), 
    8387                USE_UNSAFE, 
    8488                USE_TEST_AND_SET 
     
    8791 
    8892    @SuppressWarnings( "unchecked" ) 
    89     public CABSESDMaskedQueueOptimized( final int size ) { 
     93    public CABSESDMaskedQueueUnrolled( final int size ) { 
    9094        if ( Integer.bitCount( size ) != 1 ) { 
    9195            throw new IllegalArgumentException( "bufferSize must be a power of 2" ); 
     
    165169    } 
    166170 
    167     public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CABSESDMaskedQueueOptimized<Object>>() { 
     171    public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CABSESDMaskedQueueUnrolled<Object>>() { 
    168172        @Override 
    169         public CABSESDMaskedQueueOptimized<Object> create( final int size ) { 
    170             return new CABSESDMaskedQueueOptimized<Object>( size ); 
     173        public CABSESDMaskedQueueUnrolled<Object> create( final int size ) { 
     174            return new CABSESDMaskedQueueUnrolled<Object>( size ); 
    171175        } 
    172176 
  • Tests/JAVA/test/unstressed_task_benchmark.sh

    r482 r483  
    88 
    99 
    10 TYPE="$2" 
    1110mvn compile 
    1211 
    1312rm result.data 
    1413 
    15 for OPS in 1000000 100000 10000 1024 128 16 4 
     14for FACTORY in "ABQWrapperQueue" "ABQBusyWaitQueue" "CABSESDQueue" "CABSESDMaskedQueue" "CABSESDMaskedQueueOptimized" 
    1615do 
    1716    mvn exec:java -Dexec.mainClass="test.threads.queue.stressed.TaskBenchmark" \ 
    18         -Dexec.args="--task=test.threads.queue.unstressed.$TYPE --payload=cpu --opsPerPacket=1" -e 
     17        -Dexec.args="--task=test.threads.queue.unstressed.QueueTask --payload=none -Dtask.queue-factory=test.threads.queue.unstressed.impl.$FACTORY" -e 
    1918done 
     19 
     20 
     21for TASK in "DisruptorTask" "SequencerTask" "LongQueueTask" 
     22do 
     23    mvn exec:java -Dexec.mainClass="test.threads.queue.stressed.TaskBenchmark" \ 
     24        -Dexec.args="--task=test.threads.queue.unstressed.$TASK --payload=none" -e 
     25done 
Note: See TracChangeset for help on using the changeset viewer.