mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
Builtin profiler: Capture Tracy zones; And small improvements (#16479)
* Feature: Use the builtin profiler to automatically make zones for mod callback functions. * Doc: Basic doc for builtin profiler, and better `/profiler` chatcommand help. * Fix: `register_functions` (table of callback register function names), and `entity_instrumentation` is no longer outdated. * Fix: Builtin profiler output is no longer printed to debug.txt or to file in world with translation escapes. * Fix: Entity callback name generation used `obj_def.label` (normally non-existing field), now it uses the entity name. * Small code improvements, like use of new `Settings.get_bool` with default.
This commit is contained in:
parent
c9d4c33174
commit
69497200f9
7 changed files with 171 additions and 92 deletions
|
@ -1,5 +1,16 @@
|
|||
# Profiling
|
||||
|
||||
## Using builtin's mod profiler
|
||||
|
||||
Builtin has a profiler for callbacks registered by mods. It measures how much
|
||||
time each callback took per server-step (on average / min / max).
|
||||
|
||||
To start, enable the `profiler.load` setting.
|
||||
(There are more settings, see `profiler.*` and `instrument.*`.)
|
||||
|
||||
Use the `profiler` chatcommand to look at the results.
|
||||
|
||||
|
||||
## Profiling Luanti on Linux with perf
|
||||
|
||||
We will be using a tool called "perf", which you can get by installing `perf` or `linux-perf` or `linux-tools-common`.
|
||||
|
@ -65,13 +76,16 @@ Build Luanti with `-DDBUILD_WITH_TRACY=1`, this will fetch Tracy for building
|
|||
the Tracy client. And use `FETCH_TRACY_GIT_TAG` to get a version matching your
|
||||
Tracy server, e.g. `-DFETCH_TRACY_GIT_TAG=v0.11.0` if it's `0.11.0`.
|
||||
|
||||
To actually use Tracy, you also have to enable it with Tracy's build options:
|
||||
```
|
||||
-DTRACY_ENABLE=1 -DTRACY_ONLY_LOCALHOST=1
|
||||
```
|
||||
To actually use Tracy, you also have to enable it with Tracy's build options
|
||||
(`-DTRACY_ENABLE=1`).
|
||||
|
||||
See Tracy's documentation for more build options.
|
||||
|
||||
TL;DR:
|
||||
```
|
||||
-DDBUILD_WITH_TRACY=1 -DFETCH_TRACY_GIT_TAG=<your_version> -DTRACY_ENABLE=1 -DTRACY_ONLY_LOCALHOST=1
|
||||
```
|
||||
|
||||
### Using in C++
|
||||
|
||||
Start the Tracy server and Luanti. You should see Luanti in the menu.
|
||||
|
@ -87,3 +101,6 @@ See Tracy's official documentation for more information.
|
|||
|
||||
Note: The whole Tracy Lua API is accessible to all mods. And we don't check if it
|
||||
is or becomes insecure. Run untrusted mods at your own risk.
|
||||
|
||||
Enable `profiler.load` and `profiler.tracy` to automatically instrument mod
|
||||
callback functions.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue