use of org.jsr166.LongAdder8 in project ignite by apache.
the class GridCircularBufferPerformanceTest method testAdderThroughput.
/**
* @throws Exception If failed.
*/
public void testAdderThroughput() throws Exception {
final int size = 256 * 1024;
final ArrayBlockingQueue<Integer> buf = new ArrayBlockingQueue<>(size);
final LongAdder8 cnt = new LongAdder8();
final AtomicBoolean finished = new AtomicBoolean();
multithreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
while (!finished.get()) {
U.sleep(5000);
info("Ops/sec: " + cnt.sumThenReset() / 5);
}
return null;
}
}, 1);
multithreaded(new Callable<Object>() {
@Override
public Object call() throws Exception {
while (!finished.get()) cnt.increment();
return null;
}
}, 8);
info("Buffer: " + buf);
}
use of org.jsr166.LongAdder8 in project ignite by apache.
the class GridCacheQuerySimpleBenchmark method testPerformance.
/**
* @throws Exception If failed.
*/
public void testPerformance() throws Exception {
Random rnd = new GridRandom();
final IgniteCache<Long, Person> c = ignite.cache("offheap-cache");
X.println("___ PUT start");
final int cnt = 100_000;
final int maxSalary = cnt / 10;
for (long i = 0; i < cnt; i++) c.put(i, new Person(rnd.nextInt(maxSalary), "Vasya " + i));
X.println("___ PUT end");
final AtomicBoolean end = new AtomicBoolean();
final LongAdder8 puts = new LongAdder8();
IgniteInternalFuture<?> fut0 = multithreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
Random rnd = new GridRandom();
while (!end.get()) {
long i = rnd.nextInt(cnt);
c.put(i, new Person(rnd.nextInt(maxSalary), "Vasya " + i));
puts.increment();
}
return null;
}
}, 10);
final LongAdder8 qrys = new LongAdder8();
IgniteInternalFuture<?> fut1 = multithreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
Random rnd = new GridRandom();
while (!end.get()) {
int salary = rnd.nextInt(maxSalary);
c.query(new SqlFieldsQuery("select name from Person where salary = ?").setArgs(salary)).getAll();
qrys.increment();
}
return null;
}
}, 10);
int runTimeSec = 600;
for (int s = 0; s < runTimeSec; s++) {
Thread.sleep(1000);
long puts0 = puts.sum();
long qrys0 = qrys.sum();
puts.add(-puts0);
qrys.add(-qrys0);
X.println("___ puts: " + puts0 + " qrys: " + qrys0);
}
end.set(true);
fut0.get();
fut1.get();
X.println("___ STOP");
}
use of org.jsr166.LongAdder8 in project ignite by apache.
the class GridCacheJdbcBlobStoreMultithreadedSelfTest method checkOpenedClosedCount.
/**
*
*/
private void checkOpenedClosedCount() {
assertEquals(GRID_CNT, Ignition.allGrids().size());
for (Ignite ignite : Ignition.allGrids()) {
GridCacheContext cctx = ((IgniteKernal) ignite).internalCache(DEFAULT_CACHE_NAME).context();
CacheStore store = cctx.store().configuredStore();
long opened = ((LongAdder8) U.field(store, "opened")).sum();
long closed = ((LongAdder8) U.field(store, "closed")).sum();
assert opened > 0;
assert closed > 0;
assertEquals(opened, closed);
}
}
use of org.jsr166.LongAdder8 in project ignite by apache.
the class GridCacheBinaryObjectsAbstractDataStreamerSelfTest method testGetPut.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("BusyWait")
public void testGetPut() throws Exception {
final AtomicBoolean flag = new AtomicBoolean();
final LongAdder8 cnt = new LongAdder8();
try (IgniteDataStreamer<Object, Object> ldr = grid(0).dataStreamer(DEFAULT_CACHE_NAME)) {
IgniteInternalFuture<?> f = multithreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
while (!flag.get()) {
ldr.addData(rnd.nextInt(10000), new TestObject(rnd.nextInt(10000)));
cnt.add(1);
}
return null;
}
}, THREAD_CNT);
for (int i = 0; i < 30 && !f.isDone(); i++) Thread.sleep(1000);
flag.set(true);
f.get();
}
info("Operations in 30 sec: " + cnt.sum());
}
Aggregations