Gerrit Bot has uploaded this change for review.
crypto/hmac: allocate hmac struct on the stack
goos: linux
goarch: amd64
pkg: crypto/hmac
cpu: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
│ before │ after │
│ sec/op │ sec/op vs base │
HMACSHA256_1K-4 3.302µ ± 1% 3.296µ ± 1% ~ (p=0.740 n=25)
HMACSHA256_32-4 611.9n ± 3% 613.5n ± 2% ~ (p=0.450 n=25)
NewWriteSum-4 3.432µ ± 27% 2.513µ ± 18% -26.78% (p=0.011 n=25)
geomean 1.907µ 1.719µ -9.84%
│ before │ after │
│ B/s │ B/s vs base │
HMACSHA256_1K-4 295.8Mi ± 1% 296.3Mi ± 1% ~ (p=0.740 n=25)
HMACSHA256_32-4 49.87Mi ± 3% 49.74Mi ± 2% ~ (p=0.461 n=25)
NewWriteSum-4 8.888Mi ± 38% 12.140Mi ± 15% +36.59% (p=0.011 n=25)
geomean 50.80Mi 56.35Mi +10.93%
│ before │ after │
│ B/op │ B/op vs base │
HMACSHA256_1K-4 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=25) ¹
HMACSHA256_32-4 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=25) ¹
NewWriteSum-4 544.0 ± 0% 448.0 ± 0% -17.65% (p=0.000 n=25)
geomean 82.28 77.12 -6.27%
¹ all samples are equal
│ before │ after │
│ allocs/op │ allocs/op vs base │
HMACSHA256_1K-4 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=25) ¹
HMACSHA256_32-4 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=25) ¹
NewWriteSum-4 7.000 ± 0% 6.000 ± 0% -14.29% (p=0.000 n=25)
geomean 1.913 1.817 -5.01%
¹ all samples are equal
Change-Id: Ib9c812d52a7e56e9147fe8761c05dbffdb565d77
GitHub-Last-Rev: f9250ae1a1b25469939b6951a6981c9058c59304
GitHub-Pull-Request: golang/go#62088
---
M src/crypto/hmac/hmac.go
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/crypto/hmac/hmac.go b/src/crypto/hmac/hmac.go
index 35b9d5a..9b0f5a3 100644
--- a/src/crypto/hmac/hmac.go
+++ b/src/crypto/hmac/hmac.go
@@ -134,7 +134,13 @@
}
// BoringCrypto did not recognize h, so fall through to standard Go code.
}
+
hm := new(hmac)
+ hm.init(h, key)
+ return hm
+}
+
+func (hm *hmac) init(h func() hash.Hash, key []byte) {
hm.outer = h()
hm.inner = h()
unique := true
@@ -167,8 +173,6 @@
hm.opad[i] ^= 0x5c
}
hm.inner.Write(hm.ipad)
-
- return hm
}
// Equal compares two MACs for equality without leaking timing information.
To view, visit change 520269. To unsubscribe, or for help writing mail filters, visit settings.
1 comment:
Patchset:
Hello Mateusz Poliwczak <mpoliw...@gmail.com>, I've spotted some possible problems.
These findings are based on simple heuristics. If a finding appears wrong, briefly reply here saying so. Otherwise, please address any problems and update the GitHub PR. When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://github.com/golang/go/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above.
Possible problems detected:
1. You usually need to reference a bug number for all but trivial or cosmetic fixes. For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message. Should you have a bug reference?
To edit the commit message, see instructions [here](https://github.com/golang/go/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message). For guidelines on commit messages for the Go project, see [here](https://go.dev/doc/contribute#commit_messages).
(In general for Gerrit code reviews, the CL author is expected to close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)
To view, visit change 520269. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Filippo Valsorda, Roland Shoemaker.
Patch set 1:Run-TryBot +1
Attention is currently required from: Filippo Valsorda, Roland Shoemaker.
1 comment:
Patchset:
Hello Mateusz Poliwczak <mpoliw...@gmail.com>, I've spotted some possible problems. […]
Done
To view, visit change 520269. To unsubscribe, or for help writing mail filters, visit settings.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |