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

cope with one->many topology mappings #2996

Merged
merged 2 commits into from
Dec 20, 2017
Merged

cope with one->many topology mappings #2996

merged 2 commits into from
Dec 20, 2017

Conversation

rade
Copy link
Member

@rade rade commented Dec 19, 2017

We need this when mapping from container images to hosts - the same container image can reside on multiple hosts - and from pods to services - the same pod can be selected by multiple services. (Though the latter case currently isn't using joinResults.)

@rade rade requested a review from bboreham December 19, 2017 19:25
@rade
Copy link
Member Author

rade commented Dec 19, 2017

I will squash the two commits. The intermediate commits shows the simple solution, but it causes too much of a performance degradation. Benchmarks from running

go test -tags 'netgo unsafe' -run=x -cpu=2 -benchmem -bench='Topology' --bench-report-path=/tmp/dev-on-dev-report.json

show (best results of three runs)...

master

BenchmarkTopologyList-2          	       5	 213608474 ns/op	83141875 B/op	  617248 allocs/op
BenchmarkTopologyHosts-2         	      20	 130394925 ns/op	55311573 B/op	  429426 allocs/op
BenchmarkTopologyControllers-2   	      20	 116441786 ns/op	45196386 B/op	  344697 allocs/op
BenchmarkTopologyPods-2          	      20	 104019790 ns/op	38841077 B/op	  289083 allocs/op
BenchmarkTopologyContainers-2    	      20	  75261315 ns/op	29496258 B/op	  217927 allocs/op
BenchmarkTopologyProcesses-2     	      30	  47699918 ns/op	14889463 B/op	   69993 allocs/op

intermediate

BenchmarkTopologyList-2          	       5	 218944680 ns/op	84870128 B/op	  647710 allocs/op
BenchmarkTopologyHosts-2         	      20	 137130296 ns/op	56615384 B/op	  452493 allocs/op
BenchmarkTopologyControllers-2   	      20	 121133337 ns/op	45773628 B/op	  355381 allocs/op
BenchmarkTopologyPods-2          	      20	 103948921 ns/op	39471932 B/op	  300246 allocs/op
BenchmarkTopologyContainers-2    	      20	  72434024 ns/op	29709738 B/op	  221733 allocs/op
BenchmarkTopologyProcesses-2     	      30	  48009831 ns/op	15090687 B/op	   73562 allocs/op

final

BenchmarkTopologyList-2          	       5	 216881152 ns/op	83195312 B/op	  617550 allocs/op
BenchmarkTopologyHosts-2         	      10	 131824903 ns/op	55332674 B/op	  429578 allocs/op
BenchmarkTopologyControllers-2   	      20	 118632501 ns/op	45110930 B/op	  343866 allocs/op
BenchmarkTopologyPods-2          	      20	 103424067 ns/op	38839952 B/op	  289083 allocs/op
BenchmarkTopologyContainers-2    	      20	  69692976 ns/op	29493521 B/op	  217925 allocs/op
BenchmarkTopologyProcesses-2     	      30	  48244260 ns/op	14888529 B/op	   69993 allocs/op

one->many is much rarer
for _, a := range adjacency {
if mappedDest, found := ret.mapped[a]; found {
out.Adjacency = out.Adjacency.Add(mappedDest)
out.Adjacency = out.Adjacency.Add(ret.multi[a]...)

This comment was marked as abuse.

This comment was marked as abuse.

@rade rade merged commit dd2dfd5 into master Dec 20, 2017
@rade rade deleted the multi-join branch December 25, 2017 10:15
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.

2 participants