wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
9.89k stars 658 forks source link

Dynamically allocated frame names #608

Open YaLTeR opened 1 year ago

YaLTeR commented 1 year ago

Hi! I'm using Tracy to profile a Wayland compositor I'm writing, using the Rust Tracy bindings. I'm really quite enjoying it, thanks for this fantastic piece of software!

I've recently started using discontinuous frames to measure my compositor rendering monitor contents. However, since every monitor has a completely separate repaint and vsync cycle, I need to use a distinct frame set for every monitor. And since monitors can be plugged in and out at runtime, I need to name those frame sets dynamically.

As far as I understand, there's currently no API for creating frames that copies the name string that it receives. For now I've worked around this by leaking the generated name string (making it valid for the rest of the program's lifetime), but this is not ideal. If I understand correctly, spans do have an API that copies the string they get.

wolfpld commented 1 year ago

The workaround you are using is the intended solution. The amount of monitor connect/disconnect events is so insignificant that leaking the memory is not a problem. The alternative solution, if implemented, would require making per-frame copies of the provided string, making things not ideal in another way.

YaLTeR commented 1 year ago

Right, I see.