Skip to content

Commit b033ae8

Browse files
authored
Update distance tracking one provider at a time (#47)
Distance tracking needs to run without taking excessibe memory, and this is bounded by setting the max advertisement chain depth. If there is unbounded concurrency, that is measuring all providers at the same time, then memory consumption can no longer be bounded.
1 parent 2c3d896 commit b033ae8

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

pkg/dtrack/distance_tracker.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dtrack
33
import (
44
"context"
55
"fmt"
6-
"sync"
76
"time"
87

98
"github.com/ipfs/go-cid"
@@ -88,15 +87,9 @@ func runTracker(ctx context.Context, include, exclude map[peer.ID]struct{}, prov
8887
}
8988

9089
func updateTracks(ctx context.Context, provCache *pcache.ProviderCache, tracks map[peer.ID]*distTrack, depthLimit int64, updates chan<- DistanceUpdate) {
91-
var wg sync.WaitGroup
92-
for providerID, dtrack := range tracks {
93-
wg.Add(1)
94-
go func(pid peer.ID, track *distTrack) {
95-
updateTrack(ctx, pid, track, provCache, depthLimit, updates)
96-
wg.Done()
97-
}(providerID, dtrack)
90+
for providerID, track := range tracks {
91+
updateTrack(ctx, providerID, track, provCache, depthLimit, updates)
9892
}
99-
wg.Wait()
10093
}
10194

10295
func updateTrack(ctx context.Context, pid peer.ID, track *distTrack, provCache *pcache.ProviderCache, depthLimit int64, updates chan<- DistanceUpdate) {

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.0.6"
2+
"version": "v0.0.7"
33
}

0 commit comments

Comments
 (0)