Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor snet writer; move path resolution outside main lock #2145

Merged
merged 2 commits into from
Nov 21, 2018
Merged

Refactor snet writer; move path resolution outside main lock #2145

merged 2 commits into from
Nov 21, 2018

Conversation

scrye
Copy link
Contributor

@scrye scrye commented Nov 20, 2018

This partially fixes #1702.


This change is Reviewable

Copy link
Collaborator

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @scrye)


go/lib/snet/writer.go, line 147 at r1 (raw file):

// WriteToSCION.
type connRemoteAddressResolver struct {
	remoteAddressResolver *remoteAddressResolver

It feels a bit heavy to have an extra object here ( for a single method). OTOH it makes the code quite clean.
Maybe we could try to move resolve to remoteAddressResolver and rename it's existing resolve method to resolveAddr ? But if you feel it is less nice feel free to leave it as is.


go/lib/snet/writer.go, line 158 at r1 (raw file):

	case connAddr != nil:
		return r.remoteAddressResolver.resolve(connAddr)
	default:

It's not directly obvious that in this case argAddr != nil maybe add a comment?


go/lib/snet/writer_test.go, line 21 at r1 (raw file):

	"testing"

	"github.com/golang/mock/gomock"

Fix the imports ;) also goconvey


go/lib/snet/internal/util/util.go, line 15 at r1 (raw file):

// limitations under the License.

package util

This only contains Pathsource why not call the package or at least the file like this?


go/lib/snet/internal/util/util.go, line 45 at r1 (raw file):

Passing in a nil resolver is

Why/Where is that useful?

Copy link
Contributor Author

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 6 files reviewed, 5 unresolved discussions (waiting on @lukedirtwalker)


go/lib/snet/writer.go, line 147 at r1 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

It feels a bit heavy to have an extra object here ( for a single method). OTOH it makes the code quite clean.
Maybe we could try to move resolve to remoteAddressResolver and rename it's existing resolve method to resolveAddr ? But if you feel it is less nice feel free to leave it as is.

Ah, good point, didn't even notice during refactoring how small this got. Done.


go/lib/snet/writer.go, line 158 at r1 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

It's not directly obvious that in this case argAddr != nil maybe add a comment?

Done.


go/lib/snet/writer_test.go, line 21 at r1 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

Fix the imports ;) also goconvey

Done.


go/lib/snet/internal/util/util.go, line 15 at r1 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

This only contains Pathsource why not call the package or at least the file like this?

Done.


go/lib/snet/internal/util/util.go, line 45 at r1 (raw file):

Previously, lukedirtwalker (Lukas Vogel) wrote…
Passing in a nil resolver is

Why/Where is that useful?

When snet runs without a path resolver, it can still build the remote address resolution objects without having them deal with the fact that there is no source of paths.

So it moves error handling from deep insnet to the path source itself.

The alternative is to check if the PathSource is nil in the resolver. It depends on how one looks at the abstraction: does the path source have the responsibility of always providing a path, or does snet have the responsibility of checking it has a source, and invoking it (which in turn can eventually return a similar event, i.e., no paths). It just felt more natural to put it in the path source, but I don't have strong feelings on the matter.

Copy link
Collaborator

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@scrye scrye merged commit bebbdfd into scionproto:master Nov 21, 2018
@scrye scrye deleted the pubpr-refactor-snet-writer branch November 21, 2018 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

snet: Path lookup in snet.Write greatly degrades performance when called in parallel
2 participants