Go Benchmarks And Escape Analysis

86 views
Skip to first unread message

Patrick

unread,
Aug 13, 2020, 9:18:52 PM8/13/20
to golang-nuts
I'm new to go, and have being looking at escape analysis by benchmarking some code that I created.

What I see is the escape analysis shows that certain variables escape to the heap.

parameter path leaks to {heap} with derefs=2


But the result of the benchmark test shows 0 allocations.

1000000000          0.00429 ns/op        0 B/op        0 allocs/op


Does the 0 allocs/op mean that the compiler optimised the code and the parameter path did not leak to the heap?  Also, since there are 0 allocs/ops does this mean I don't need to be concerned about leaking to the heap?

Allocation recording is turned on in the test

Thanks




jake...@gmail.com

unread,
Aug 13, 2020, 10:17:50 PM8/13/20
to golang-nuts
0.00429 ns/op seems suspiciously low. I suspect that there could be a problem with your benchmark. Could you post the code.
( On this mailing list please just send code as plain text or as a link to the Go playground.)
Reply all
Reply to author
Forward
0 new messages