I recently added a new API (AllocSoonUse) to the
https://gitee.com/qiulaidongfeng/arena I wrote (copy in
https://github.com/qiulaidongfeng/arena)
This API allocdata to adjacent []byte, and the length can be set.
I use this benchmark code : https://go.dev/play/p/nAGveraT5_h
benchmark Brief description, use AllocSoonUse and new to allocate some data
of different sizes that does not contain Pointers and use it soon after
allocation.
I use `go test -bench=. -count=10 -benchtime=2s > new.txt && benchstat
new.txt` got this result
│ new.txt │
│ sec/op │
NoStd-16 207.4µ ± 4%
Std-16 245.0µ ± 1%
geomean 225.4µ
It appears that using AllocSoonUse takes 15.34% less time than using new in
some scenarios.
I initially speculated that the reason for the performance improvement was
the change in cache hit rate.
But using this benchmark https://go.dev/play/p/SCNMV6I9GWC and `go test
-bench=. -count=10 -benchtime=2s > new.txt && benchstat new.txt` got this
result
│ new.txt │
│ sec/op │
NoStd-16 206.6µ ± 3%
Std-16 236.0µ ± 2%
geomean 220.9µ
It appears that there is still a 12.45% performance gap after commenting
out the access code to allocated memory to reduce the access to memory.
I want to get the performance gap so the reason.
The possibility has been ruled out, AllocSoonUse allows free memory in a
way that allows for immediate reuse , but I did not enable this opt-in.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/13dfb086-3fc4-4361-80eb-fc6466cfd72fn%40googlegroups.com.