miekg/dns — pull request #77 by millerkil (2014-01-25 21:45:49+00:00)
Title: Overallocate label index buffer

I noticed that you can improve the performance on some of the benchmarks by overallocating `Split` for the average case. Almost 2x faster in some cases, and cuts memory allocations in half for a few.

```
go test -bench . -cpu 1 -benchmem -benchtime 15s github.com/miekg/dns
---
PASS
BenchmarkMsgLen	10000000	2523 ns/op	616 B/op	14 allocs/op
BenchmarkMsgLenPack	5000000	8347 ns/op	1932 B/op	56 allocs/op
BenchmarkSplitLabels	100000000	332 ns/op	56 B/op	3 allocs/op
BenchmarkLenLabels	500000000	58.7 ns/op	0 B/op	0 allocs/op
BenchmarkCompareLabels	50000000	881 ns/op	160 B/op	8 allocs/op
BenchmarkIsSubDomain	10000000	2468 ns/op	384 B/op	22 allocs/op
BenchmarkServing	1000000	28474 ns/op	939 B/op	26 allocs/op
BenchmarkServingCompress 1000000	27982 ns/op	939 B/op	26 allocs/op
ok	github.com/miekg/dns	284.668s
```
```
go test -bench . -cpu 1 -benchmem -benchtime 15s github.com/millerkil/dns
---
PASS
BenchmarkMsgLen	10000000	2433 ns/op	592 B/op	12 allocs/op *
BenchmarkMsgLenPack	5000000	8433 ns/op	1932 B/op	56 allocs/op
BenchmarkSplitLabels	100000000	182 ns/op	32 B/op	1 allocs/op *
BenchmarkLenLabels	500000000	60.6 ns/op	0 B/op	0 allocs/op
BenchmarkCompareLabels	50000000	598 ns/op	112 B/op	4 allocs/op *
BenchmarkIsSubDomain	20000000	1844 ns/op	304 B/op	12 allocs/op *
BenchmarkServing	1000000	28659 ns/op	934 B/op	26 allocs/op
BenchmarkServingCompress 1000000	28552 ns/op	936 B/op	26 allocs/op
ok	github.com/millerkil/dns	267.728s
```