-
Notifications
You must be signed in to change notification settings - Fork 117
Profiling
OpenDream natively integrates the Tracy profiler for high-resolution high-precision profiling of memory and CPU usage of DM code.
This profiling is available when OpenDream is compiled in TOOLS
or DEBUG
mode (note that DEBUG
mode runs a lot slower than TOOLS
).
To enable the profiling from application start (and thus capture all of /world
initialisation from the first instruction) start the OpenDream server with the command --cvar opendream.enable_tracy=true
. Alternatively, you can enable the profiling at runtime by typing activatetracy
into the server console - this will capture profiling data only from the moment the command is run and will not reflect accurately on memory usage as it will not log memory which was allocated before the profiler was activated.
Note that activating the profiler without connecting a Tracy client will cause OpenDream to use a lot of memory as it buffers all profiling data.
To view the profiling data, connect the Tracy client. As the profiling runs, this is the screen you will see:
- The resource graph shows the amount of memory allocated by icon and sound objects.
- The string graph shows the amount of memory allocated to storing strings (DreamValues containing string data)
- The
/datum
graph shows the maximum amount of memory that could be used by all currently used/datum
s. Note that the amount of memory actually allocated may be less if the/datum
's vars are kept as default values. - The
/list
contents graph shows the amount of memory allocated by lists. Note that where a list contains a string or/datum
entry, that allocation is also shown in the string and/datum
graphs respectively. - The
/list
instance graph shows the number of lists that exist - this is actually a unit-less quantity, though Tracy shows it as bytes due to a limitation of the Tracy API.
The flame graph will show each server tick and how much time was spent in each DM proc, as well as the time allocated to sending map updates and disk IO. The relevant source code and statistics are also available.
Compiling in TOOLS
enables several additional features and this may reduce performance slightly, though there should be no performance cost from Tracy while it is not enabled.
If enabled, Tracy will have a small performance cost as every allocation and proc call is recorded and tracked.
If enabled and no Tracy client is attached, the OpenDream server will buffer all profiling data and thus allocate a considerable amount of memory.