core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/statistic/OPerformanceStatisticManager.java
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<>(statistics.size());

    final Collection<Thread> threadsToRemove = new ArrayList<>();
    for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
      final Thread thread = entry.getKey();
      final OSessionStoragePerformanceStatistic statistic = entry.getValue();
      snapshots.add(new ORawPair<>(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);
    }
  }
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<>(statistics.size());

    final Collection<Thread> threadsToRemove = new ArrayList<>();
    for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
      final Thread thread = entry.getKey();
      final OSessionStoragePerformanceStatistic statistic = entry.getValue();
      snapshots.add(new ORawPair<>(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);
    }
  }
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