From 656bd24ba7f54173289bf49fb98c0ef300a37181 Mon Sep 17 00:00:00 2001 From: teor Date: Wed, 28 Oct 2020 15:16:03 +1000 Subject: [PATCH] Hedge every syncer block download request Remove the minimum data points from the syncer hedge configuragtion. When there are no data points, hedge sends the second request immediately. Where there are less than 1/(1-latency_percentile) data points (20), hedge delays the second request by the highest recent download time. This change should improve genesis and post-restart sync latency. --- zebrad/src/components/sync.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zebrad/src/components/sync.rs b/zebrad/src/components/sync.rs index 4850d32e..70e30193 100644 --- a/zebrad/src/components/sync.rs +++ b/zebrad/src/components/sync.rs @@ -148,6 +148,9 @@ where // making a less-fallible network service, and the Hedge layer // tries to reduce latency of that less-fallible service. // + // We hedge every request. If we don't have any recent timings, + // Hedge issues a second request with no delay. + // // XXX add ServiceBuilder::hedge() so this becomes // ServiceBuilder::new().hedge(...).retry(...)... let block_network = Hedge::new( @@ -157,7 +160,7 @@ where .timeout(BLOCK_DOWNLOAD_TIMEOUT) .service(peers), AlwaysHedge, - 20, + 0, 0.95, 2 * SYNC_RESTART_TIMEOUT, );