From a5fb815a1fab3229ed0b24d8688860c46008a2eb Mon Sep 17 00:00:00 2001 From: dvovk Date: Wed, 22 May 2024 22:55:47 +0100 Subject: [PATCH 1/5] disable speedtest if --- diagnostics/setup.go | 5 ++++- erigon-lib/diagnostics/client.go | 13 +++++++++---- erigon-lib/diagnostics/speedtest.go | 5 +++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/diagnostics/setup.go b/diagnostics/setup.go index 7ce8b3a6d53..2be489b7fce 100644 --- a/diagnostics/setup.go +++ b/diagnostics/setup.go @@ -20,6 +20,7 @@ var ( metricsPortFlag = "metrics.port" pprofPortFlag = "pprof.port" pprofAddrFlag = "pprof.addr" + downloaderDisabledFlag = "no-downloader" ) func Setup(ctx *cli.Context, node *node.ErigonNode, metricsMux *http.ServeMux, pprofMux *http.ServeMux) { @@ -48,7 +49,9 @@ func Setup(ctx *cli.Context, node *node.ErigonNode, metricsMux *http.ServeMux, p diagMux = SetupDiagnosticsEndpoint(nil, diagAddress) } - diagnostic := diaglib.NewDiagnosticClient(diagMux, node.Backend().DataDir()) + noDownloader := ctx.Bool(downloaderDisabledFlag) + + diagnostic := diaglib.NewDiagnosticClient(diagMux, node.Backend().DataDir(), noDownloader) diagnostic.Setup() SetupEndpoints(ctx, node, diagMux, diagnostic) diff --git a/erigon-lib/diagnostics/client.go b/erigon-lib/diagnostics/client.go index 284e46c1498..b1ec507c696 100644 --- a/erigon-lib/diagnostics/client.go +++ b/erigon-lib/diagnostics/client.go @@ -8,8 +8,9 @@ import ( ) type DiagnosticClient struct { - metricsMux *http.ServeMux - dataDirPath string + metricsMux *http.ServeMux + dataDirPath string + noDownloader bool syncStats SyncStatistics snapshotFileList SnapshoFilesList @@ -26,10 +27,11 @@ type DiagnosticClient struct { networkSpeedMutex sync.Mutex } -func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string) *DiagnosticClient { +func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string, noDownloader bool) *DiagnosticClient { return &DiagnosticClient{ metricsMux: metricsMux, dataDirPath: dataDirPath, + noDownloader: noDownloader, syncStats: SyncStatistics{}, hardwareInfo: HardwareInfo{}, snapshotFileList: SnapshoFilesList{}, @@ -53,7 +55,10 @@ func (d *DiagnosticClient) Setup() { d.setupHeadersDiagnostics(rootCtx) d.setupBodiesDiagnostics(rootCtx) d.setupResourcesUsageDiagnostics(rootCtx) - d.setupSpeedtestDiagnostics(rootCtx) + + if !d.noDownloader { + d.setupSpeedtestDiagnostics(rootCtx) + } //d.logDiagMsgs() } diff --git a/erigon-lib/diagnostics/speedtest.go b/erigon-lib/diagnostics/speedtest.go index d2c463bbbbb..fe06fbafa8a 100644 --- a/erigon-lib/diagnostics/speedtest.go +++ b/erigon-lib/diagnostics/speedtest.go @@ -17,6 +17,11 @@ func (d *DiagnosticClient) setupSpeedtestDiagnostics(rootCtx context.Context) { for { select { case <-ticker.C: + if d.syncStats.SnapshotDownload.DownloadFinished { + ticker.Stop() + return + } + d.networkSpeedMutex.Lock() d.networkSpeed = d.runSpeedTest(rootCtx) d.networkSpeedMutex.Unlock() From 793d2c74b6e045d4702b76abfbd60d11a3ef3c59 Mon Sep 17 00:00:00 2001 From: dvovk Date: Wed, 22 May 2024 23:09:25 +0100 Subject: [PATCH 2/5] fix --- erigon-lib/diagnostics/client.go | 5 +---- erigon-lib/diagnostics/speedtest.go | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/erigon-lib/diagnostics/client.go b/erigon-lib/diagnostics/client.go index b1ec507c696..df15f84d745 100644 --- a/erigon-lib/diagnostics/client.go +++ b/erigon-lib/diagnostics/client.go @@ -55,10 +55,7 @@ func (d *DiagnosticClient) Setup() { d.setupHeadersDiagnostics(rootCtx) d.setupBodiesDiagnostics(rootCtx) d.setupResourcesUsageDiagnostics(rootCtx) - - if !d.noDownloader { - d.setupSpeedtestDiagnostics(rootCtx) - } + d.setupSpeedtestDiagnostics(rootCtx) //d.logDiagMsgs() } diff --git a/erigon-lib/diagnostics/speedtest.go b/erigon-lib/diagnostics/speedtest.go index fe06fbafa8a..938536473ca 100644 --- a/erigon-lib/diagnostics/speedtest.go +++ b/erigon-lib/diagnostics/speedtest.go @@ -14,6 +14,11 @@ func (d *DiagnosticClient) setupSpeedtestDiagnostics(rootCtx context.Context) { d.networkSpeed = d.runSpeedTest(rootCtx) d.networkSpeedMutex.Unlock() + if d.noDownloader { + ticker.Stop() + return + } + for { select { case <-ticker.C: From 68fde9933a7fbcfe8605c02b98200e9c6e558b3c Mon Sep 17 00:00:00 2001 From: dvovk Date: Thu, 23 May 2024 10:26:05 +0100 Subject: [PATCH 3/5] added flag for speedtest --- cmd/utils/flags.go | 7 ++++++- diagnostics/setup.go | 6 +++--- erigon-lib/diagnostics/client.go | 10 +++++----- erigon-lib/diagnostics/speedtest.go | 29 ++++------------------------- 4 files changed, 18 insertions(+), 34 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 6eb96c93268..ea75fe19975 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1013,9 +1013,14 @@ var ( Usage: "Diagnostics HTTP server listening port", Value: 6060, } + DiagSpeedTestFlag = cli.BoolFlag{ + Name: "diagnostics.speedtest", + Usage: "Enable speed test", + Value: false, + } ) -var MetricFlags = []cli.Flag{&MetricsEnabledFlag, &MetricsHTTPFlag, &MetricsPortFlag, &DiagDisabledFlag, &DiagEndpointAddrFlag, &DiagEndpointPortFlag} +var MetricFlags = []cli.Flag{&MetricsEnabledFlag, &MetricsHTTPFlag, &MetricsPortFlag, &DiagDisabledFlag, &DiagEndpointAddrFlag, &DiagEndpointPortFlag, &DiagSpeedTestFlag} var DiagnosticsFlags = []cli.Flag{&DiagnosticsURLFlag, &DiagnosticsURLFlag, &DiagnosticsSessionsFlag} diff --git a/diagnostics/setup.go b/diagnostics/setup.go index 2be489b7fce..6534ecac245 100644 --- a/diagnostics/setup.go +++ b/diagnostics/setup.go @@ -20,7 +20,7 @@ var ( metricsPortFlag = "metrics.port" pprofPortFlag = "pprof.port" pprofAddrFlag = "pprof.addr" - downloaderDisabledFlag = "no-downloader" + diagnoticsSpeedTestFlag = "diagnostics.speedtest" ) func Setup(ctx *cli.Context, node *node.ErigonNode, metricsMux *http.ServeMux, pprofMux *http.ServeMux) { @@ -49,9 +49,9 @@ func Setup(ctx *cli.Context, node *node.ErigonNode, metricsMux *http.ServeMux, p diagMux = SetupDiagnosticsEndpoint(nil, diagAddress) } - noDownloader := ctx.Bool(downloaderDisabledFlag) + speedTest := ctx.Bool(diagnoticsSpeedTestFlag) - diagnostic := diaglib.NewDiagnosticClient(diagMux, node.Backend().DataDir(), noDownloader) + diagnostic := diaglib.NewDiagnosticClient(diagMux, node.Backend().DataDir(), speedTest) diagnostic.Setup() SetupEndpoints(ctx, node, diagMux, diagnostic) diff --git a/erigon-lib/diagnostics/client.go b/erigon-lib/diagnostics/client.go index df15f84d745..df5b04a76fc 100644 --- a/erigon-lib/diagnostics/client.go +++ b/erigon-lib/diagnostics/client.go @@ -8,9 +8,9 @@ import ( ) type DiagnosticClient struct { - metricsMux *http.ServeMux - dataDirPath string - noDownloader bool + metricsMux *http.ServeMux + dataDirPath string + speedTest bool syncStats SyncStatistics snapshotFileList SnapshoFilesList @@ -27,11 +27,11 @@ type DiagnosticClient struct { networkSpeedMutex sync.Mutex } -func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string, noDownloader bool) *DiagnosticClient { +func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string, speedTest bool) *DiagnosticClient { return &DiagnosticClient{ metricsMux: metricsMux, dataDirPath: dataDirPath, - noDownloader: noDownloader, + speedTest: speedTest, syncStats: SyncStatistics{}, hardwareInfo: HardwareInfo{}, snapshotFileList: SnapshoFilesList{}, diff --git a/erigon-lib/diagnostics/speedtest.go b/erigon-lib/diagnostics/speedtest.go index 938536473ca..77da08ac7a6 100644 --- a/erigon-lib/diagnostics/speedtest.go +++ b/erigon-lib/diagnostics/speedtest.go @@ -8,32 +8,11 @@ import ( ) func (d *DiagnosticClient) setupSpeedtestDiagnostics(rootCtx context.Context) { - ticker := time.NewTicker(30 * time.Minute) go func() { - d.networkSpeedMutex.Lock() - d.networkSpeed = d.runSpeedTest(rootCtx) - d.networkSpeedMutex.Unlock() - - if d.noDownloader { - ticker.Stop() - return - } - - for { - select { - case <-ticker.C: - if d.syncStats.SnapshotDownload.DownloadFinished { - ticker.Stop() - return - } - - d.networkSpeedMutex.Lock() - d.networkSpeed = d.runSpeedTest(rootCtx) - d.networkSpeedMutex.Unlock() - case <-rootCtx.Done(): - ticker.Stop() - return - } + if d.speedTest { + d.networkSpeedMutex.Lock() + d.networkSpeed = d.runSpeedTest(rootCtx) + d.networkSpeedMutex.Unlock() } }() } From 04bcfb781a79a842869c09d4dac31bd0f5db4c8d Mon Sep 17 00:00:00 2001 From: dvovk Date: Wed, 22 May 2024 22:55:47 +0100 Subject: [PATCH 4/5] cherry picj speedtestt disable --- diagnostics/setup.go | 4 ++++ erigon-lib/diagnostics/client.go | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/diagnostics/setup.go b/diagnostics/setup.go index 6534ecac245..fd18af8e257 100644 --- a/diagnostics/setup.go +++ b/diagnostics/setup.go @@ -20,7 +20,11 @@ var ( metricsPortFlag = "metrics.port" pprofPortFlag = "pprof.port" pprofAddrFlag = "pprof.addr" +<<<<<<< HEAD diagnoticsSpeedTestFlag = "diagnostics.speedtest" +======= + downloaderDisabledFlag = "no-downloader" +>>>>>>> 420cfbfc94 (disable speedtest if) ) func Setup(ctx *cli.Context, node *node.ErigonNode, metricsMux *http.ServeMux, pprofMux *http.ServeMux) { diff --git a/erigon-lib/diagnostics/client.go b/erigon-lib/diagnostics/client.go index df5b04a76fc..ee7a00be6c2 100644 --- a/erigon-lib/diagnostics/client.go +++ b/erigon-lib/diagnostics/client.go @@ -8,9 +8,15 @@ import ( ) type DiagnosticClient struct { +<<<<<<< HEAD metricsMux *http.ServeMux dataDirPath string speedTest bool +======= + metricsMux *http.ServeMux + dataDirPath string + noDownloader bool +>>>>>>> 420cfbfc94 (disable speedtest if) syncStats SyncStatistics snapshotFileList SnapshoFilesList @@ -55,7 +61,10 @@ func (d *DiagnosticClient) Setup() { d.setupHeadersDiagnostics(rootCtx) d.setupBodiesDiagnostics(rootCtx) d.setupResourcesUsageDiagnostics(rootCtx) - d.setupSpeedtestDiagnostics(rootCtx) + + if !d.noDownloader { + d.setupSpeedtestDiagnostics(rootCtx) + } //d.logDiagMsgs() } From ece0f2ac5015475886aa6a1f94446c3511291b2d Mon Sep 17 00:00:00 2001 From: dvovk Date: Mon, 27 May 2024 17:50:12 +0100 Subject: [PATCH 5/5] fix --- diagnostics/setup.go | 4 ---- erigon-lib/diagnostics/client.go | 11 +---------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/diagnostics/setup.go b/diagnostics/setup.go index fd18af8e257..6534ecac245 100644 --- a/diagnostics/setup.go +++ b/diagnostics/setup.go @@ -20,11 +20,7 @@ var ( metricsPortFlag = "metrics.port" pprofPortFlag = "pprof.port" pprofAddrFlag = "pprof.addr" -<<<<<<< HEAD diagnoticsSpeedTestFlag = "diagnostics.speedtest" -======= - downloaderDisabledFlag = "no-downloader" ->>>>>>> 420cfbfc94 (disable speedtest if) ) func Setup(ctx *cli.Context, node *node.ErigonNode, metricsMux *http.ServeMux, pprofMux *http.ServeMux) { diff --git a/erigon-lib/diagnostics/client.go b/erigon-lib/diagnostics/client.go index ee7a00be6c2..df5b04a76fc 100644 --- a/erigon-lib/diagnostics/client.go +++ b/erigon-lib/diagnostics/client.go @@ -8,15 +8,9 @@ import ( ) type DiagnosticClient struct { -<<<<<<< HEAD metricsMux *http.ServeMux dataDirPath string speedTest bool -======= - metricsMux *http.ServeMux - dataDirPath string - noDownloader bool ->>>>>>> 420cfbfc94 (disable speedtest if) syncStats SyncStatistics snapshotFileList SnapshoFilesList @@ -61,10 +55,7 @@ func (d *DiagnosticClient) Setup() { d.setupHeadersDiagnostics(rootCtx) d.setupBodiesDiagnostics(rootCtx) d.setupResourcesUsageDiagnostics(rootCtx) - - if !d.noDownloader { - d.setupSpeedtestDiagnostics(rootCtx) - } + d.setupSpeedtestDiagnostics(rootCtx) //d.logDiagMsgs() }