Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: Optimize formatting time in header with avoiding buffer copy in ioa #20267

Closed
hnakamur opened this issue May 6, 2017 · 4 comments
Closed

Comments

@hnakamur
Copy link

hnakamur commented May 6, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.1 linux/amd64

The target source code version: e94b9d4

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/hnakamur/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build252988026=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

This issue is not an error report.
I optimized formatting time in log headers a little bit.

name                    old time/op    new time/op    delta
Println-2                  543ns ± 1%     474ns ± 0%  -12.67%  (p=0.000 n=8+9)
PrintlnMicoroseconds-2     580ns ± 1%     511ns ± 0%  -11.89%  (p=0.000 n=10+10)

name                    old alloc/op   new alloc/op   delta
Println-2                  21.0B ± 0%     21.0B ± 0%     ~     (all equal)
PrintlnMicoroseconds-2     21.0B ± 0%     21.0B ± 0%     ~     (all equal)

name                    old allocs/op  new allocs/op  delta
Println-2                   2.00 ± 0%      2.00 ± 0%     ~     (all equal)
PrintlnMicoroseconds-2      2.00 ± 0%      2.00 ± 0%     ~     (all equal)

Could you take a look at the following two commits and tell me what do you think?

Before my optimization, I added BenchmarkPrintlnMicoroseconds to be used alongside with existing BenchmarkPrintln.
https://github.com/hnakamur/go/commit/3442066c11696d05a1927d5467b4c1493cbd9ec7

Then I optimized itoa.
Actually itoa remains the same for backward compatibility.
I added itoaPad which avoids a buffer copy.
https://github.com/hnakamur/go/commit/a95dd6dc3bcd6e4e5264f06859a7dc3b368545ef

What did you expect to see?

What did you see instead?

@bradfitz
Copy link
Contributor

bradfitz commented May 6, 2017

Could you take a look at the following two commits and tell me what do you think?

We can only accept code submitted via Gerrit which we have configured to require that you've submitted a CLA.

See https://golang.org/doc/contribute.html for how to send a change, including an optimization change.

@bradfitz bradfitz added this to the Go1.10 milestone May 6, 2017
@gopherbot
Copy link

CL https://golang.org/cl/42891 mentions this issue.

@hnakamur
Copy link
Author

hnakamur commented May 6, 2017

Thanks for your comment!
I sent the change for review at https://go-review.googlesource.com/c/42891/

@hnakamur
Copy link
Author

I'm closing this issue since now its' got 12% slower this this patch after rebase.
https://go-review.googlesource.com/c/go/+/42891

@golang golang locked and limited conversation to collaborators Oct 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants