Search in sources :

Example 46 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class OPerformanceStatisticManager method fetchSystemCounters.

/**
   * Iterates over all live threads and accumulates performance statics gathered form threads on system level,
   * also accumulates statistic from dead threads which were alive when when gathering of performance measurements is started.
   *
   * @param countersHolder Holder which is used to accumulate all performance statistic data
   */
private void fetchSystemCounters(PerformanceCountersHolder countersHolder) {
    //go through all threads and accumulate statistic only for live threads
    //all dead threads will be removed and statistics from them will be
    //later accumulated in #deadThreadsStatistic field, then result statistic from this field
    //will be aggregated to countersHolder
    //To decrease inter thread communication delay we fetch snapshots first
    //and only after that we aggregate data from immutable snapshots
    final Collection<ORawPair<Thread, PerformanceSnapshot>> snapshots = new ArrayList<ORawPair<Thread, PerformanceSnapshot>>(statistics.size());
    final Collection<Thread> threadsToRemove = new ArrayList<Thread>();
    for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
        final Thread thread = entry.getKey();
        final OSessionStoragePerformanceStatistic statistic = entry.getValue();
        snapshots.add(new ORawPair<Thread, PerformanceSnapshot>(thread, statistic.getSnapshot()));
    }
    for (ORawPair<Thread, PerformanceSnapshot> pair : snapshots) {
        final Thread thread = pair.getFirst();
        if (thread.isAlive()) {
            final PerformanceSnapshot snapshot = pair.getSecond();
            snapshot.performanceCountersHolder.pushData(countersHolder);
        } else {
            threadsToRemove.add(thread);
        }
    }
    if (!threadsToRemove.isEmpty()) {
        updateDeadThreadsStatistic(threadsToRemove);
    }
    final ImmutableStatistic ds = deadThreadsStatistic;
    if (ds != null) {
        final PerformanceCountersHolder dch = ds.countersHolder;
        dch.pushData(countersHolder);
    }
}
Also used : ORawPair(com.orientechnologies.common.util.ORawPair) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 47 with OSessionStoragePerformanceStatistic

use of com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic in project orientdb by orientechnologies.

the class LocalCreateBinaryDocumentSpeedTest method cycle.

@Override
@Test(enabled = false)
public void cycle() {
    final OStorage storage = database.getStorage();
    ((OAbstractPaginatedStorage) storage).startGatheringPerformanceStatisticForCurrentThread();
    record = new ORecordBytes(database, payload);
    record.save();
    if (data.getCyclesDone() == data.getCycles() - 1)
        database.commit();
    OSessionStoragePerformanceStatistic sessionStoragePerformanceStatistic = ((OAbstractPaginatedStorage) storage).completeGatheringPerformanceStatisticForCurrentThread();
    System.out.println(sessionStoragePerformanceStatistic.toDocument().toJSON("prettyPrint"));
}
Also used : ORecordBytes(com.orientechnologies.orient.core.record.impl.ORecordBytes) OStorage(com.orientechnologies.orient.core.storage.OStorage) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) OSessionStoragePerformanceStatistic(com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic) OrientMonoThreadTest(com.orientechnologies.orient.test.database.base.OrientMonoThreadTest) Test(org.testng.annotations.Test)

Aggregations

OSessionStoragePerformanceStatistic (com.orientechnologies.orient.core.storage.impl.local.statistic.OSessionStoragePerformanceStatistic)47 OAtomicOperation (com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation)25 IOException (java.io.IOException)23 OCacheEntry (com.orientechnologies.orient.core.storage.cache.OCacheEntry)20 Lock (java.util.concurrent.locks.Lock)11 OSBTreeBonsaiLocalException (com.orientechnologies.orient.core.exception.OSBTreeBonsaiLocalException)9 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 ORawPair (com.orientechnologies.common.util.ORawPair)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 OException (com.orientechnologies.common.exception.OException)4 ORecordId (com.orientechnologies.orient.core.id.ORecordId)4 OPaginatedClusterException (com.orientechnologies.orient.core.exception.OPaginatedClusterException)3 OStorageException (com.orientechnologies.orient.core.exception.OStorageException)3 OTooBigIndexKeyException (com.orientechnologies.orient.core.exception.OTooBigIndexKeyException)3 OIndexException (com.orientechnologies.orient.core.index.OIndexException)3 OLocalHashTableException (com.orientechnologies.orient.core.exception.OLocalHashTableException)2 OStorage (com.orientechnologies.orient.core.storage.OStorage)2 OAbstractPaginatedStorage (com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage)2 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)1 OAllCacheEntriesAreUsedException (com.orientechnologies.orient.core.exception.OAllCacheEntriesAreUsedException)1