Skip to content

Commit 03de2e4

Browse files
committed
Log aggregate stats instead of individual calls
1 parent 04742d9 commit 03de2e4

File tree

1 file changed

+33
-11
lines changed
  • server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2

1 file changed

+33
-11
lines changed

server/manager/src/main/java/org/apache/accumulo/manager/tableOps/bulkVer2/LoadFiles.java

+33-11
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
package org.apache.accumulo.manager.tableOps.bulkVer2;
2020

2121
import static java.nio.charset.StandardCharsets.UTF_8;
22-
import static java.util.concurrent.TimeUnit.MILLISECONDS;
2322
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOADED;
2423
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
2524
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.PREV_ROW;
2625

26+
import java.time.Duration;
2727
import java.util.ArrayList;
2828
import java.util.Comparator;
2929
import java.util.HashMap;
@@ -315,6 +315,16 @@ long finish() throws Exception {
315315
}
316316
}
317317

318+
/**
319+
* Stats for the loadFiles method. Helps track wasted time and iterations.
320+
*/
321+
private static class ImportTimingStats {
322+
Duration totalWastedTime = Duration.ZERO;
323+
long wastedIterations = 0;
324+
long tabletCount = 0;
325+
long callCount = 0;
326+
}
327+
318328
/**
319329
* Make asynchronous load calls to each overlapping Tablet in the bulk mapping. Return a sleep
320330
* time to isReady based on a factor of the TabletServer with the most Tablets. This method will
@@ -344,20 +354,33 @@ private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMa
344354

345355
loader.start(bulkDir, manager, tid, bulkInfo.setTime);
346356

347-
long t1 = System.currentTimeMillis();
357+
ImportTimingStats importTimingStats = new ImportTimingStats();
358+
359+
Timer timer = Timer.startNew();
348360
while (lmi.hasNext()) {
349361
loadMapEntry = lmi.next();
350362
List<TabletMetadata> tablets =
351-
findOverlappingTablets(fmtTid, loadMapEntry.getKey(), tabletIter);
363+
findOverlappingTablets(fmtTid, loadMapEntry.getKey(), tabletIter, importTimingStats);
352364
loader.load(tablets, loadMapEntry.getValue());
353365
}
366+
Duration totalProcessingTime = timer.elapsed();
354367

355368
log.trace("{}: Completed Finding Overlapping Tablets", fmtTid);
356369

370+
if (importTimingStats.callCount > 0) {
371+
log.info(
372+
"Bulk import stats for {} (tid = {}): processed {} tablets in {} calls which took {}ms ({} nanos). Skipped {} iterations which took {}ms ({} nanos) or {}% of the processing time.",
373+
bulkInfo.sourceDir, FateTxId.formatTid(tid), importTimingStats.tabletCount,
374+
importTimingStats.callCount, totalProcessingTime.toMillis(),
375+
totalProcessingTime.toNanos(), importTimingStats.wastedIterations,
376+
importTimingStats.totalWastedTime.toMillis(), importTimingStats.totalWastedTime.toNanos(),
377+
(importTimingStats.totalWastedTime.toNanos() * 100) / totalProcessingTime.toNanos());
378+
}
379+
357380
long sleepTime = loader.finish();
358381
if (sleepTime > 0) {
359382
log.trace("{}: Tablet Max Sleep is {}", fmtTid, sleepTime);
360-
long scanTime = Math.min(System.currentTimeMillis() - t1, 30_000);
383+
long scanTime = Math.min(totalProcessingTime.toMillis(), 30_000);
361384
log.trace("{}: Scan time is {}", fmtTid, scanTime);
362385
sleepTime = Math.max(sleepTime, scanTime * 2);
363386
}
@@ -372,7 +395,7 @@ private long loadFiles(TableId tableId, Path bulkDir, LoadMappingIterator loadMa
372395
* Find all the tablets within the provided bulk load mapping range.
373396
*/
374397
private List<TabletMetadata> findOverlappingTablets(String fmtTid, KeyExtent loadRange,
375-
Iterator<TabletMetadata> tabletIter) {
398+
Iterator<TabletMetadata> tabletIter, ImportTimingStats importTimingStats) {
376399

377400
TabletMetadata currTablet = null;
378401

@@ -394,7 +417,7 @@ private List<TabletMetadata> findOverlappingTablets(String fmtTid, KeyExtent loa
394417
currTablet = tabletIter.next();
395418
}
396419

397-
long wastedMillis = timer.elapsed(MILLISECONDS);
420+
Duration wastedTime = timer.elapsed();
398421

399422
if (cmp != 0) {
400423
throw new IllegalStateException(
@@ -416,11 +439,10 @@ private List<TabletMetadata> findOverlappingTablets(String fmtTid, KeyExtent loa
416439
throw new IllegalStateException("Unexpected end row " + currTablet + " " + loadRange);
417440
}
418441

419-
if (wastedIterations > 0) {
420-
log.debug(
421-
"Skipped {} tablets searching for prevEndRow of loadRange in {} ms to return {} tablets total in {}ms.",
422-
wastedIterations, wastedMillis, tablets.size(), timer.elapsed(MILLISECONDS));
423-
}
442+
importTimingStats.wastedIterations += wastedIterations;
443+
importTimingStats.totalWastedTime = importTimingStats.totalWastedTime.plus(wastedTime);
444+
importTimingStats.tabletCount += tablets.size();
445+
importTimingStats.callCount++;
424446

425447
return tablets;
426448
} catch (NoSuchElementException e) {

0 commit comments

Comments
 (0)