dns/dnsmessage: don't include bytes after name.Length in the compression map

This improves the performance of name compression and makes
the name.Data[name.Length:] not included in the compression
map, it is unnecessary and might cause issues (i.e. reusing
the Name struct, without using the NewName function).

goos: linux
goarch: amd64
pkg: golang.org/x/net/dns/dnsmessage
cpu: Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
             │    before     │                after                 │
             │    sec/op     │    sec/op     vs base                │
Pack-4         15.672µ ± 13%   5.470µ ± 14%  -65.10% (p=0.000 n=10)
AppendPack-4   15.144µ ± 12%   5.330µ ± 10%  -64.80% (p=0.000 n=10)
geomean         15.41µ         5.400µ        -64.95%

             │    before    │                after                 │
             │     B/op     │     B/op      vs base                │
Pack-4         6.051Ki ± 0%   1.285Ki ± 0%  -78.76% (p=0.000 n=10)
AppendPack-4    5684.0 ± 0%     804.0 ± 0%  -85.86% (p=0.000 n=10)
geomean        5.795Ki        1.005Ki       -82.67%

             │   before   │               after                │
             │ allocs/op  │ allocs/op   vs base                │
Pack-4         21.00 ± 0%   11.00 ± 0%  -47.62% (p=0.000 n=10)
AppendPack-4   20.00 ± 0%   10.00 ± 0%  -50.00% (p=0.000 n=10)
geomean        20.49        10.49       -48.82%

Change-Id: Idf40d5d4790d37eb7253214f089eff859a937c60
GitHub-Last-Rev: a3182830e27086a0e12e116c7f7916468eb1edf2
GitHub-Pull-Request: golang/net#190
Reviewed-on: https://go-review.googlesource.com/c/net/+/522817
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2 files changed
tree: ed62f5f36e50102c5b2d2791537daf3381893097
  1. bpf/
  2. context/
  3. dict/
  4. dns/
  5. html/
  6. http/
  7. http2/
  8. icmp/
  9. idna/
  10. internal/
  11. ipv4/
  12. ipv6/
  13. lif/
  14. nettest/
  15. netutil/
  16. proxy/
  17. publicsuffix/
  18. route/
  19. trace/
  20. webdav/
  21. websocket/
  22. xsrftoken/
  23. .gitattributes
  24. .gitignore
  25. codereview.cfg
  26. CONTRIBUTING.md
  27. go.mod
  28. go.sum
  29. LICENSE
  30. PATENTS
  31. README.md
README.md

Go Networking

Go Reference

This repository holds supplementary Go networking libraries.

Download/Install

The easiest way to install is to run go get -u golang.org/x/net. You can also manually git clone the repository to $GOPATH/src/golang.org/x/net.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html. The main issue tracker for the net repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/net:” in the subject line, so it is easy to find.