Performance tuning for plugin/file#7658
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7658 +/- ##
==========================================
+ Coverage 55.70% 63.26% +7.56%
==========================================
Files 224 278 +54
Lines 10016 15129 +5113
==========================================
+ Hits 5579 9571 +3992
- Misses 3978 4871 +893
- Partials 459 687 +228 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PrevLabel always begins its iteration from the tail of domain name. less(..) loop can improve its performance by calling PrevLabel starting from the last processed label. As the benchmark results showed, the performance is improved by about 15%. $ go test -bench=Less -run=^$ goos: linux goarch: amd64 pkg: github.com/coredns/coredns/plugin/file/tree cpu: Intel(R) Xeon(R) Platinum 8336C CPU @ 2.30GHz BenchmarkLess/base-16 99003 12105 ns/op BenchmarkLess/optimized-16 114522 10590 ns/op PASS ok github.com/coredns/coredns/plugin/file/tree 2.416s Signed-off-by: yuwenchao <ywc689@163.com>
Similar to tree.less(..), performance of function nameFromRight can boost by utilizing dns.PrevLabel more efficiently. As benchmark tests shown, performance of this function with the optimization is gained by double or triple. * Benchmark test result for the original implementation: BenchmarkNameFromRight/i0_origin-16 430719652 2.794 ns/op BenchmarkNameFromRight/eq_origin_i1_shot-16 30933135 37.52 ns/op BenchmarkNameFromRight/two_labels_i1-16 29375857 40.71 ns/op BenchmarkNameFromRight/two_labels_i2-16 18556830 63.97 ns/op BenchmarkNameFromRight/two_labels_i3_shot-16 14678812 84.73 ns/op BenchmarkNameFromRight/ten_labels_i5-16 8522132 133.0 ns/op BenchmarkNameFromRight/ten_labels_i11_shot-16 3154410 378.2 ns/op BenchmarkNameFromRight/not_subdomain_shot-16 35297224 33.59 ns/op BenchmarkNameFromRightRandomized-16 10638702 113.4 ns/op 0 B/op 0 allocs/op * Benchmark test result with this optimization: BenchmarkNameFromRight/i0_origin-16 425864671 2.808 ns/op BenchmarkNameFromRight/eq_origin_i1_shot-16 60903428 19.53 ns/op BenchmarkNameFromRight/two_labels_i1-16 50209297 24.21 ns/op BenchmarkNameFromRight/two_labels_i2-16 42483711 27.88 ns/op BenchmarkNameFromRight/two_labels_i3_shot-16 40898925 29.24 ns/op BenchmarkNameFromRight/ten_labels_i5-16 27916532 44.54 ns/op BenchmarkNameFromRight/ten_labels_i11_shot-16 17540040 67.59 ns/op BenchmarkNameFromRight/not_subdomain_shot-16 67180514 17.46 ns/op BenchmarkNameFromRightRandomized-16 32692081 38.21 ns/op 0 B/op 0 allocs/op Signed-off-by: yuwenchao <yuwenchao@bytedance.com>
c7d4481 to
dfeffae
Compare
Member
|
brillant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Why is this pull request needed and what does it do?
The functions
tree.lessandnameFromRightare in the critical DNS data processing path of file plugin. Optimization of the two functions can help reduce server load and boost throughput of CoreDNS server significantly.Note that both functions call
dns.PrevLabelin a loop, and always start each call from the tail of the domain name. This patch improves the two functions performance by callingdns.PrevLabelstarting from the last processed label, which dramatically reduces the cost ofdns.PrevLabel.As the benchmark results showed, the performance of
tree.lessis improved by about 15%,and performance of
nameFromRightwith the optimization is gained by double or triple.2. Which issues (if any) are related?
nothing
3. Which documentation changes (if any) need to be made?
nothing
4. Does this introduce a backward incompatible change or deprecation?
no