Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

swarm/network: Keep span across roundtrip #1210

Closed
wants to merge 20 commits into from

Conversation

nolash
Copy link
Contributor

@nolash nolash commented Feb 8, 2019

This PR addresses #1209 (see copy of description below) which is an incremental part of #1181

Until now, the spans are only valid within internal peer contexts, but we may want to trace durations from node makes request to node received delivery.

According to opentracing support, if a Span is to persist across asynchronous operations, it's the requester's responsibility to remember the Span and Finish() it accordingly. In other words, a Span cannot be recalled after passing through the tracer.Inject()/tracer.Extract() serialization, only new spans (ChildOf(), FollowFrom()) can be created from the SpanContext that's passed on.

To this end, I've introduced a "store" for spans to be remembered. This "store" is a singleton per swarm instance. It seems to me to belong in the swarm/tracing package, so I put it there.


Unlike LazyChunkReader.Read, we don't know how long a single Retrieve Request took. We should update the spans to record the full duration of a retrieve request, until it is actually delivered on the requestor node.

Good
screen shot 2019-02-08 at 15 26 04

Bad
screen shot 2019-02-08 at 15 26 21

Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should document this code more?

swarm/tracing/tracing.go Show resolved Hide resolved
swarm/tracing/tracing.go Show resolved Hide resolved
swarm/storage/filestore_test.go Outdated Show resolved Hide resolved
@skylenet
Copy link
Contributor

image

Looks way better than before. Now we can see which stream.send.request took longer, therefore increasing also the time on lcr.read

matthalp and others added 8 commits February 18, 2019 07:48
This corrects the previous change which broke the build and
was pushed by accident.
This changes default location of the data directory to use the LOCALAPPDATA
environment variable, resolving issues with remote home directories an improving
compatibility with Cygwin.

Fixes #2239 
Fixes #2237 
Fixes #16437
Package crypto works with or without cgo, which is great. However, to make it
work without cgo required setting the build tag `nocgo`. It's common to disable
cgo by instead just setting the environment variable `CGO_ENABLED=0`. Setting
this environment variable does _not_ implicitly set the build tag `nocgo`. So
projects that try to build the crypto package with `CGO_ENABLED=0` will fail. I
have done this myself several times. Until today, I had just assumed that this
meant that this package requires cgo.

But a small build tag change will make this case work. Instead of using `nocgo`
and `!nocgo`, we can use `!cgo` and `cgo`, respectively. The `cgo` build tag is
automatically set if cgo is enabled, and unset if it is disabled.
Matthalp-zz and others added 3 commits February 19, 2019 19:49
Simplifies the transaction presense check to use a function to
determine if the transaction is present in the block provided
to trace, which originally had a redundant parenthesis and used
a `exist` flag to dictate control flow.
Copy link
Member

@acud acud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please fix the few minor comments before submitting upstream <3

@@ -83,16 +84,11 @@ func NewPeer(peer *protocols.Peer, streamer *Registry) *Peer {
clients: make(map[Stream]*client),
clientParams: make(map[Stream]*clientParams),
quit: make(chan struct{}),
spans: sync.Map{},
//spans: sync.Map{},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -884,6 +887,10 @@ func (r *Registry) Start(server *p2p.Server) error {
}

func (r *Registry) Stop() error {
r.spans.Range(func(k, v interface{}) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_, v interface{})?

@@ -1,4 +1,4 @@
// Copyright 2016 The go-ethereum Authors
//// Copyright 2016 The go-ethereum Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//

// FinishSpans calls `Finish()` on all stored spans
// It should be called on instance shutdown
func FinishSpans() {
store.spans.Range(func(k, v interface{}) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_,v

@nolash
Copy link
Contributor Author

nolash commented Feb 20, 2019

submitted upstream ethereum/go-ethereum#19140

@nolash nolash closed this Feb 20, 2019
@nolash nolash deleted the trace-request-across-protocol branch June 5, 2019 13:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.