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

encoding/gob: replace runtime values with constants in init() #54184

Open
Thorleon opened this issue Aug 1, 2022 · 1 comment
Open

encoding/gob: replace runtime values with constants in init() #54184

Thorleon opened this issue Aug 1, 2022 · 1 comment
Labels
NeedsInvestigation Performance
Milestone

Comments

@Thorleon
Copy link
Contributor

@Thorleon Thorleon commented Aug 1, 2022

Current init() implementation in encoding/gob/decode.go checks int/uint/uintptr bit size with reflection in runtime. We could replace it with values available on compile stage. This should reduce time and allocations on binary start.

Results from GODEBUG=inittrace=1:
before:
init encoding/gob @4.4 ms, 0.21 ms clock, 43496 bytes, 652 allocs
after:
init encoding/gob @4.4 ms, 0.15 ms clock, 41672 bytes, 643 allocs

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 1, 2022

Change https://go.dev/cl/420455 mentions this issue: inet/rpc: replace runtime values with constants in init()

@Thorleon Thorleon changed the title net/rpc: replace runtime values with constants in init() encoding/gob: replace runtime values with constants in init() Aug 1, 2022
@seankhliao seankhliao added Performance NeedsInvestigation labels Aug 1, 2022
@dmitshur dmitshur added this to the Go1.20 milestone Aug 4, 2022
gopherbot pushed a commit that referenced this issue Aug 8, 2022
Current init() implementation in `encoding/gob/decode.go` checks int/uint/uintptr bit size with reflection in runtime. We could replace it with values available on compile stage. This should reduce time and allocations on binary start.
Results from GODEBUG=inittrace=1:
before:
init encoding/gob @4.4 ms, 0.21 ms clock, 43496 bytes, 652 allocs
after:
init encoding/gob @4.4 ms, 0.15 ms clock, 41672 bytes, 643 allocs

Updates #54184

Change-Id: I46dda2682fb92519da199415e29401d61edce697
Reviewed-on: https://go-review.googlesource.com/c/go/+/420455
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Performance
Projects
None yet
Development

No branches or pull requests

4 participants