fix(cli): provide stat cosmetics (#11034)
Guillaume Michel committed
Oct 28, 2025 at 22:38 UTC
8c5f302d25c8bc90f10fb0173993509231936737
9 files changed
+33
-25
core/commands/provide.go
+6
-6
@@ -437,8 +437,8 @@ NOTES:
437
if !brief {
438
formatLine(1, "%sTotal records provided: %s", indent, humanNumber(s.Sweep.Operations.Past.RecordsProvided))
439
formatLine(1, "%sTotal provide errors: %s", indent, humanNumber(s.Sweep.Operations.Past.KeysFailed))
440
- formatLine(1, "%sCIDs provided/min: %s", indent, humanFloatOrNA(s.Sweep.Operations.Past.KeysProvidedPerMinute))
441
- formatLine(1, "%sCIDs reprovided/min: %s", indent, humanFloatOrNA(s.Sweep.Operations.Past.KeysReprovidedPerMinute))
440
+ formatLine(1, "%sCIDs provided/min/worker: %s", indent, humanFloatOrNA(s.Sweep.Operations.Past.KeysProvidedPerMinute))
441
+ formatLine(1, "%sCIDs reprovided/min/worker: %s", indent, humanFloatOrNA(s.Sweep.Operations.Past.KeysReprovidedPerMinute))
442
formatLine(1, "%sRegion reprovide duration: %s", indent, humanDurationOrNA(s.Sweep.Operations.Past.RegionReprovideDuration))
443
formatLine(1, "%sAvg CIDs/reprovide: %s", indent, humanFloatOrNA(s.Sweep.Operations.Past.AvgKeysPerReprovide))
444
formatLine(1, "%sRegions reprovided (last cycle): %s", indent, humanNumber(s.Sweep.Operations.Past.RegionReprovidedLastCycle))
@@ -451,7 +451,7 @@ NOTES:
451
if displayWorkers || brief {
452
availableReservedBurst := max(0, s.Sweep.Workers.DedicatedBurst-s.Sweep.Workers.ActiveBurst)
453
availableReservedPeriodic := max(0, s.Sweep.Workers.DedicatedPeriodic-s.Sweep.Workers.ActivePeriodic)
454
- availableFreeWorkers := s.Sweep.Workers.Max - max(s.Sweep.Workers.DedicatedBurst, s.Sweep.Workers.ActiveBurst) - max(s.Sweep.Workers.DedicatedPeriodic, s.Sweep.Workers.ActivePeriodic)
454
+ availableFreeWorkers := max(0, s.Sweep.Workers.Max-max(s.Sweep.Workers.DedicatedBurst, s.Sweep.Workers.ActiveBurst)-max(s.Sweep.Workers.DedicatedPeriodic, s.Sweep.Workers.ActivePeriodic))
455
availableBurst := availableFreeWorkers + availableReservedBurst
456
availablePeriodic := availableFreeWorkers + availableReservedPeriodic
457
@@ -463,7 +463,7 @@ NOTES:
463
if compactMode {
464
specifyWorkers = ""
465
}
466
- formatLine(0, "%sActive%s: %s / %s (max)", indent, specifyWorkers, humanNumber(s.Sweep.Workers.Active), humanNumber(s.Sweep.Workers.Max))
466
+ formatLine(0, "%sActive%s: %s / %s (max)", indent, specifyWorkers, humanNumber(s.Sweep.Workers.Active), humanFull(float64(s.Sweep.Workers.Max), 0))
467
if brief {
468
// Brief mode - show condensed worker info
469
formatLine(0, "%sPeriodic%s: %s active, %s available, %s queued", indent, specifyWorkers,
@@ -472,7 +472,7 @@ NOTES:
472
humanNumber(s.Sweep.Workers.ActiveBurst), humanNumber(availableBurst), humanNumber(s.Sweep.Workers.QueuedBurst))
473
} else {
474
formatLine(0, "%sFree%s: %s", indent, specifyWorkers, humanNumber(availableFreeWorkers))
475
- formatLine(0, "%sWorkers stats:%s %-9s %s", indent, " ", "Periodic", "Burst")
475
+ formatLine(0, "%s %-14s %-9s %s", indent, "Workers stats:", "Periodic", "Burst")
476
formatLine(0, "%s %-14s %-9s %s", indent, "Active:", humanNumber(s.Sweep.Workers.ActivePeriodic), humanNumber(s.Sweep.Workers.ActiveBurst))
477
formatLine(0, "%s %-14s %-9s %s", indent, "Dedicated:", humanNumber(s.Sweep.Workers.DedicatedPeriodic), humanNumber(s.Sweep.Workers.DedicatedBurst))
478
formatLine(0, "%s %-14s %-9s %s", indent, "Available:", humanNumber(availablePeriodic), humanNumber(availableBurst))
@@ -559,7 +559,7 @@ func humanFloatOrNA(val float64) string {
559
if val <= 0 {
560
return "N/A"
561
}
562
- return fmt.Sprintf("%.1f", val)
562
+ return humanFull(val, 1)
563
}
564
565
func humanSI(val float64, decimals int) string {
core/node/provider.go
+1
-1
@@ -562,7 +562,7 @@ func SweepingProviderOpt(cfg *config.Config) fx.Option {
562
defer ticker.Stop()
563
564
var (
565
- queueSize, prevQueueSize int
565
+ queueSize, prevQueueSize int64
566
queuedWorkers, prevQueuedWorkers bool
567
count int
568
)
docs/examples/kubo-as-a-library/go.mod
+1
-1
@@ -115,7 +115,7 @@ require (
115
github.com/libp2p/go-doh-resolver v0.5.0 // indirect
116
github.com/libp2p/go-flow-metrics v0.3.0 // indirect
117
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
118
- github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac // indirect
118
+ github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781 // indirect
119
github.com/libp2p/go-libp2p-kbucket v0.8.0 // indirect
120
github.com/libp2p/go-libp2p-pubsub v0.14.2 // indirect
121
github.com/libp2p/go-libp2p-pubsub-router v0.6.0 // indirect
docs/examples/kubo-as-a-library/go.sum
+2
-2
@@ -434,8 +434,8 @@ github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl9
434
github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8=
435
github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV5VxfIrm0bcI0g=
436
github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL6+TrrxANBjPGw=
437
-github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac h1:2TWHkp8MJBLfwIRMUfvjFb2DABcjLaYAwVBzAEirkhU=
438
-github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac/go.mod h1:aHMTg23iseX9grGSfA5gFUzLrqzmYbA8PqgGPqM8VkI=
437
+github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781 h1:oTzgZExvlcixPXIXO7Knojv5yYoBB5SMLUmgtNzBGfY=
438
+github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781/go.mod h1:aHMTg23iseX9grGSfA5gFUzLrqzmYbA8PqgGPqM8VkI=
439
github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio=
440
github.com/libp2p/go-libp2p-kbucket v0.8.0 h1:QAK7RzKJpYe+EuSEATAaaHYMYLkPDGC18m9jxPLnU8s=
441
github.com/libp2p/go-libp2p-kbucket v0.8.0/go.mod h1:JMlxqcEyKwO6ox716eyC0hmiduSWZZl6JY93mGaaqc4=
docs/provide-stats.md
+17
-9
@@ -144,15 +144,23 @@ reprovides).
144
Number of failed region provide/reprovide operations since startup. Failed
145
regions are automatically retried unless the node is offline.
146
147
-### CIDs provided/min
148
-
149
-Average rate of initial provides per minute during the last reprovide cycle
150
-(excludes reprovides).
151
-
152
-### CIDs reprovided/min
153
-
154
-Average rate of reprovides per minute during the last reprovide cycle (excludes
155
-initial provides).
147
+### CIDs provided/min/worker
148
+
149
+Average rate of initial provides per minute per worker during the last
150
+reprovide cycle (excludes reprovides). Each worker handles one keyspace region
151
+at a time, providing all CIDs in that region. This rate only counts active time
152
+(timer doesn't run when no initial provides are being processed). The overall
153
+provide rate can be higher when multiple workers are providing different
154
+regions concurrently.
155
+
156
+### CIDs reprovided/min/worker
157
+
158
+Average rate of reprovides per minute per worker during the last reprovide
159
+cycle (excludes initial provides). Each worker handles one keyspace region at a
160
+time, reproviding all CIDs in that region. The overall reprovide rate can be
161
+higher when multiple workers are reproviding different regions concurrently. To
162
+estimate total reprovide rate, multiply by the number of [periodic
163
+workers](./config.md#providedhtdedicatedperiodicworkers) in use.
164
165
### Region reprovide duration
166
go.mod
+1
-1
@@ -53,7 +53,7 @@ require (
53
github.com/libp2p/go-doh-resolver v0.5.0
54
github.com/libp2p/go-libp2p v0.44.0
55
github.com/libp2p/go-libp2p-http v0.5.0
56
- github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac
56
+ github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781
57
github.com/libp2p/go-libp2p-kbucket v0.8.0
58
github.com/libp2p/go-libp2p-pubsub v0.14.2
59
github.com/libp2p/go-libp2p-pubsub-router v0.6.0
go.sum
+2
-2
@@ -518,8 +518,8 @@ github.com/libp2p/go-libp2p-gostream v0.6.0 h1:QfAiWeQRce6pqnYfmIVWJFXNdDyfiR/qk
518
github.com/libp2p/go-libp2p-gostream v0.6.0/go.mod h1:Nywu0gYZwfj7Jc91PQvbGU8dIpqbQQkjWgDuOrFaRdA=
519
github.com/libp2p/go-libp2p-http v0.5.0 h1:+x0AbLaUuLBArHubbbNRTsgWz0RjNTy6DJLOxQ3/QBc=
520
github.com/libp2p/go-libp2p-http v0.5.0/go.mod h1:glh87nZ35XCQyFsdzZps6+F4HYI6DctVFY5u1fehwSg=
521
-github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac h1:2TWHkp8MJBLfwIRMUfvjFb2DABcjLaYAwVBzAEirkhU=
522
-github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac/go.mod h1:aHMTg23iseX9grGSfA5gFUzLrqzmYbA8PqgGPqM8VkI=
521
+github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781 h1:oTzgZExvlcixPXIXO7Knojv5yYoBB5SMLUmgtNzBGfY=
522
+github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781/go.mod h1:aHMTg23iseX9grGSfA5gFUzLrqzmYbA8PqgGPqM8VkI=
523
github.com/libp2p/go-libp2p-kbucket v0.3.1/go.mod h1:oyjT5O7tS9CQurok++ERgc46YLwEpuGoFq9ubvoUOio=
524
github.com/libp2p/go-libp2p-kbucket v0.8.0 h1:QAK7RzKJpYe+EuSEATAaaHYMYLkPDGC18m9jxPLnU8s=
525
github.com/libp2p/go-libp2p-kbucket v0.8.0/go.mod h1:JMlxqcEyKwO6ox716eyC0hmiduSWZZl6JY93mGaaqc4=
test/dependencies/go.mod
+1
-1
@@ -184,7 +184,7 @@ require (
184
github.com/libp2p/go-flow-metrics v0.3.0 // indirect
185
github.com/libp2p/go-libp2p v0.44.0 // indirect
186
github.com/libp2p/go-libp2p-asn-util v0.4.1 // indirect
187
- github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac // indirect
187
+ github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781 // indirect
188
github.com/libp2p/go-libp2p-kbucket v0.8.0 // indirect
189
github.com/libp2p/go-libp2p-record v0.3.1 // indirect
190
github.com/libp2p/go-libp2p-routing-helpers v0.7.5 // indirect
test/dependencies/go.sum
+2
-2
@@ -468,8 +468,8 @@ github.com/libp2p/go-libp2p v0.44.0 h1:5Gtt8OrF8yiXmH+Mx4+/iBeFRMK1TY3a8OrEBDEqA
468
github.com/libp2p/go-libp2p v0.44.0/go.mod h1:NovCojezAt4dnDd4fH048K7PKEqH0UFYYqJRjIIu8zc=
469
github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94=
470
github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8=
471
-github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac h1:2TWHkp8MJBLfwIRMUfvjFb2DABcjLaYAwVBzAEirkhU=
472
-github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251017193437-abd04263daac/go.mod h1:aHMTg23iseX9grGSfA5gFUzLrqzmYbA8PqgGPqM8VkI=
471
+github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781 h1:oTzgZExvlcixPXIXO7Knojv5yYoBB5SMLUmgtNzBGfY=
472
+github.com/libp2p/go-libp2p-kad-dht v0.35.2-0.20251028150720-c3f8d33dc781/go.mod h1:aHMTg23iseX9grGSfA5gFUzLrqzmYbA8PqgGPqM8VkI=
473
github.com/libp2p/go-libp2p-kbucket v0.8.0 h1:QAK7RzKJpYe+EuSEATAaaHYMYLkPDGC18m9jxPLnU8s=
474
github.com/libp2p/go-libp2p-kbucket v0.8.0/go.mod h1:JMlxqcEyKwO6ox716eyC0hmiduSWZZl6JY93mGaaqc4=
475
github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg=