commit | 3d6432c72ee9bfb55444a618b3b161bb1c0c6c7a | [log] [tgz] |
---|---|---|
author | Jonathan Amsterdam <jba@google.com> | Wed Jun 02 11:35:39 2021 -0400 |
committer | Jonathan Amsterdam <jba@google.com> | Fri Jun 04 13:12:34 2021 +0000 |
tree | 900d9049d3189e636432e94050bcc54d09bec095 | |
parent | 50c1ec4d2c83944e0f6db9611f844a4ab66591e6 [diff] |
event: add a namespace to every event Add a namespace to every event. It can be set with Builder.Namespace. By default we use the import path of the package that builds the event. The Exporter memoizes the map from pcs to namespaces. This saves both the time to extract the frame and parse the fully-qualified function name, and the allocation that is inevitable because runtime.CallersFrames takes a slice. This is significantly slower in the Noop cases (see below), so the user must enable it with an option. name old time/op new time/op delta LogEventNoExporter-8 616ns ± 2% 612ns ± 2% -0.67% (p=0.019 n=17+20) LogEventNoop-8 1.83µs ± 3% 13.51µs ± 4% +638.00% (p=0.000 n=18+19) LogEventDiscard-8 10.7µs ± 2% 23.7µs ± 2% +121.35% (p=0.000 n=20+17) LogEventfDiscard-8 16.6µs ± 2% 28.8µs ± 1% +73.47% (p=0.000 n=19+18) TraceEventNoop-8 41.5µs ± 3% 78.6µs ± 1% +89.63% (p=0.000 n=19+18) MetricEventNoop-8 16.4µs ± 2% 40.9µs ± 2% +149.97% (p=0.000 n=17+20) Logrus-8 55.4µs ± 2% 54.3µs ± 3% -1.97% (p=0.000 n=19+17) Logrusf-8 46.4µs ± 3% 45.1µs ± 1% -2.82% (p=0.000 n=20+18) Baseline-8 280ns ± 2% 278ns ± 2% -0.72% (p=0.025 n=19+20) LogStdlib-8 8.54µs ± 1% 8.49µs ± 2% -0.60% (p=0.043 n=18+18) LogPrintf-8 13.1µs ± 2% 13.0µs ± 2% -0.72% (p=0.010 n=18+18) LogZap-8 20.4µs ± 3% 20.1µs ± 1% -1.43% (p=0.000 n=20+18) LogZapf-8 21.7µs ± 3% 21.6µs ± 1% ~ (p=0.797 n=20+19) LogZerolog-8 7.47µs ± 2% 7.40µs ± 1% -0.87% (p=0.006 n=18+19) LogZerologf-8 12.5µs ± 3% 12.6µs ± 2% ~ (p=0.171 n=18+19) Further testing showed that the time is all due to runtime.Callers; caching the pcs is very effective at eliminating any overhead from extracting frame information. (Note that TraceEventNoop and MetricEventNoop are misnamed; they install a printer that writes to io.Discard.) Change-Id: I37bb5e6194be6dcaaa471086dcd3d4850bfd531c Reviewed-on: https://go-review.googlesource.com/c/exp/+/324291 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com>
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.