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

labels: eliminate most allocations and improve perf by 15-65% #1007

Merged
merged 2 commits into from Sep 21, 2019

Conversation

charlievieth
Copy link
Contributor

This commit changes the labels functions to step through labels section-by-section instead of splitting them and thus allocating a slice.

Where possible allocations are reduced to 0.

benchmark                         old ns/op     new ns/op     delta
BenchmarkSplitLabels-12           41.4          34.9          -15.70%
BenchmarkLenLabels-12             25.8          15.5          -39.92%
BenchmarkCompareDomainName-12     107           39.3          -63.27%
BenchmarkIsSubDomain-12           348           120           -65.52%

benchmark                         old allocs     new allocs     delta
BenchmarkSplitLabels-12           1              1              +0.00%
BenchmarkLenLabels-12             0              0              +0.00%
BenchmarkCompareDomainName-12     2              0              -100.00%
BenchmarkIsSubDomain-12           6              0              -100.00%

benchmark                         old bytes     new bytes     delta
BenchmarkSplitLabels-12           32            32            +0.00%
BenchmarkLenLabels-12             0             0             +0.00%
BenchmarkCompareDomainName-12     64            0             -100.00%
BenchmarkIsSubDomain-12           192           0             -100.00%

This commit changes the labels functions to step through labels
section-by-section instead of splitting them and thus allocating
a slice.

Where possible allocations are reduced to 0.

```
benchmark                         old ns/op     new ns/op     delta
BenchmarkSplitLabels-12           41.4          34.9          -15.70%
BenchmarkLenLabels-12             25.8          15.5          -39.92%
BenchmarkCompareDomainName-12     107           39.3          -63.27%
BenchmarkIsSubDomain-12           348           120           -65.52%

benchmark                         old allocs     new allocs     delta
BenchmarkSplitLabels-12           1              1              +0.00%
BenchmarkLenLabels-12             0              0              +0.00%
BenchmarkCompareDomainName-12     2              0              -100.00%
BenchmarkIsSubDomain-12           6              0              -100.00%

benchmark                         old bytes     new bytes     delta
BenchmarkSplitLabels-12           32            32            +0.00%
BenchmarkLenLabels-12             0             0             +0.00%
BenchmarkCompareDomainName-12     64            0             -100.00%
BenchmarkIsSubDomain-12           192           0             -100.00%
```
@codecov-io
Copy link

codecov-io commented Sep 21, 2019

Codecov Report

Merging #1007 into master will increase coverage by 0.08%.
The diff coverage is 97.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1007      +/-   ##
==========================================
+ Coverage   54.63%   54.72%   +0.08%     
==========================================
  Files          41       41              
  Lines        9842     9857      +15     
==========================================
+ Hits         5377     5394      +17     
+ Misses       3438     3437       -1     
+ Partials     1027     1026       -1
Impacted Files Coverage Δ
labels.go 96.61% <97.36%> (+3.4%) ⬆️
server.go 67.67% <0%> (-0.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2acbc9e...df95aa5. Read the comment docs.

@miekg miekg merged commit ab6ac40 into miekg:master Sep 21, 2019
miekg added a commit that referenced this pull request Oct 4, 2019
miekg added a commit that referenced this pull request Oct 4, 2019
…#1007)"

This reverts commit ab6ac40.

This break CoreDNS tests and probably a lot of other apps as well.
Reverted
miekg added a commit that referenced this pull request Oct 4, 2019
…#1007)" (#1022)

This reverts commit ab6ac40.

This break CoreDNS tests and probably a lot of other apps as well.
Reverted
aanm pushed a commit to cilium/dns that referenced this pull request Jul 29, 2022
…1007)

* labels: eliminate most allocations and improve perf by 15-65%

This commit changes the labels functions to step through labels
section-by-section instead of splitting them and thus allocating
a slice.

Where possible allocations are reduced to 0.

```
benchmark                         old ns/op     new ns/op     delta
BenchmarkSplitLabels-12           41.4          34.9          -15.70%
BenchmarkLenLabels-12             25.8          15.5          -39.92%
BenchmarkCompareDomainName-12     107           39.3          -63.27%
BenchmarkIsSubDomain-12           348           120           -65.52%

benchmark                         old allocs     new allocs     delta
BenchmarkSplitLabels-12           1              1              +0.00%
BenchmarkLenLabels-12             0              0              +0.00%
BenchmarkCompareDomainName-12     2              0              -100.00%
BenchmarkIsSubDomain-12           6              0              -100.00%

benchmark                         old bytes     new bytes     delta
BenchmarkSplitLabels-12           32            32            +0.00%
BenchmarkLenLabels-12             0             0             +0.00%
BenchmarkCompareDomainName-12     64            0             -100.00%
BenchmarkIsSubDomain-12           192           0             -100.00%
```

* labels: fix CompareDomainName and improve tests
aanm pushed a commit to cilium/dns that referenced this pull request Jul 29, 2022
…miekg#1007)" (miekg#1022)

This reverts commit ab6ac40.

This break CoreDNS tests and probably a lot of other apps as well.
Reverted
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.

None yet

3 participants