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

make Report.Topology(name) fast #3001

Merged
merged 4 commits into from
Dec 25, 2017
Merged

make Report.Topology(name) fast #3001

merged 4 commits into from
Dec 25, 2017

Conversation

rade
Copy link
Member

@rade rade commented Dec 24, 2017

Previously this was buidling a fresh map of all topologies, just so it could look up the one given as an argument.

Node summarisation (via detailed.Summaries()) in particular was badly affected by that.

Previously this was buidling a fresh map of all topologies, just so it
could look up the one given as an argument.

Node summarisation (via detailed.Summaries) in particular was badly
affected by that.
@rade rade requested a review from bboreham December 24, 2017 21:20
@rade
Copy link
Member Author

rade commented Dec 24, 2017

benchmarks from running

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

master

BenchmarkSummarizeHosts-2         	    1000	   1176833 ns/op	  780470 B/op	    1285 allocs/op
BenchmarkSummarizeControllers-2   	     300	   6092717 ns/op	 3829144 B/op	    7689 allocs/op
BenchmarkSummarizePods-2          	     100	  11990191 ns/op	 7058585 B/op	   15140 allocs/op
BenchmarkSummarizeContainers-2    	      50	  62106253 ns/op	33253299 B/op	  110870 allocs/op
BenchmarkSummarizeProcesses-2     	     100	  15227052 ns/op	 9166401 B/op	   17965 allocs/op

branch

BenchmarkSummarizeHosts-2         	   10000	    156431 ns/op	   49526 B/op	     394 allocs/op
BenchmarkSummarizeControllers-2   	    2000	   1027057 ns/op	  348434 B/op	    3447 allocs/op
BenchmarkSummarizePods-2          	     500	   2475295 ns/op	  828243 B/op	    7548 allocs/op
BenchmarkSummarizeContainers-2    	     100	  29804019 ns/op	11219051 B/op	   84011 allocs/op
BenchmarkSummarizeProcesses-2     	     500	   2652562 ns/op	  881735 B/op	    7866 allocs/op

rade added 3 commits December 24, 2017 22:26
Having 6 lists of topolgies in the same file is a bit much:

1. consts for topology names
2. Report type definition
3. MakeReport() Report initialisation
4. Report.Topology(name) lookup
5. Report.TopologyMap() mapping of names to topology references
6. Report.WalkPairedTopologies() iterator over topology references

We get rid of 5 and 6 by introducing a topologyNames slice. So we
are down to 5.

We replace Report.TopologyMap() with a new function,
WalkNamedTopologies, that uses topologyNames. WalkPairedTopologies()
is updated to operate in a similar fashion. Likewise for
WalkTopologies() and Topologies() - these were previously calling
Walk[Paired]Topologies, but it is clearer to simply implement them
directly.
The three report.Walk* functions are quite enough.
@rade rade force-pushed the fast-topology-lookup branch from 760862c to dcda884 Compare December 24, 2017 22:30
@rade rade merged commit 78b9ac3 into master Dec 25, 2017
@rade
Copy link
Member Author

rade commented Dec 25, 2017

I've merged this since it's all pretty straightforward.

@rade rade deleted the fast-topology-lookup branch December 25, 2017 13: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.

1 participant