Skip to content

Conversation

@dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Nov 21, 2025

This takes the existing using_cpp_profilers.rst and moves it to be about "Sampling profilers" (sampling_profilers.rst), so that a new page can be added about "Tracing profilers" (like Perfetto and Tracy!) and makes the old URL into an index that explains the difference and links to both pages.

This is marked as DRAFT for the moment, because it only covers Perfetto - I actually haven't had a chance try Tracy yet :-)

@dsnopek dsnopek requested a review from Ivorforce November 21, 2025 16:47
@dsnopek dsnopek added enhancement area:engine details Issues and PRs related to the Engine Details section of the documentation labels Nov 21, 2025
@dsnopek dsnopek marked this pull request as draft November 21, 2025 16:47
@dsnopek dsnopek force-pushed the tracing-profiler branch 3 times, most recently from 00cf4f1 to 74c46a5 Compare November 21, 2025 21:28
@dsnopek dsnopek changed the title [DRAFT] Add documentation on how to use Tracy and Perfetto Add documentation on how to use Tracy and Perfetto Nov 21, 2025
@dsnopek dsnopek marked this pull request as ready for review November 21, 2025 21:28
@dsnopek
Copy link
Contributor Author

dsnopek commented Nov 21, 2025

I've filled in the docs for Tracy now too, so taking this out of draft!

Given that I've only just tried Tracy for the first time, I'm very curious to hear if I'm using it correctly or not :-)

@dsnopek dsnopek force-pushed the tracing-profiler branch 2 times, most recently from aa775c7 to e5bd5a8 Compare November 21, 2025 22:40
Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good!

@dsnopek dsnopek force-pushed the tracing-profiler branch 2 times, most recently from 6bbb449 to 3b017d0 Compare November 24, 2025 21:51
@dsnopek
Copy link
Contributor Author

dsnopek commented Nov 24, 2025

@Ivorforce @AThousandShips Thanks for the review! I think I've integrated all your feedback in my latest push :-)

Copy link
Member

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@@ -1,3 +1,3 @@
.. _doc_using_cpp_profilers:

Using C++ profilers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should C++ be dropped from the page title and page path since both sampling and tracing profilers can be used for more than C++ applications and the Godot codebase contains other languages besides C++.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the "C++" is in there to distinguish it from Godot's profiler?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the section is explicit enough that we could drop C++. For example, in the same section we have a using sanitizers page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sanitizers is a little different, though: there isn't a "Godot sanitizer" and "C++ sanitizers", whereas we do have a "Godot profiler" and "C++ profilers"

However, if we do rename it, I assume we'd want to keep the path the same so we don't have to deal with redirects?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if we do rename it, I assume we'd want to keep the path the same so we don't have to deal with redirects?

yeah, keep things simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the page title isn't from this PR (it's pre-existing), I don't think we need to resolve this here. The title can be addressed in another PR

To learn more, see the
`Tracy manual <https://github.com/wolfpld/tracy/releases/latest/download/tracy.pdf>`_.

Perfetto for Android
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth including that it supports Win/Mac/Linux as well.

Copy link
Contributor Author

@dsnopek dsnopek Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the way Godot has integrated it (at least so far) really supports Windows and Mac. It's setup to use the "system" backend, which requires connecting with Perfetto's system daemon which I think is only Linux and Android. If we added support for the "in process" backend we could add docs for how to use that later? The steps for using it would be somewhat different

This will create a ``perfetto`` directory - you can place this anywhere.

Next, build the Android debug or release templates for your architecture using
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are debug symbols not required for Perfetto?

Copy link
Contributor Author

@dsnopek dsnopek Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! Debug symbols are not required for Perfetto, or Tracy either, if you just use its tracing stuff and not its sampling features

Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Ryan-000
Copy link
Contributor

Ryan-000 commented Dec 3, 2025

When I previously used a Tracy integration, GDExtensions could not reload. (At least on Linux, I'm not sure about Windows).

If this is still true, it may be worth mentioning.

@Ivorforce
Copy link
Member

Did you use the Tracy Gdextension?

@Ryan-000
Copy link
Contributor

Ryan-000 commented Dec 3, 2025

Did you use the Tracy Gdextension?

Yes https://github.com/Ryan-000/godot_tracy

@Ivorforce
Copy link
Member

Ivorforce commented Dec 3, 2025

Aha, that should explain it.
The tracy GDExtension is, well, a GDExtension. It's possible that the hot reload didn't work well with how tracy's / the extension's assumptions.
Godot's integration is in core, and does not use the GDExtension system. As such, I don't think it will affect whether GDExtensions can reload or not. But thanks for reporting, we'll keep an eye on it!

@Ryan-000
Copy link
Contributor

Ryan-000 commented Dec 3, 2025

Oh my bad, I misinterpreted your question. I actually had it compiled as a custom module, not as GDExtension.

Copy link
Contributor

@AdriaandeJongh AdriaandeJongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the guide but didn't get tracy to work unfortunately. As I am now stuck, and with little knowledge of what went wrong where, perhaps a bit of info on common mistakes or troubleshooting would be in order? It would help if I'd know what actually went wrong so I could make a more specific suggestion...

Record a trace
~~~~~~~~~~~~~~

Launch the Tracy server - you'll see something like this:
Copy link
Contributor

@AdriaandeJongh AdriaandeJongh Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 'just launch the server!' is a bit too casual for users like me. I went down a rabbit hole just to discover that the previous cmake compile steps place a binary at tracy/profiler/build/tracy-profiler which is the thing you'll want to launch. Might be good to add that here somehow.


The full details can be found in the
`Tracy manual <https://github.com/wolfpld/tracy/releases/latest/download/tracy.pdf>`_,
but here is the TL;DR:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TL;DR should IMO also contain that you need to install CMake. The easiest way to do that is using a Homebrew command, eg. brew install cmake.

that is exhibiting performance issues), wait before pressing the button.

Now, export your game using the release templates you built above, and run it.
As soon as both are running, and you have pressed the "Connect" button in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did all the steps precisely as explained, and yet tracy gets stuck in 'Waiting for connection' after pressing the connect button. Perhaps some basic info on troubleshooting is in order here.

Copy link
Contributor

@AdriaandeJongh AdriaandeJongh Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a bit of a checklist:

  • make sure you compiled the export templates with the right scons arguments
  • make sure you export your game using the custom export template
  • ... ?

or maybe this is too convoluted, idk.

Copy link
Contributor

@AdriaandeJongh AdriaandeJongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it to work! There was an important scons argument missing from this guide. Other than that I think the guide is pretty good! Thanks a lot @dsnopek!

Comment on lines +38 to +41
Next, build the release templates for your platform using ``scons``, but adding
the ``profiler_path=path/to/tracy`` argument with the real path to the ``tracy``
directory, as well as ``debug_symbols=yes`` to allow Tracy's sampling features
to work.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another required argument that is missing from this guide: profiler=tracy. Might also have to be set for the other profilers (I don't know) but for this one I confirmed it to be the reason I wasn't able to get tracy to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this argument was only added recently. Other profilers also need it (profiler=perfetto, as well as profiler=instruments, although I think instruments should be documented in a follow-up PR by Stuart).

Comment on lines +94 to +96
If you press "Connect" now, you can profile the launch of Godot. However,
if you want to profile something specific (for example, a part of your game
that is exhibiting performance issues), wait before pressing the button.
Copy link
Member

@Ivorforce Ivorforce Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just learned from a comment on the PR (+ the manual) that by default, tracy just stashes the profiler results until a server connection is made. So starting the server later (instead of immediately) just leads to RAM issues.
For now, I'd say we can change the formulation to ask users to profile immediately to avoid issues. In the future, we may want to add support for TRACY_ON_DEMAND (which makes profiling slower but supports launching the server later without RAM bloat).

Maybe something like this?

Suggested change
If you press "Connect" now, you can profile the launch of Godot. However,
if you want to profile something specific (for example, a part of your game
that is exhibiting performance issues), wait before pressing the button.
Press "connect". This will ensure tracy makes a connection immediately when the game launches. If you forget to press "connect", tracy will store system events in RAM, which can quickly blow up your memory usage (see ``TRACY_ON_DEMAND`` documentation).

@AdriaandeJongh
Copy link
Contributor

To make line numbers show up correctly for tracy, these two checkboxes in the player settings need to be checked:
Screenshot 2025-12-08 at 12 51 00

This should be in the docs, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:engine details Issues and PRs related to the Engine Details section of the documentation enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants