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

Use ps.Map for Counters and Sets, remove Metadata in favour of Latest. #838

Merged
merged 12 commits into from
Jan 25, 2016

Conversation

tomwilkie
Copy link
Contributor

Part of #502, helps towards #812 & #854.

@tomwilkie tomwilkie self-assigned this Jan 18, 2016
@tomwilkie tomwilkie force-pushed the 502-more-immutability branch from d434454 to 3a58b74 Compare January 19, 2016 00:31
@tomwilkie
Copy link
Contributor Author

This only shows a small improvement vs master.

This change:

Toms-MacBook-Pro:render twilkie$ go test -bench .
PASS
BenchmarkEndpointRender-8                      10000        120894 ns/op       46217 B/op        655 allocs/op
BenchmarkEndpointStats-8                    100000000           18.9 ns/op       0 B/op        0 allocs/op
BenchmarkProcessRender-8                       10000        229275 ns/op       87324 B/op       1166 allocs/op
BenchmarkProcessStats-8                     20000000            64.5 ns/op       0 B/op        0 allocs/op
BenchmarkProcessWithContainerNameRender-8       5000        259938 ns/op       96385 B/op       1310 allocs/op
BenchmarkProcessWithContainerNameStats-8    20000000            75.3 ns/op       0 B/op        0 allocs/op
BenchmarkProcessNameRender-8                    5000        289304 ns/op      110414 B/op       1414 allocs/op
BenchmarkProcessNameStats-8                 100000000           20.2 ns/op         0 B/op          0 allocs/op
BenchmarkContainerRender-8                      3000        426344 ns/op      149200 B/op       2037 allocs/op
BenchmarkContainerStats-8                       3000        355616 ns/op      128917 B/op       1825 allocs/op
BenchmarkContainerWithImageNameRender-8         3000        435100 ns/op      160829 B/op       2170 allocs/op
BenchmarkContainerWithImageNameStats-8          3000        350997 ns/op      128936 B/op       1825 allocs/op
BenchmarkContainerImageRender-8                 2000        523001 ns/op      197214 B/op       2494 allocs/op
BenchmarkContainerImageStats-8              100000000           19.4 ns/op         0 B/op          0 allocs/op
BenchmarkContainerHostnameRender-8              3000        423759 ns/op      156442 B/op       2131 allocs/op
BenchmarkContainerHostnameStats-8           100000000           18.8 ns/op         0 B/op          0 allocs/op
BenchmarkHostRender-8                          10000        125865 ns/op       53674 B/op        591 allocs/op
BenchmarkHostStats-8                        20000000            64.4 ns/op         0 B/op          0 allocs/op
BenchmarkPodRender-8                            2000        502690 ns/op      189855 B/op       2402 allocs/op
BenchmarkPodStats-8                         100000000           19.2 ns/op         0 B/op          0 allocs/op
BenchmarkPodServiceRender-8                     2000        596074 ns/op      226953 B/op       2728 allocs/op
BenchmarkPodServiceStats-8                  100000000           18.9 ns/op         0 B/op          0 allocs/op
ok      github.com/weaveworks/scope/render  33.525s

master:

Toms-MacBook-Pro:render twilkie$ go test -bench .
PASS
BenchmarkEndpointRender-8                      10000        136654 ns/op       52423 B/op        773 allocs/op
BenchmarkEndpointStats-8                    100000000           19.2 ns/op         0 B/op          0 allocs/op
BenchmarkProcessRender-8                        5000        252663 ns/op       97502 B/op       1372 allocs/op
BenchmarkProcessStats-8                     20000000            63.9 ns/op         0 B/op          0 allocs/op
BenchmarkProcessWithContainerNameRender-8       5000        284485 ns/op      107775 B/op       1540 allocs/op
BenchmarkProcessWithContainerNameStats-8    20000000            73.8 ns/op         0 B/op          0 allocs/op
BenchmarkProcessNameRender-8                    5000        322436 ns/op      121794 B/op       1639 allocs/op
BenchmarkProcessNameStats-8                 100000000           19.3 ns/op         0 B/op          0 allocs/op
BenchmarkContainerRender-8                      3000        438796 ns/op      167064 B/op       2390 allocs/op
BenchmarkContainerStats-8                       3000        381435 ns/op      145151 B/op       2141 allocs/op
BenchmarkContainerWithImageNameRender-8         3000        470924 ns/op      179896 B/op       2546 allocs/op
BenchmarkContainerWithImageNameStats-8          3000        388080 ns/op      145163 B/op       2142 allocs/op
BenchmarkContainerImageRender-8                 2000        559187 ns/op      218356 B/op       2908 allocs/op
BenchmarkContainerImageStats-8              100000000           19.0 ns/op         0 B/op          0 allocs/op
BenchmarkContainerHostnameRender-8              3000        458770 ns/op      174065 B/op       2484 allocs/op
BenchmarkContainerHostnameStats-8           100000000           19.0 ns/op         0 B/op          0 allocs/op
BenchmarkHostRender-8                          10000        145496 ns/op       61871 B/op        709 allocs/op
BenchmarkHostStats-8                        20000000            69.0 ns/op         0 B/op          0 allocs/op
BenchmarkPodRender-8                            2000        554012 ns/op      210833 B/op       2802 allocs/op
BenchmarkPodStats-8                         100000000           20.7 ns/op         0 B/op          0 allocs/op
BenchmarkPodServiceRender-8                     2000        693266 ns/op      249112 B/op       3152 allocs/op
BenchmarkPodServiceStats-8                  50000000            20.1 ns/op         0 B/op          0 allocs/op
ok      github.com/weaveworks/scope/render  34.110s

@paulbellamy
Copy link
Contributor

rebased on master after #752 merge

@paulbellamy paulbellamy force-pushed the 502-more-immutability branch from 3a58b74 to e8a6fa4 Compare January 20, 2016 11:11
@paulbellamy
Copy link
Contributor

After rebasing, with a slow report, it looks to give a ~20% decrease in render times against master

@tomwilkie
Copy link
Contributor Author

Sweet!

I think next steps are doing this for metadata (or moving all the uses of
metadata to latest) and doing this for controls.

I also want to figure out a way of measuring the cpu cost on a per path
basis, maybe by just measuring latency of each http request?

On Wednesday, 20 January 2016, Paul Bellamy [email protected]
wrote:

After rebasing, with a slow report, it looks to give a ~20% decrease in
render times.


Reply to this email directly or view it on GitHub
#838 (comment).

@tomwilkie tomwilkie force-pushed the 502-more-immutability branch 2 times, most recently from 822501a to c05659b Compare January 21, 2016 22:55
@tomwilkie
Copy link
Contributor Author

After rebase:

Toms-MacBook-Pro:render twilkie$ go test -bench . -- -bench-report-file report.json 
PASS
BenchmarkEndpointRender-8                      10000        114758 ns/op       46583 B/op        636 allocs/op
BenchmarkEndpointStats-8                    100000000           20.6 ns/op       0 B/op        0 allocs/op
BenchmarkProcessRender-8                       10000        244565 ns/op       98794 B/op       1209 allocs/op
BenchmarkProcessStats-8                     20000000            69.3 ns/op         0 B/op          0 allocs/op
BenchmarkProcessWithContainerNameRender-8       5000        276988 ns/op      114176 B/op       1380 allocs/op
BenchmarkProcessWithContainerNameStats-8    20000000            78.4 ns/op         0 B/op          0 allocs/op
BenchmarkProcessNameRender-8                    5000        298939 ns/op      127116 B/op       1473 allocs/op
BenchmarkProcessNameStats-8                 100000000           20.1 ns/op         0 B/op          0 allocs/op
BenchmarkContainerRender-8                      3000        446539 ns/op      185989 B/op       2181 allocs/op
BenchmarkContainerStats-8                       3000        375755 ns/op      152921 B/op       1942 allocs/op
BenchmarkContainerWithImageNameRender-8         3000        481497 ns/op      199505 B/op       2327 allocs/op
BenchmarkContainerWithImageNameStats-8          3000        394297 ns/op      152895 B/op       1942 allocs/op
BenchmarkContainerImageRender-8                 2000        704382 ns/op      255313 B/op       2701 allocs/op
BenchmarkContainerImageStats-8              100000000           20.6 ns/op         0 B/op          0 allocs/op
BenchmarkContainerHostnameRender-8              3000        489741 ns/op      193500 B/op       2275 allocs/op
BenchmarkContainerHostnameStats-8           100000000           21.5 ns/op         0 B/op          0 allocs/op
BenchmarkHostRender-8                           2000        776683 ns/op      330908 B/op       3485 allocs/op
BenchmarkHostStats-8                        10000000           135 ns/op           0 B/op          0 allocs/op
BenchmarkPodRender-8                            2000        565940 ns/op      235692 B/op       2585 allocs/op
BenchmarkPodStats-8                         100000000           20.3 ns/op         0 B/op          0 allocs/op
BenchmarkPodServiceRender-8                     2000        687174 ns/op      291711 B/op       2967 allocs/op
BenchmarkPodServiceStats-8                  100000000           20.2 ns/op         0 B/op          0 allocs/op
ok      github.com/weaveworks/scope/render  37.441s

@paulbellamy paulbellamy force-pushed the 502-more-immutability branch 2 times, most recently from b7c2855 to 5bc7c31 Compare January 22, 2016 16:03
@tomwilkie
Copy link
Contributor Author

Removing Metadata seems to have made a bit of a difference:

Toms-MacBook-Pro:render twilkie$ go test -bench . -- -bench-report-file report.json 
PASS
BenchmarkEndpointRender-8                      20000         93756 ns/op       36560 B/op        537 allocs/op
BenchmarkEndpointStats-8                    100000000           20.0 ns/op         0 B/op          0 allocs/op
BenchmarkProcessRender-8                       10000        199651 ns/op       81129 B/op       1048 allocs/op
BenchmarkProcessStats-8                     20000000            66.6 ns/op         0 B/op          0 allocs/op
BenchmarkProcessWithContainerNameRender-8      10000        252394 ns/op       93416 B/op       1197 allocs/op
BenchmarkProcessWithContainerNameStats-8    20000000            82.0 ns/op         0 B/op          0 allocs/op
BenchmarkProcessNameRender-8                    5000        280984 ns/op      107636 B/op       1299 allocs/op
BenchmarkProcessNameStats-8                 100000000           20.2 ns/op         0 B/op          0 allocs/op
BenchmarkContainerRender-8                      2000        539458 ns/op      183885 B/op       2268 allocs/op
BenchmarkContainerStats-8                       5000        380214 ns/op      154729 B/op       2027 allocs/op
BenchmarkContainerWithImageNameRender-8         3000        467436 ns/op      191281 B/op       2388 allocs/op
BenchmarkContainerWithImageNameStats-8          3000        379499 ns/op      154744 B/op       2027 allocs/op
BenchmarkContainerImageRender-8                 2000        533797 ns/op      232635 B/op       2728 allocs/op
BenchmarkContainerImageStats-8              100000000           19.4 ns/op         0 B/op          0 allocs/op
BenchmarkContainerHostnameRender-8              3000        449177 ns/op      191396 B/op       2362 allocs/op
BenchmarkContainerHostnameStats-8           100000000           19.1 ns/op         0 B/op          0 allocs/op
BenchmarkHostRender-8                           2000        698756 ns/op      296103 B/op       3438 allocs/op
BenchmarkHostStats-8                        10000000           127 ns/op           0 B/op          0 allocs/op
BenchmarkPodRender-8                            2000        525026 ns/op      224886 B/op       2661 allocs/op
BenchmarkPodStats-8                         100000000           19.8 ns/op         0 B/op          0 allocs/op
BenchmarkPodServiceRender-8                     2000        669774 ns/op      265491 B/op       3021 allocs/op
BenchmarkPodServiceStats-8                  100000000           19.7 ns/op         0 B/op          0 allocs/op
ok      github.com/weaveworks/scope/render  40.533s

In particular, HostRender (our most expensive) has gone form 776683 -> 698756, a 10% win.

@tomwilkie
Copy link
Contributor Author

On master HostRendered is about 884358, so this is about 20% performance improvement - ie not enough.

@tomwilkie tomwilkie changed the title [WIP] Use ps.Map for Counters and Sets. Use ps.Map for Counters and Sets, remove Metadata in favour of Latest. Jan 22, 2016
Also
- Add more complicated report.json for benchmark
- Break up report/topology.go
- Implement our own DeepEqual for ps.Map
@tomwilkie
Copy link
Contributor Author

Another improvement (about 30% now)

Toms-MacBook-Pro:render twilkie$ go test -bench . -- -bench-report-file report.json 
PASS
BenchmarkEndpointRender-8                      20000         89061 ns/op       26108 B/op        455 allocs/op
BenchmarkEndpointStats-8                    50000000            23.1 ns/op         0 B/op          0 allocs/op
BenchmarkProcessRender-8                       10000        178029 ns/op       65252 B/op        905 allocs/op
BenchmarkProcessStats-8                     20000000            69.1 ns/op         0 B/op          0 allocs/op
BenchmarkProcessWithContainerNameRender-8      10000        220903 ns/op       77279 B/op       1047 allocs/op
BenchmarkProcessWithContainerNameStats-8    20000000            79.3 ns/op         0 B/op          0 allocs/op
BenchmarkProcessNameRender-8                   10000        234506 ns/op       88773 B/op       1132 allocs/op
BenchmarkProcessNameStats-8                 100000000           19.6 ns/op         0 B/op          0 allocs/op
BenchmarkContainerRender-8                      3000        378241 ns/op      148396 B/op       1953 allocs/op
BenchmarkContainerStats-8                       5000        322733 ns/op      120321 B/op       1728 allocs/op
BenchmarkContainerWithImageNameRender-8         3000        408063 ns/op      155543 B/op       2067 allocs/op
BenchmarkContainerWithImageNameStats-8          5000        321084 ns/op      120331 B/op       1728 allocs/op
BenchmarkContainerImageRender-8                 3000        479331 ns/op      193134 B/op       2369 allocs/op
BenchmarkContainerImageStats-8              100000000           19.1 ns/op         0 B/op          0 allocs/op
BenchmarkContainerHostnameRender-8              3000        403683 ns/op      155901 B/op       2046 allocs/op
BenchmarkContainerHostnameStats-8           100000000           19.3 ns/op         0 B/op          0 allocs/op
BenchmarkHostRender-8                           2000        613970 ns/op      250425 B/op       3013 allocs/op
BenchmarkHostStats-8                        10000000           127 ns/op           0 B/op          0 allocs/op
BenchmarkPodRender-8                            3000        463328 ns/op      186217 B/op       2310 allocs/op
BenchmarkPodStats-8                         100000000           19.1 ns/op         0 B/op          0 allocs/op
BenchmarkPodServiceRender-8                     2000        549846 ns/op      223603 B/op       2639 allocs/op
BenchmarkPodServiceStats-8                  100000000           19.1 ns/op         0 B/op          0 allocs/op
ok      github.com/weaveworks/scope/render  38.055s

@tomwilkie tomwilkie assigned paulbellamy and unassigned tomwilkie Jan 24, 2016
@tomwilkie tomwilkie force-pushed the 502-more-immutability branch from 537e318 to f2df789 Compare January 24, 2016 21:55
@paulbellamy
Copy link
Contributor

This panics running the benchmarks against report.json, due to a edgeMetadata.Merge(nil)

Because they are commutative and immutable, we can do this!
@paulbellamy paulbellamy assigned tomwilkie and unassigned paulbellamy Jan 25, 2016
@paulbellamy
Copy link
Contributor

Basically just some more comments on tests, then LGTM.

Added a minor optimisation that gains another ~10%.

if !reflect.DeepEqual(want, have) {
t.Errorf(test.Diff(want, have))
}
}

This comment was marked as abuse.

This comment was marked as abuse.

tomwilkie added a commit that referenced this pull request Jan 25, 2016
Use ps.Map for Counters and Sets, remove Metadata in favour of Latest.
@tomwilkie tomwilkie merged commit fd8696f into master Jan 25, 2016
@tomwilkie tomwilkie deleted the 502-more-immutability branch January 25, 2016 21:24
rade added a commit that referenced this pull request Dec 17, 2017
It is unused and none of the adjacency mapping code in the renderer
takes any notice of it. Removing this shrinks the report size.

Edges were introduced in #838. At the time we had an experimental
packet sniffer under experimental/sniff/sniffer.go. That got removed
in #1646.

We can resurrect this if we ever decide to add meta data to edges.
@rade rade mentioned this pull request Dec 17, 2017
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