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
{{ message }}
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
swarm/network/fetcher.go is very convoluted, due to tracking of outgoing chunk requests
swarm/storage/netstore.go, fetcher struct is convoluted and obscures the API behind required params in context.Context, which change the control flow - namely source.
Delivery and NetStore are coupled via the FetchFunc and context.Context.
Fetcher and fetcher naming are very confusing.
Fetcher contains a context as part of its struct.
Tracing is mostly broken, apart from one or two traces (see SendPriority).
Because of this I propose:
Most of this results in very difficult code to understand and trace. Some of the functionality can be replaced with https://godoc.org/golang.org/x/sync/singleflight and we can reduce complexity with it (swarm/network/fetcher.go).
Reduce complexity for chunk requests across the network. Currently we have the following flow:
// doRequest attempts at finding a peer to request the chunk from
// * first it tries to request explicitly from peers that are known to have offered the chunk
// * if there are no such peers (available) it tries to request it from a peer closest to the chunk address
// excluding those in the peersToSkip map
// * if no such peer is found an error is returned
I suggest we skip the first part for simplicity, and only add it if necessary.
Decide on context cancelation across process boundary.
All of this will help with the numerous issues we have with Swarm being slow. Also related: #1148
Currently the code in:
swarm/network/fetcher.gois very convoluted, due to tracking of outgoing chunk requestsswarm/storage/netstore.go,fetcherstruct is convoluted and obscures the API behind required params incontext.Context, which change the control flow - namelysource.DeliveryandNetStoreare coupled via theFetchFuncandcontext.Context.Fetcherandfetchernaming are very confusing.Fetchercontains acontextas part of its struct.SendPriority).Because of this I propose:
Most of this results in very difficult code to understand and trace. Some of the functionality can be replaced with https://godoc.org/golang.org/x/sync/singleflight and we can reduce complexity with it (
swarm/network/fetcher.go).Reduce complexity for chunk requests across the network. Currently we have the following flow:
I suggest we skip the first part for simplicity, and only add it if necessary.
All of this will help with the numerous issues we have with Swarm being slow. Also related: #1148