Hello,
I'm trying to figure out how to do "frame" based profiling in GO and was redirect to this mailing--list from the `r/golang` sub (topic <https://www.reddit.com/r/golang/comments/hg71ji/how_to_do_frame_based_profiling_in_go/>). Would be amazing if anyone here can help. In short: I have a game server in Go and need to profile CPU costs of individual frames but sadly can't find a way to do that properly. I thought that the `pprof` CPU profile should be the right tool. However, at least the profile visualization tools always aggregate the methods execution costs between `StartCPUProfile` and `StopCPUProfile`. While in some scenarios this is great, we have currently have big spikes in for frame duration and would love to see the difference in times per frame. Ideally in a flame-graph like visualization but grouped by frames. So we'd somehow need to mark the frame start/end and tell the visualization to use that. Ideally, like the profiler in the Unity3D Editor does: [image: Post image] <https://preview.redd.it/jck3mr3hz8751.png?width=800&format=png&auto=webp&s=1e7092f877c76b8416a9c35eb0dd0bcadadc5258> Unity3D Profiling - Per frame method execution times I tried use `Start/StopCPUProfile` at the beginning and end of a frame to create an individual capture per frame. That's not ideal for comparison but should be good enough and simple in concept. Sadly the cost of `StartCPUProfile` is so high, we can't call that per frame. Looking at the code, the the 100 millisecond sleep in `profileWriter` explains that it. So what we'd need is a way to mark the frame start/end somehow for visual grouping. Is that possible with `pprof`? [image: Post image] <https://preview.redd.it/pahav4l229751.png?width=1203&format=png&auto=webp&s=41671383f2aa5fcd8bb39204701a9f6a5bb0797a> pprof.go Further, I wonder if it's even possible to profile a game server with a simulation framerate of 120Hz. Since the 100Hz CPU profile rate is hard coded in `StartCPUProfile` I would guess we even per frame aggregation it make not work of a frame duration is usually below 1s / 120 or is that not relevant? Best, Michael -- 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/d0e8b1ae-d992-44ed-bd9a-6a72e6526d4co%40googlegroups.com.
