pjvds / tidy

Go lang structured logging made fast and simple
7 stars 0 forks source link

lower required allocation in text format #1

Closed pjvds closed 9 years ago

pjvds commented 9 years ago

I like the current text formatter. It is very fast compared to what I have seen before and requires minimal allocations. It is especially that last part I care about most, since less allocations means less GC pressure.

The benchmarks in text_test.go show that we still require 5 allocations for small entries and 28 for large entries. We should invest time to bring this number down even further.

$ go test -bench 'BenchmarkSmallTextColoredTextFormatter' -test.benchmem  -run '$^'
PASS
BenchmarkSmallTextColoredTextFormatter-6     1000000          1735 ns/op      71.45 MB/s          15 B/op          5 allocs/op
ok      github.com/pjvds/tidy   1.762s
pjvds commented 9 years ago

Commit https://github.com/pjvds/tidy/commit/8f2ca5aceaf036fc8ffd598d7d80fc9c66f00fc9 lowers the allocation from 5 to 4, this means all overhead is gone and the allocation count is now equal to the field count.