Skip to content

Commit 7e1adef

Browse files
authored
diagnostics: cherry pick speedtest disable (#10509)
Cherry pick PR #10449 into the release branch
1 parent b0df97f commit 7e1adef

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

cmd/utils/flags.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,9 +1013,14 @@ var (
10131013
Usage: "Diagnostics HTTP server listening port",
10141014
Value: 6060,
10151015
}
1016+
DiagSpeedTestFlag = cli.BoolFlag{
1017+
Name: "diagnostics.speedtest",
1018+
Usage: "Enable speed test",
1019+
Value: false,
1020+
}
10161021
)
10171022

1018-
var MetricFlags = []cli.Flag{&MetricsEnabledFlag, &MetricsHTTPFlag, &MetricsPortFlag, &DiagDisabledFlag, &DiagEndpointAddrFlag, &DiagEndpointPortFlag}
1023+
var MetricFlags = []cli.Flag{&MetricsEnabledFlag, &MetricsHTTPFlag, &MetricsPortFlag, &DiagDisabledFlag, &DiagEndpointAddrFlag, &DiagEndpointPortFlag, &DiagSpeedTestFlag}
10191024

10201025
var DiagnosticsFlags = []cli.Flag{&DiagnosticsURLFlag, &DiagnosticsURLFlag, &DiagnosticsSessionsFlag}
10211026

diagnostics/setup.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var (
2020
metricsPortFlag = "metrics.port"
2121
pprofPortFlag = "pprof.port"
2222
pprofAddrFlag = "pprof.addr"
23+
diagnoticsSpeedTestFlag = "diagnostics.speedtest"
2324
)
2425

2526
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
4849
diagMux = SetupDiagnosticsEndpoint(nil, diagAddress)
4950
}
5051

51-
diagnostic := diaglib.NewDiagnosticClient(diagMux, node.Backend().DataDir())
52+
speedTest := ctx.Bool(diagnoticsSpeedTestFlag)
53+
54+
diagnostic := diaglib.NewDiagnosticClient(diagMux, node.Backend().DataDir(), speedTest)
5255
diagnostic.Setup()
5356

5457
SetupEndpoints(ctx, node, diagMux, diagnostic)

erigon-lib/diagnostics/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
type DiagnosticClient struct {
1111
metricsMux *http.ServeMux
1212
dataDirPath string
13+
speedTest bool
1314

1415
syncStats SyncStatistics
1516
snapshotFileList SnapshoFilesList
@@ -26,10 +27,11 @@ type DiagnosticClient struct {
2627
networkSpeedMutex sync.Mutex
2728
}
2829

29-
func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string) *DiagnosticClient {
30+
func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string, speedTest bool) *DiagnosticClient {
3031
return &DiagnosticClient{
3132
metricsMux: metricsMux,
3233
dataDirPath: dataDirPath,
34+
speedTest: speedTest,
3335
syncStats: SyncStatistics{},
3436
hardwareInfo: HardwareInfo{},
3537
snapshotFileList: SnapshoFilesList{},

erigon-lib/diagnostics/speedtest.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,11 @@ import (
88
)
99

1010
func (d *DiagnosticClient) setupSpeedtestDiagnostics(rootCtx context.Context) {
11-
ticker := time.NewTicker(30 * time.Minute)
1211
go func() {
13-
d.networkSpeedMutex.Lock()
14-
d.networkSpeed = d.runSpeedTest(rootCtx)
15-
d.networkSpeedMutex.Unlock()
16-
17-
for {
18-
select {
19-
case <-ticker.C:
20-
d.networkSpeedMutex.Lock()
21-
d.networkSpeed = d.runSpeedTest(rootCtx)
22-
d.networkSpeedMutex.Unlock()
23-
case <-rootCtx.Done():
24-
ticker.Stop()
25-
return
26-
}
12+
if d.speedTest {
13+
d.networkSpeedMutex.Lock()
14+
d.networkSpeed = d.runSpeedTest(rootCtx)
15+
d.networkSpeedMutex.Unlock()
2716
}
2817
}()
2918
}

0 commit comments

Comments
 (0)