commit | 3fe0347cd05f48bcf98befe317a02c85270dc22b | [log] [tgz] |
---|---|---|
author | Jonathan Amsterdam <jba@google.com> | Sun Sep 11 07:52:32 2022 -0400 |
committer | Jonathan Amsterdam <jba@google.com> | Tue Oct 04 19:15:58 2022 +0000 |
tree | 614c421aa02580807e936e7b8c9ef959a8d13f7e | |
parent | 540bb7301a08c785a908b6b77c69f307eb85a3f5 [diff] |
slog: benchmarks Add benchmarks to measure the performance of LogAttrs and compare it with Zap. The run_benchmarks.sh script will run the benchmarks 5 times both with and without the code to fetch the pc, and write the results to files. That code is currently slow (200ns) so we optimistically disable it. Put the equivalent Zap benchmarks in a subdirectory, zapbenchmarks, which is in a separate module to avoid having golang.org/x/exp depend on go.uber.org/zap. The Zap benchmarks are named identically to the slog ones so benchstat can compare them. The zapbenchmarks/run_benchmarks.sh script runs the benchmarks, puts the output in a file, and rename the "pkg:" header in the file to match the slog benchmarks package so that benchstat will compare them. We test only the Logger.LogAttrs method. That is the intended fast path of the package. It might be interesting to see how much slower the methods that take ...any are, but we don't do that in this CL. We use io.Discard for all output, to keep extraneous effects to a minimum. But again, it would be interesting to compare that with writing to a file, for instance. Our original benchmarks defined a simple binary format and had handlers that produced it. But the fact is, people don't seem to do that, even people who want high performance. So again, interesting, but not on the critical path. These benchmarks show that slog is competitive with Zap even with pc-fetching enabled, and significantly faster without it. Change-Id: I88cf12f6e3b2a0eab894664cb106f3b4ec3996c4 Reviewed-on: https://go-review.googlesource.com/c/exp/+/436759 Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This subrepository holds experimental and deprecated (in the old
directory) packages.
The idea for this subrepository originated as the pkg/exp
directory of the main repository, but its presence there made it unavailable to users of the binary downloads of the Go installation. The subrepository has therefore been created to make it possible to go get
these packages.
Warning: Packages here are experimental and unreliable. Some may one day be promoted to the main repository or other subrepository, or they may be modified arbitrarily or even disappear altogether.
In short, code in this subrepository is not subject to the Go 1 compatibility promise. (No subrepo is, but the promise is even more likely to be violated by go.exp than the others.)
Caveat emptor.