use of org.apache.ignite.internal.processors.cache.persistence.pagemem.PagesWriteSpeedBasedThrottle in project ignite by apache.
the class ProgressWatchdog method tick.
/**
* Regular method printing statistics to out and to log. Checks gaps in progress.
*/
private void tick() {
long elapsedMs = U.currentTimeMillis() - msStart;
final long totalCnt = overallRecordsProcessed.longValue();
long elapsedMsFromPrevTick = elapsedMs - prevMsElapsed.getAndSet(elapsedMs);
if (elapsedMsFromPrevTick == 0)
return;
final long currPutPerSec = ((totalCnt - prevRecordsCnt.getAndSet(totalCnt)) * 1000) / elapsedMsFromPrevTick;
final long averagePutPerSec = totalCnt * 1000 / elapsedMs;
boolean slowProgress = currPutPerSec < averagePutPerSec / 10 && !stopping;
final String fileNameWithDump = slowProgress ? reactNoProgress() : "";
DataStorageConfiguration dsCfg = ignite.configuration().getDataStorageConfiguration();
String defRegName = dsCfg.getDefaultDataRegionConfiguration().getName();
long dirtyPages = -1;
for (DataRegionMetrics m : ignite.dataRegionMetrics()) if (m.getName().equals(defRegName))
dirtyPages = m.getDirtyPages();
GridCacheSharedContext<Object, Object> cacheSctx = null;
PageMemoryImpl pageMemory = null;
try {
cacheSctx = ((IgniteEx) ignite).context().cache().context();
pageMemory = (PageMemoryImpl) cacheSctx.database().dataRegion(defRegName).pageMemory();
} catch (IgniteCheckedException e) {
e.printStackTrace();
}
long cpBufPages = 0;
GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) (cacheSctx.database());
AtomicInteger wrPageCntr = db.writtenPagesCounter();
long cpWrittenPages = wrPageCntr == null ? 0 : wrPageCntr.get();
AtomicInteger syncedPagesCntr = db.syncedPagesCounter();
int cpSyncedPages = syncedPagesCntr == null ? 0 : syncedPagesCntr.get();
AtomicInteger evictedPagesCntr = db.evictedPagesCntr();
int cpEvictedPages = evictedPagesCntr == null ? 0 : evictedPagesCntr.get();
int pageSize = pageMemory == null ? 0 : pageMemory.pageSize();
String cpWriteSpeed = getMBytesPrintable(detectDelta(elapsedMsFromPrevTick, cpWrittenPages, prevCpWrittenPages) * pageSize);
String cpSyncSpeed = getMBytesPrintable(detectDelta(elapsedMsFromPrevTick, cpSyncedPages, prevCpSyncedPages) * pageSize);
String walSpeed = "";
long throttleParkTimeNanos = 0;
double curDirtyRatio = 0.0;
String targetDirtyRatioStr = "";
double closeToThrottle = 0.0;
long idx = -1;
long lastArchIdx = -1;
int walArchiveSegments = 0;
long walWorkSegments = 0;
long markDirtySpeed = 0;
long cpWriteSpeedInPages = 0;
long estWrAllSpeed = 0;
try {
if (pageMemory != null) {
cpBufPages = pageMemory.checkpointBufferPagesCount();
PagesWriteSpeedBasedThrottle throttle = U.field(pageMemory, "writeThrottle");
if (throttle != null) {
curDirtyRatio = throttle.getCurrDirtyRatio();
double targetDirtyRatio = throttle.getTargetDirtyRatio();
targetDirtyRatioStr = targetDirtyRatio < 0 ? "" : formatDbl(targetDirtyRatio);
closeToThrottle = throttle.throttleWeight();
throttleParkTimeNanos = throttle.throttleParkTime();
markDirtySpeed = throttle.getMarkDirtySpeed();
cpWriteSpeedInPages = throttle.getCpWriteSpeed();
estWrAllSpeed = throttle.getLastEstimatedSpeedForMarkAll();
if (estWrAllSpeed > 99_999)
estWrAllSpeed = 99_999;
}
}
FileWriteAheadLogManager wal = (FileWriteAheadLogManager) cacheSctx.wal();
idx = 0;
lastArchIdx = 0;
walArchiveSegments = wal.walArchiveSegments();
walWorkSegments = idx - lastArchIdx;
/* // uncomment when currentWritePointer is available
FileWALPointer ptr = wal.currentWritePointer();
FileWALPointer prevWalPtr = this.prevWalPtrRef.getAndSet(ptr);
if (prevWalPtr != null) {
long idxDiff = ptr.index() - prevWalPtr.index();
long offDiff = ptr.fileOffset() - prevWalPtr.fileOffset();
long bytesDiff = idxDiff * maxWalSegmentSize + offDiff;
long bytesPerSec = (bytesDiff * 1000) / elapsedMsFromPrevTick;
walSpeed = getMBytesPrintable(bytesPerSec);
} else
walSpeed = "0";
*/
walSpeed = "0";
} catch (Exception e) {
X.error(e.getClass().getSimpleName() + ":" + e.getMessage());
}
long elapsedSecs = elapsedMs / 1000;
X.println(" >> " + operation + " done: " + totalCnt + "/" + elapsedSecs + "s, " + "Cur. " + operation + " " + currPutPerSec + " recs/sec " + "cpWriteSpeed=" + cpWriteSpeed + " " + "cpSyncSpeed=" + cpSyncSpeed + " " + "walSpeed= " + walSpeed + " " + "walWorkSeg.=" + walWorkSegments + " " + "markDirtySpeed=" + markDirtySpeed + " " + "Avg. " + operation + " " + averagePutPerSec + " recs/sec, " + "dirtyP=" + dirtyPages + ", " + "cpWrittenP.=" + cpWrittenPages + ", " + "cpBufP.=" + cpBufPages + " " + "threshold=" + targetDirtyRatioStr + " " + "walIdx=" + idx + " " + "archWalIdx=" + lastArchIdx + " " + "walArchiveSegments=" + walArchiveSegments + " " + fileNameWithDump);
line(elapsedSecs, currPutPerSec, walSpeed, cpWriteSpeed, cpSyncSpeed, walWorkSegments, throttleParkTimeNanos, formatDbl(curDirtyRatio), targetDirtyRatioStr, formatDbl(closeToThrottle), markDirtySpeed, cpWriteSpeedInPages, estWrAllSpeed, averagePutPerSec, dirtyPages, cpWrittenPages, cpSyncedPages, cpEvictedPages, idx, lastArchIdx, walArchiveSegments);
}
Aggregations