You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(provide): detailed ipfs provide stat (#11019)
* feat: provide stats
* added N/A
* format
* workers stats alignment
* ipfs provide stat --all --compact
* consolidating compact stat
* update column alignment
* flags combinations errors
* command description
* change schedule AvgPrefixLen to float
* changelog
* alignments
* provide stat description draft
* rephrased provide-stats.md
* linking provide-stats.md from command description
* documentation test
* fix: refactor provide stat command type handling
- add extractSweepingProvider() helper to reduce nested type switching
- extract lowWorkerThreshold constant for worker availability check
- fix --lan error handling to work with buffered providers
* docs: add clarifying comments
* fix(commands): improve provide stat compact mode
- prevent panic when both columns are empty
- fix column alignment with UTF-8 characters
- only track col0MaxWidth for first column (as intended)
* test: add tests for ipfs provide stat command
- test basic functionality, flags, JSON output
- test legacy provider behavior
- test integration with content scheduling
- test disabled provider configurations
- add parseSweepStats helper with t.Helper()
* docs: improve provide command help text
- update tagline to "Control and monitor content providing"
- simplify help descriptions
- make error messages more consistent
- update tests to match new error messages
* metrics rename
```
Next reprovide at:
Next prefix:
```
updated to:
```
Next region prefix:
Next region reprovide:
```
* docs: improve Provide system documentation clarity
Enhance documentation for the Provide system to better explain how provider
records work and the differences between sweep and legacy modes.
Changes to docs/config.md:
- Provide section: add clear explanation of provider records and their role
- Provide.DHT: add provider record lifecycle and two provider systems overview
- Provide.DHT.Interval: explain relationship to expiration, contrast sweep vs legacy behavior
- Provide.DHT.SweepEnabled: rewrite to explain legacy problem, sweep solution, and efficiency gains
- Monitoring section: prioritize command-line tools (ipfs provide stat) before Prometheus
Changes to core/commands/provide.go:
- ipfs provide stat help: add explanation of provider records, TTL expiration, and how sweep batching works
Changes to docs/changelogs/v0.39.md:
- Add context about why stats matter for monitoring provider health
- Emphasize real-time monitoring workflow with watch command
- Explain what users can observe (rates, queues, worker availability)
* depend on latest kad-dht master
* docs: nits
---------
Co-authored-by: Marcin Rataj <[email protected]>
> Legacy provider shows basic statistics without flag support.
63
+
21
64
#### 🪦 Deprecated `go-ipfs` name no longer published
22
65
23
66
The `go-ipfs` name was deprecated in 2022 and renamed to `kubo`. Starting with this release, we have stopped publishing Docker images and distribution binaries under the old `go-ipfs` name.
24
67
25
68
Existing users should switch to:
69
+
26
70
- Docker: `ipfs/kubo` image (instead of `ipfs/go-ipfs`)
27
-
- Binaries: download from https://dist.ipfs.tech/kubo/ or https://github.com/ipfs/kubo/releases
71
+
- Binaries: download from <https://dist.ipfs.tech/kubo/> or <https://github.com/ipfs/kubo/releases>
28
72
29
73
For Docker users, the legacy `ipfs/go-ipfs` image name now shows a deprecation notice directing you to `ipfs/kubo`.
Your node must re-announce (reprovide) content periodically to keep it
1977
+
discoverable. The [`Provide.DHT.Interval`](#providedhtinterval) setting
1978
+
controls this timing, with the default ensuring records refresh well before
1979
+
expiration or negative churn effects kick in.
1980
+
1981
+
**Two provider systems:**
1982
+
1983
+
-**Sweep provider**: Divides the DHT keyspace into regions and systematically
1984
+
sweeps through them over the reprovide interval. This batches CIDs allocated
1985
+
to the same DHT servers, dramatically reducing the number of DHT lookups and
1986
+
PUTs needed. Spreads work evenly over time with predictable resource usage.
1987
+
1988
+
-**Legacy provider**: Processes each CID individually with separate DHT
1989
+
lookups. Works well for small content collections but struggles to complete
1990
+
reprovide cycles when managing thousands of CIDs.
1991
+
1967
1992
#### Monitoring Provide Operations
1968
1993
1969
-
You can monitor the effectiveness of your provide configuration through metrics exposed at the Prometheus endpoint: `{Addresses.API}/debug/metrics/prometheus` (default: `http://127.0.0.1:5001/debug/metrics/prometheus`).
1994
+
**Quick command-line monitoring:** Use `ipfs provide stat` to view the current
1995
+
state of the provider system. For real-time monitoring, run
1996
+
`watch ipfs provide stat --all --compact` to see detailed statistics refreshed
1997
+
continuously in a 2-column layout.
1970
1998
1971
-
Different metrics are available depending on whether you use legacy mode (`SweepEnabled=false`) or sweep mode (`SweepEnabled=true`). See [Provide metrics documentation](https://github.com/ipfs/kubo/blob/master/docs/metrics.md#provide) for details.
1999
+
**Long-term monitoring:** For in-depth or long-term monitoring, metrics are
2000
+
exposed at the Prometheus endpoint: `{Addresses.API}/debug/metrics/prometheus`
2001
+
(default: `http://127.0.0.1:5001/debug/metrics/prometheus`). Different metrics
2002
+
are available depending on whether you use legacy mode (`SweepEnabled=false`) or
2003
+
sweep mode (`SweepEnabled=true`). See [Provide metrics documentation](https://github.com/ipfs/kubo/blob/master/docs/metrics.md#provide)
2004
+
for details.
1972
2005
1973
-
To enable detailed debug logging for both providers, set:
2006
+
**Debug logging:** For troubleshooting, enable detailed logging by setting:
Sets how often to re-announce content to the DHT. Provider records on Amino DHT
1985
-
expire after [`amino.DefaultProvideValidity`](https://github.com/libp2p/go-libp2p-kad-dht/blob/v0.34.0/amino/defaults.go#L40-L43),
1986
-
also known as Provider Record Expiration Interval.
2018
+
expire after [`amino.DefaultProvideValidity`](https://github.com/libp2p/go-libp2p-kad-dht/blob/v0.34.0/amino/defaults.go#L40-L43).
2019
+
2020
+
**Why this matters:** The interval must be shorter than the expiration window to
2021
+
ensure provider records refresh before they expire. The default value is
2022
+
approximately half of [`amino.DefaultProvideValidity`](https://github.com/libp2p/go-libp2p-kad-dht/blob/v0.34.0/amino/defaults.go#L40-L43),
2023
+
which accounts for network churn and ensures records stay alive without
2024
+
overwhelming the network with unnecessary announcements.
1987
2025
1988
-
An interval of about half the expiration window ensures provider records
1989
-
are refreshed well before they expire. This keeps your content continuously
1990
-
discoverable accounting for network churn without overwhelming the network with too frequent announcements.
2026
+
**With sweep mode enabled
2027
+
([`Provide.DHT.SweepEnabled`](#providedhtsweepenabled)):** The system spreads
2028
+
reprovide operations smoothly across this entire interval. Each keyspace region
2029
+
is reprovided at scheduled times throughout the period, ensuring announcements
2030
+
periodically happen every interval.
2031
+
2032
+
**With legacy mode:** The system attempts to reprovide all CIDs as quickly as
2033
+
possible at the start of each interval. If reproviding takes longer than this
2034
+
interval (common with large datasets), the next cycle is skipped and provider
2035
+
records may expire.
1991
2036
1992
2037
- If unset, it uses the implicit safe default.
1993
2038
- If set to the value `"0"` it will disable content reproviding to DHT.
@@ -2055,46 +2100,60 @@ Type: `optionalInteger` (non-negative; `0` means unlimited number of workers)
2055
2100
2056
2101
#### `Provide.DHT.SweepEnabled`
2057
2102
2058
-
Whether Provide Sweep is enabled. If not enabled, the legacy
2059
-
[`boxo/provider`](https://github.com/ipfs/boxo/tree/main/provider) is used for
2060
-
both provides and reprovides.
2061
-
2062
-
Provide Sweep is a resource efficient technique for advertising content to
2063
-
the Amino DHT swarm. The Provide Sweep module tracks the keys that should be periodically reprovided in
2064
-
the `Keystore`. It splits the keys into DHT keyspace regions by proximity (XOR
2065
-
distance), and schedules when reprovides should happen in order to spread the
2066
-
reprovide operation over time to avoid a spike in resource utilization. It
2067
-
basically sweeps the keyspace _from left to right_ over the
2068
-
[`Provide.DHT.Interval`](#providedhtinterval) time period, and reprovides keys
2069
-
matching to the visited keyspace region.
2070
-
2071
-
Provide Sweep aims at replacing the inefficient legacy `boxo/provider`
2072
-
module, and is currently opt-in. You can compare the effectiveness of sweep mode vs legacy mode by monitoring the appropriate metrics (see [Monitoring Provide Operations](#monitoring-provide-operations) above).
2073
-
2074
-
Whenever new keys should be advertised to the Amino DHT, `kubo` calls
2075
-
`StartProviding()`, triggering an initial `provide` operation for the given
2076
-
keys. The keys will be added to the `Keystore` tracking which keys should be
2077
-
reprovided and when they should be reprovided. Calling `StopProviding()`
2078
-
removes the keys from the `Keystore`. However, it is currently tricky for
2079
-
`kubo` to detect when a key should stop being advertised. Hence, `kubo` will
2080
-
periodically refresh the `Keystore` at each [`Provide.DHT.Interval`](#providedhtinterval)
2081
-
by providing it a channel of all the keys it is expected to contain according
2082
-
to the [`Provide.Strategy`](#providestrategy). During this operation,
2083
-
all keys in the `Keystore` are purged, and only the given ones remain scheduled.
2103
+
Enables the sweep provider for efficient content announcements. When disabled,
2104
+
the legacy [`boxo/provider`](https://github.com/ipfs/boxo/tree/main/provider) is
2105
+
used instead.
2106
+
2107
+
**The legacy provider problem:** The legacy system processes CIDs one at a
2108
+
time, requiring a separate DHT lookup (10-20 seconds each) to find the 20
2109
+
closest peers for each CID. This sequential approach typically handles less
2110
+
than 10,000 CID over 22h ([`Provide.DHT.Interval`](#providedhtinterval)). If
2111
+
your node has more CIDs than can be reprovided within
2112
+
[`Provide.DHT.Interval`](#providedhtinterval), provider records start expiring
> Sweep mode provides similar effectiveness to Accelerated DHT but with steady resource usage - better for machines with limited CPU, memory, or network bandwidth.
2154
+
> Sweep mode achieves similar effectiveness to the Accelerated DHT client but with steady resource consumption.
2155
+
2156
+
You can compare the effectiveness of sweep mode vs legacy mode by monitoring the appropriate metrics (see [Monitoring Provide Operations](#monitoring-provide-operations) above).
2098
2157
2099
2158
> [!NOTE]
2100
2159
> This feature is opt-in for now, but will become the default in a future release.
0 commit comments