private long runAndReportTimeAndGetDurationMicros(Runnable runnable, String timerName) { Timer.Context timer = getTimer(timerName).time(); runnable.run(); return TimeUnit.NANOSECONDS.toMicros(timer.stop()); }
@Override public Map<Cell, byte[]> get(TableReference tableRef, Set<Cell> cells) { Timer.Context timer = getTimer("get").time(); checkGetPreconditions(tableRef); if (Iterables.isEmpty(cells)) { return ImmutableMap.of(); } hasReads = true; Map<Cell, byte[]> result = Maps.newHashMap(); SortedMap<Cell, byte[]> writes = writesByTable.get(tableRef); if (writes != null) { for (Cell cell : cells) { if (writes.containsKey(cell)) { result.put(cell, writes.get(cell)); } } } // We don't need to read any cells that were written locally. result.putAll(getFromKeyValueService(tableRef, Sets.difference(cells, result.keySet()))); long getMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop()); if (perfLogger.isDebugEnabled()) { perfLogger.debug("get({}, {} cells) found {} cells (some possibly deleted), took {} ms", tableRef, cells.size(), result.size(), getMillis); } validatePreCommitRequirementsOnReadIfNecessary(tableRef, getStartTimestamp()); return Maps.filterValues(result, Predicates.not(Value.IS_EMPTY)); }
@Override public SortedMap<byte[], RowResult<byte[]>> getRows(TableReference tableRef, Iterable<byte[]> rows, ColumnSelection columnSelection) { Timer.Context timer = getTimer("getRows").time(); checkGetPreconditions(tableRef); if (Iterables.isEmpty(rows)) { return AbstractTransaction.EMPTY_SORTED_ROWS; } hasReads = true; ImmutableMap.Builder<Cell, byte[]> result = ImmutableSortedMap.naturalOrder(); Map<Cell, Value> rawResults = Maps.newHashMap( keyValueService.getRows(tableRef, rows, columnSelection, getStartTimestamp())); SortedMap<Cell, byte[]> writes = writesByTable.get(tableRef); if (writes != null) { for (byte[] row : rows) { extractLocalWritesForRow(result, writes, row, columnSelection); } } // We don't need to do work postFiltering if we have a write locally. rawResults.keySet().removeAll(result.build().keySet()); SortedMap<byte[], RowResult<byte[]>> results = filterRowResults(tableRef, rawResults, result); long getRowsMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop()); if (perfLogger.isDebugEnabled()) { perfLogger.debug("getRows({}, {} rows) found {} rows, took {} ms", tableRef, Iterables.size(rows), results.size(), getRowsMillis); } validatePreCommitRequirementsOnReadIfNecessary(tableRef, getStartTimestamp()); return results; }
Timer.Context timer = getTimer("waitForCommitTsMillis").time(); waitForCommitToComplete(startTimestamps); long waitForCommitTsMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop());
Timer.Context timer = getTimer("processedRangeMillis").time(); Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> firstPages = keyValueService.getFirstBatchForRanges(tableRef, input, getStartTimestamp());
Timer.Context commitStageTimer = getTimer("commitStage").time(); Timer.Context acquireLocksTimer = getTimer("commitAcquireLocks").time(); LockToken commitLocksToken = acquireLocksForCommit(); long microsForRowLocks = TimeUnit.NANOSECONDS.toMicros(acquireLocksTimer.stop()); Timer.Context commitTimestampTimer = getTimer("getCommitTimestamp").time(); long commitTimestamp = timelockService.getFreshTimestamp(); commitTsForScrubbing = commitTimestamp; getTimer("commitTotalTimeSinceTxCreation").update(microsSinceCreation, TimeUnit.MICROSECONDS); getHistogram(AtlasDbMetricNames.SNAPSHOT_TRANSACTION_BYTES_WRITTEN).update(byteCount.get()); optionalProfile = Optional.of(ImmutableTransactionCommitProfile.builder()
private long runAndReportTimeAndGetDurationMicros(Runnable runnable, String timerName) { Timer.Context timer = getTimer(timerName).time(); runnable.run(); return TimeUnit.NANOSECONDS.toMicros(timer.stop()); }
@Override public Map<Cell, byte[]> get(TableReference tableRef, Set<Cell> cells) { Timer.Context timer = getTimer("get").time(); checkGetPreconditions(tableRef); if (Iterables.isEmpty(cells)) { return ImmutableMap.of(); } hasReads = true; Map<Cell, byte[]> result = Maps.newHashMap(); SortedMap<Cell, byte[]> writes = writesByTable.get(tableRef); if (writes != null) { for (Cell cell : cells) { if (writes.containsKey(cell)) { result.put(cell, writes.get(cell)); } } } // We don't need to read any cells that were written locally. result.putAll(getFromKeyValueService(tableRef, Sets.difference(cells, result.keySet()))); long getMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop()); if (perfLogger.isDebugEnabled()) { perfLogger.debug("get({}, {} cells) found {} cells (some possibly deleted), took {} ms", tableRef, cells.size(), result.size(), getMillis); } validatePreCommitRequirementsOnReadIfNecessary(tableRef, getStartTimestamp()); return Maps.filterValues(result, Predicates.not(Value.IS_EMPTY)); }
@Override public SortedMap<byte[], RowResult<byte[]>> getRows(TableReference tableRef, Iterable<byte[]> rows, ColumnSelection columnSelection) { Timer.Context timer = getTimer("getRows").time(); checkGetPreconditions(tableRef); if (Iterables.isEmpty(rows)) { return AbstractTransaction.EMPTY_SORTED_ROWS; } hasReads = true; ImmutableMap.Builder<Cell, byte[]> result = ImmutableSortedMap.naturalOrder(); Map<Cell, Value> rawResults = Maps.newHashMap( keyValueService.getRows(tableRef, rows, columnSelection, getStartTimestamp())); SortedMap<Cell, byte[]> writes = writesByTable.get(tableRef); if (writes != null) { for (byte[] row : rows) { extractLocalWritesForRow(result, writes, row, columnSelection); } } // We don't need to do work postFiltering if we have a write locally. rawResults.keySet().removeAll(result.build().keySet()); SortedMap<byte[], RowResult<byte[]>> results = filterRowResults(tableRef, rawResults, result); long getRowsMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop()); if (perfLogger.isDebugEnabled()) { perfLogger.debug("getRows({}, {} rows) found {} rows, took {} ms", tableRef, Iterables.size(rows), results.size(), getRowsMillis); } validatePreCommitRequirementsOnReadIfNecessary(tableRef, getStartTimestamp()); return results; }
Timer.Context timer = getTimer("waitForCommitTsMillis").time(); waitForCommitToComplete(startTimestamps); long waitForCommitTsMillis = TimeUnit.NANOSECONDS.toMillis(timer.stop());
Timer.Context timer = getTimer("processedRangeMillis").time(); Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> firstPages = keyValueService.getFirstBatchForRanges(tableRef, input, getStartTimestamp());
Timer.Context commitStageTimer = getTimer("commitStage").time(); Timer.Context acquireLocksTimer = getTimer("commitAcquireLocks").time(); LockToken commitLocksToken = acquireLocksForCommit(); long microsForRowLocks = TimeUnit.NANOSECONDS.toMicros(acquireLocksTimer.stop()); Timer.Context commitTimestampTimer = getTimer("getCommitTimestamp").time(); long commitTimestamp = timelockService.getFreshTimestamp(); commitTsForScrubbing = commitTimestamp; getTimer("commitTotalTimeSinceTxCreation").update(microsSinceCreation, TimeUnit.MICROSECONDS); getHistogram(AtlasDbMetricNames.SNAPSHOT_TRANSACTION_BYTES_WRITTEN).update(byteCount.get()); optionalProfile = Optional.of(ImmutableTransactionCommitProfile.builder()