Closed ksw2000 closed 2 months ago
Replace the field bufKV with two []byte fields and remove the filed buf.
bufKV
[]byte
buf
type Cookie struct { - buf []byte // -24 bytes - bufKV argsKV // -56 bytes + bufK []byte // +24 bytes + bufV []byte // +24 bytes }
In the benchmark test, the execution time increased slightly by about 1%.
goos: linux goarch: amd64 pkg: github.com/valyala/fasthttp cpu: AMD EPYC 7763 64-Core Processor │ old.txt │ new2.txt │ │ sec/op │ sec/op vs base │ CookieParseMin-4 26.55n ± 1% 26.53n ± 1% ~ (p=0.733 n=20) CookieParseNoExpires-4 89.89n ± 3% 91.65n ± 3% +1.96% (p=0.033 n=20) CookieParseFull-4 531.0n ± 3% 540.8n ± 1% ~ (p=0.057 n=20) geomean 108.2n 109.6n +1.24% │ old.txt │ new2.txt │ │ B/op │ B/op vs base │ CookieParseMin-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ CookieParseNoExpires-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ CookieParseFull-4 163.0 ± 0% 163.0 ± 0% ~ (p=1.000 n=20) ¹ geomean ² +0.00% ² ¹ all samples are equal ² summaries must be >0 to compute geomean │ old.txt │ new2.txt │ │ allocs/op │ allocs/op vs base │ CookieParseMin-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ CookieParseNoExpires-4 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=20) ¹ CookieParseFull-4 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=20) ¹ geomean ² +0.00% ² ¹ all samples are equal ² summaries must be >0 to compute geomean
Thanks!
Replace the field
bufKV
with two[]byte
fields and remove the filedbuf
.In the benchmark test, the execution time increased slightly by about 1%.