Add metrics to world state downloader to track number of pending requests, total requests completed and total requests retried. (#837)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Adrian Sutton 6 years ago committed by GitHub
parent a18f1663c6
commit c996907e55
  1. 3
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/DefaultSynchronizer.java
  2. 26
      ethereum/eth/src/main/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/WorldStateDownloader.java
  3. 18
      ethereum/eth/src/test/java/tech/pegasys/pantheon/ethereum/eth/sync/worldstate/WorldStateDownloaderTest.java

@ -105,7 +105,8 @@ public class DefaultSynchronizer<C> implements Synchronizer {
stateQueue, stateQueue,
syncConfig.getWorldStateHashCountPerRequest(), syncConfig.getWorldStateHashCountPerRequest(),
syncConfig.getWorldStateRequestParallelism(), syncConfig.getWorldStateRequestParallelism(),
ethTasksTimer); ethTasksTimer,
metricsSystem);
this.fastSyncDownloader = this.fastSyncDownloader =
Optional.of( Optional.of(
new FastSyncDownloader<>( new FastSyncDownloader<>(

@ -22,7 +22,10 @@ import tech.pegasys.pantheon.ethereum.eth.sync.tasks.WaitForPeerTask;
import tech.pegasys.pantheon.ethereum.trie.MerklePatriciaTrie; import tech.pegasys.pantheon.ethereum.trie.MerklePatriciaTrie;
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateStorage; import tech.pegasys.pantheon.ethereum.worldstate.WorldStateStorage;
import tech.pegasys.pantheon.ethereum.worldstate.WorldStateStorage.Updater; import tech.pegasys.pantheon.ethereum.worldstate.WorldStateStorage.Updater;
import tech.pegasys.pantheon.metrics.Counter;
import tech.pegasys.pantheon.metrics.LabelledMetric; import tech.pegasys.pantheon.metrics.LabelledMetric;
import tech.pegasys.pantheon.metrics.MetricCategory;
import tech.pegasys.pantheon.metrics.MetricsSystem;
import tech.pegasys.pantheon.metrics.OperationTimer; import tech.pegasys.pantheon.metrics.OperationTimer;
import tech.pegasys.pantheon.services.queue.BigQueue; import tech.pegasys.pantheon.services.queue.BigQueue;
import tech.pegasys.pantheon.util.bytes.BytesValue; import tech.pegasys.pantheon.util.bytes.BytesValue;
@ -43,6 +46,8 @@ import org.apache.logging.log4j.Logger;
public class WorldStateDownloader { public class WorldStateDownloader {
private static final Logger LOG = LogManager.getLogger(); private static final Logger LOG = LogManager.getLogger();
private final Counter completedRequestsCounter;
private final Counter retriedRequestsTotal;
private enum Status { private enum Status {
IDLE, IDLE,
@ -67,13 +72,30 @@ public class WorldStateDownloader {
final BigQueue<NodeDataRequest> pendingRequests, final BigQueue<NodeDataRequest> pendingRequests,
final int hashCountPerRequest, final int hashCountPerRequest,
final int maxOutstandingRequests, final int maxOutstandingRequests,
final LabelledMetric<OperationTimer> ethTasksTimer) { final LabelledMetric<OperationTimer> ethTasksTimer,
final MetricsSystem metricsSystem) {
this.ethContext = ethContext; this.ethContext = ethContext;
this.worldStateStorage = worldStateStorage; this.worldStateStorage = worldStateStorage;
this.pendingRequests = pendingRequests; this.pendingRequests = pendingRequests;
this.hashCountPerRequest = hashCountPerRequest; this.hashCountPerRequest = hashCountPerRequest;
this.maxOutstandingRequests = maxOutstandingRequests; this.maxOutstandingRequests = maxOutstandingRequests;
this.ethTasksTimer = ethTasksTimer; this.ethTasksTimer = ethTasksTimer;
metricsSystem.createGauge(
MetricCategory.SYNCHRONIZER,
"world_state_pending_requests_current",
"Number of pending requests for fast sync world state download",
() -> (double) pendingRequests.size());
completedRequestsCounter =
metricsSystem.createCounter(
MetricCategory.SYNCHRONIZER,
"world_state_completed_requests_total",
"Total number of node data requests completed as part of fast sync world state download");
retriedRequestsTotal =
metricsSystem.createCounter(
MetricCategory.SYNCHRONIZER,
"world_state_retried_requests_total",
"Total number of node data requests repeated as part of fast sync world state download");
} }
public CompletableFuture<Void> run(final BlockHeader header) { public CompletableFuture<Void> run(final BlockHeader header) {
@ -184,8 +206,10 @@ public class WorldStateDownloader {
for (NodeDataRequest request : requests) { for (NodeDataRequest request : requests) {
BytesValue matchingData = requestFailed ? null : data.get(request.getHash()); BytesValue matchingData = requestFailed ? null : data.get(request.getHash());
if (matchingData == null) { if (matchingData == null) {
retriedRequestsTotal.inc();
pendingRequests.enqueue(request); pendingRequests.enqueue(request);
} else { } else {
completedRequestsCounter.inc();
// Persist request data // Persist request data
request.setData(matchingData); request.setData(matchingData);
request.persist(storageUpdater); request.persist(storageUpdater);

@ -123,7 +123,8 @@ public class WorldStateDownloaderTest {
queue, queue,
10, 10,
10, 10,
NoOpMetricsSystem.NO_OP_LABELLED_TIMER); NoOpMetricsSystem.NO_OP_LABELLED_TIMER,
new NoOpMetricsSystem());
CompletableFuture<Void> future = downloader.run(header); CompletableFuture<Void> future = downloader.run(header);
assertThat(future).isDone(); assertThat(future).isDone();
@ -170,7 +171,8 @@ public class WorldStateDownloaderTest {
queue, queue,
10, 10,
10, 10,
NoOpMetricsSystem.NO_OP_LABELLED_TIMER); NoOpMetricsSystem.NO_OP_LABELLED_TIMER,
new NoOpMetricsSystem());
CompletableFuture<Void> result = downloader.run(header); CompletableFuture<Void> result = downloader.run(header);
@ -238,7 +240,8 @@ public class WorldStateDownloaderTest {
queue, queue,
10, 10,
10, 10,
NoOpMetricsSystem.NO_OP_LABELLED_TIMER); NoOpMetricsSystem.NO_OP_LABELLED_TIMER,
new NoOpMetricsSystem());
CompletableFuture<Void> result = downloader.run(header); CompletableFuture<Void> result = downloader.run(header);
@ -316,7 +319,8 @@ public class WorldStateDownloaderTest {
queue, queue,
10, 10,
10, 10,
NoOpMetricsSystem.NO_OP_LABELLED_TIMER); NoOpMetricsSystem.NO_OP_LABELLED_TIMER,
new NoOpMetricsSystem());
CompletableFuture<Void> result = downloader.run(header); CompletableFuture<Void> result = downloader.run(header);
@ -407,7 +411,8 @@ public class WorldStateDownloaderTest {
queue, queue,
10, 10,
10, 10,
NoOpMetricsSystem.NO_OP_LABELLED_TIMER); NoOpMetricsSystem.NO_OP_LABELLED_TIMER,
new NoOpMetricsSystem());
CompletableFuture<Void> result = downloader.run(header); CompletableFuture<Void> result = downloader.run(header);
@ -532,7 +537,8 @@ public class WorldStateDownloaderTest {
queue, queue,
hashesPerRequest, hashesPerRequest,
maxOutstandingRequests, maxOutstandingRequests,
NoOpMetricsSystem.NO_OP_LABELLED_TIMER); NoOpMetricsSystem.NO_OP_LABELLED_TIMER,
new NoOpMetricsSystem());
// Create some peers that can respond // Create some peers that can respond
List<RespondingEthPeer> usefulPeers = List<RespondingEthPeer> usefulPeers =

Loading…
Cancel
Save