-
Notifications
You must be signed in to change notification settings - Fork 130
Plumb in three more metrics #344
Changes from 3 commits
4c2ac70
9f8c908
59fc263
61ee867
dff58b4
d86bf6f
447e991
54af8a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ | |
import tech.pegasys.pantheon.ethereum.mainnet.ProtocolSchedule; | ||
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason; | ||
import tech.pegasys.pantheon.ethereum.rlp.RLPException; | ||
import tech.pegasys.pantheon.metrics.MetricCategory; | ||
import tech.pegasys.pantheon.metrics.MetricsSystem; | ||
import tech.pegasys.pantheon.metrics.OperationTimer; | ||
import tech.pegasys.pantheon.util.uint.UInt256; | ||
|
||
import java.util.ArrayList; | ||
|
@@ -64,21 +67,29 @@ public class BlockPropagationManager<C> { | |
|
||
private final Set<Hash> requestedBlocks = new ConcurrentSet<>(); | ||
private final PendingBlocks pendingBlocks; | ||
private final OperationTimer announcedBlockIngestTimer; | ||
|
||
BlockPropagationManager( | ||
final SynchronizerConfiguration config, | ||
final ProtocolSchedule<C> protocolSchedule, | ||
final ProtocolContext<C> protocolContext, | ||
final EthContext ethContext, | ||
final SyncState syncState, | ||
final PendingBlocks pendingBlocks) { | ||
final PendingBlocks pendingBlocks, | ||
final MetricsSystem metricsSystem) { | ||
this.config = config; | ||
this.protocolSchedule = protocolSchedule; | ||
this.protocolContext = protocolContext; | ||
this.ethContext = ethContext; | ||
|
||
this.syncState = syncState; | ||
this.pendingBlocks = pendingBlocks; | ||
|
||
this.announcedBlockIngestTimer = | ||
metricsSystem.createTimer( | ||
MetricCategory.BLOCKCHAIN, | ||
"pantheon_blockchain_announcedBlock_ingest", | ||
"Time to ingest a single announced block"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it meaningful to track importing an announced block separately to just importing a block? ie should we just time how long There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was timing the amount of time to process the block. Its separate code paths IIRc between download and announced blocks, and different tasks (download I see being split into at least three non-adjacent tasks : headers, bodies, receipts). I could push this down into the persistBlock task, but I was hoping to have the number for the logging statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having the timing in the log message is probably justification enough for this. I think at some point having a timer inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pluming it into tasks is a much larger PR. I'll leave it here for now, but it may move. |
||
} | ||
|
||
public void start() { | ||
|
@@ -241,21 +252,25 @@ CompletableFuture<Block> importOrSavePendingBlock(final Block block) { | |
final PersistBlockTask<C> importTask = | ||
PersistBlockTask.create( | ||
protocolSchedule, protocolContext, block, HeaderValidationMode.FULL); | ||
final OperationTimer.TimingContext blockTimer = announcedBlockIngestTimer.startTimer(); | ||
return ethContext | ||
.getScheduler() | ||
.scheduleWorkerTask(importTask::run) | ||
.whenComplete( | ||
(r, t) -> { | ||
if (t != null) { | ||
// TODO do we time failures? But we cannot drop a label in at this point. | ||
LOG.warn( | ||
"Failed to import announced block {} ({}).", | ||
block.getHeader().getNumber(), | ||
block.getHash()); | ||
} else { | ||
final double time = blockTimer.stopTimer(); | ||
LOG.info( | ||
"Successfully imported announced block {} ({}).", | ||
"Successfully imported announced block {} ({}) in {}ms.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include the time in the log message is a nice touch. |
||
block.getHeader().getNumber(), | ||
block.getHash()); | ||
block.getHash(), | ||
time); | ||
} | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cast to double is proving to be an annoyingly common pattern. Should we introduce a
LongSupplier
version of gauges? Even if it just did the cast internally it would tidy code up. Also, in hind-sight I should have usedDoubleSupplier
. Might be a separate PR...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because I also see the potential of a UInt256Supplier.