5 ms·
> You can also have seemingly obvious flows for a variable that the analyzer can't reason about and it escapes when you didn't think it would. You really just h
by pcwalton 8y ago
> You can also have seemingly obvious flows for a variable that the analyzer can't reason about and it escapes when you didn't think it would. You really just have to run the tool to see if you want to be sure.
And this is why "get programmers to manually optimize their code to please escape analysis" is not a reasonable memory management strategy.
- dullgiulio 8y agoNobody is suggesting that. Go has very good profiling support, and that's how performance optimization starts. If profiling finds that there are too many allocations on a hot path, you might want to see why they escape to heap. But that's a last resort strategy.
- staticassertion 8y agoThis sounds very much like "write code to please escape analysis", but with a profiling step in front of it.
- kristianp 8y agoNo, there's a difference. Profiling will often show you where you're doing allocations or calling code that does allocations in the most often used code. Profiling shows where to reduce those allocations to get the biggest improvements. When making the changes, you don't try to reduce escapes, you reduce allocations. Have a look at [1] and go down to where it says " To find out why the garbage collector is running so much". [1] https://blog.golang.org/profiling-go-programs https://blog.golang.org/profiling-go-programs