]> Cypherpunks repositories - gostls13.git/commit
log/slog: simplify and optimize RFC3339 handling
authorJoe Tsai <joetsai@digital-static.net>
Thu, 23 Mar 2023 08:01:46 +0000 (01:01 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 17 Aug 2023 16:48:35 +0000 (16:48 +0000)
commitd63652b7c69d106a6bab787fbdf7726d39e42406
tree3d607ab35288a1e90eb7808df9516cc5b9e2f69e
parentaaa384cf3a510a1f1945010e2c0e2ba8d0282f91
log/slog: simplify and optimize RFC3339 handling

In CL 421877 and CL 444278, time.Time.AppendFormat has been
specially optimized for the time.RFC3339Nano representation.
Relying on that optimization and modify the output to obtain the
fixed-width millisecond resolution that slog uses.

This both removes a lot of code and also improves performance:

name       old time/op  new time/op  delta
WriteTime  93.0ns ± 1%  80.8ns ± 0%  -13.17%  (p=0.000 n=8+9)

Change-Id: I61e8f4476c111443e3e2098a45b2c21a76137345
Reviewed-on: https://go-review.googlesource.com/c/go/+/478757
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
src/log/slog/handler.go
src/log/slog/handler_test.go
src/log/slog/internal/buffer/buffer.go
src/log/slog/internal/buffer/buffer_test.go