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

Avoid object creation when scanning DNS names #2921

Merged
merged 1 commit into from
Nov 6, 2017
Merged

Conversation

bboreham
Copy link
Collaborator

@bboreham bboreham commented Nov 4, 2017

Since we do this a lot, scanning the lists in-place saves work.

Also we don't need to sort them since StringSet is implemented as a sorted set of strings

It's actually benchmarking a little slower, when the best of five runs is taken, but with reduced memory allocation. The timing of this benchmark is highly variable on my VM; the new benchmarks in #2920 are more reliably faster with this change.

Before

BenchmarkTopologyList-2   	       1	1479321809 ns/op	351308800 B/op	 2913864 allocs/op

After

BenchmarkTopologyList-2   	       1	1511797615 ns/op	347651256 B/op	 2753226 allocs/op

Since we do this a lot, scanning the lists in-place saves time.
Also we don't need to sort them since StringSet is implemented as a
sorted set of strings
// DNSFirstMatch returns the first DNS name where match() returns
// true, from a prioritized list of snooped and reverse-resolved DNS
// names associated with node n.
func DNSFirstMatch(n report.Node, match func(name string) bool) (string, bool) {

This comment was marked as abuse.

This comment was marked as abuse.

@bboreham bboreham merged commit c52b5f6 into master Nov 6, 2017
@dlespiau dlespiau deleted the optimise-dnsnames branch November 21, 2017 08:49
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