better profiler output #5753

Open
opened 2023-12-19 21:39:54 +00:00 by flux · 6 comments
Member

the output of the profiler is borderline useless a lot of time:

 instrumentation                  |    min µs |    max µs |    avg µs | min % | max % | avg %
--------------------------------- | --------- | --------- | --------- | ----- | ----- | ------
 yl_statuseffects:                |      1083 |   1102284 |     90947 |   0.3 |  97.0 |  23.6
  - on_joinplayer[2] ...........  |        39 |       177 |        82 |   0.0 |   0.1 |   0.0
  - on_leaveplayer[1] ..........  |         1 |         1 |         1 |   0.0 |   0.0 |   0.0
  - on_player_receive_fields[1]   |        33 |      4225 |       105 |   0.0 |   7.9 |   0.2
  - globalstep[3] ..............  |         1 |       165 |         2 |   0.0 |   0.4 |   0.0
  - globalstep[2] ..............  |         1 |      5039 |       125 |   0.0 |   7.3 |   0.2
  - globalstep[1] ..............  |      1081 |   1101408 |     90836 |   0.3 |  97.0 |  23.4
  - on_leaveplayer[3] ..........  |        47 |       138 |        93 |   0.0 |   0.3 |   0.1
  - on_joinplayer[1] ...........  |        59 |      3509 |       684 |   0.0 |   1.1 |   0.2
  - /toggle_bf_hud .............  |       253 |       253 |       253 |   0.1 |   0.1 |   0.1
  - on_leaveplayer[2] ..........  |        91 |      1873 |       466 |   0.0 |   0.5 |   0.2
--------------------------------- | --------- | --------- | --------- | ----- | ----- | ------

what exactly is e.g. globalstep[1]?

in #2416 (comment), i mentioned some changes i made to the profiler to show files and line numbers where these things are defined:

diff --git a/builtin/profiler/instrumentation.lua b/builtin/profiler/instrumentation.lua
index 5c1cb191b..42b1c0c5a 100644
--- a/builtin/profiler/instrumentation.lua
+++ b/builtin/profiler/instrumentation.lua
@@ -61,11 +61,9 @@ local function generate_name(def)
        elseif label == false then
                return format("%s", class or func_name):trim()
        end
-
-       local index_id = def.mod .. (class or func_name)
-       local index = counts[index_id] or 1
-       counts[index_id] = index + 1
-       return format("%s[%d] %s", class or func_name, index, class and func_name or ""):trim()
+       local info = debug.getinfo(def.func)
+       local worldpath = minetest.get_worldpath()
+       return format("%s %s#%s", class or func_name, info.source:gsub(worldpath, ""), info.linedefined)
 end
 
 ---
diff --git a/builtin/profiler/reporter.lua b/builtin/profiler/reporter.lua
index 5928a3718..2e24a1fe0 100644
--- a/builtin/profiler/reporter.lua
+++ b/builtin/profiler/reporter.lua
@@ -77,7 +77,7 @@ local Formatter = {
        end
 }
 
-local widths = { 55, 9, 9, 9, 5, 5, 5 }
+local widths = { 80, 9, 9, 9, 5, 5, 5 }
 local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths))
 
 local HR = {}

much better:

the output of the profiler is borderline useless a lot of time: ``` instrumentation | min µs | max µs | avg µs | min % | max % | avg % --------------------------------- | --------- | --------- | --------- | ----- | ----- | ------ yl_statuseffects: | 1083 | 1102284 | 90947 | 0.3 | 97.0 | 23.6 - on_joinplayer[2] ........... | 39 | 177 | 82 | 0.0 | 0.1 | 0.0 - on_leaveplayer[1] .......... | 1 | 1 | 1 | 0.0 | 0.0 | 0.0 - on_player_receive_fields[1] | 33 | 4225 | 105 | 0.0 | 7.9 | 0.2 - globalstep[3] .............. | 1 | 165 | 2 | 0.0 | 0.4 | 0.0 - globalstep[2] .............. | 1 | 5039 | 125 | 0.0 | 7.3 | 0.2 - globalstep[1] .............. | 1081 | 1101408 | 90836 | 0.3 | 97.0 | 23.4 - on_leaveplayer[3] .......... | 47 | 138 | 93 | 0.0 | 0.3 | 0.1 - on_joinplayer[1] ........... | 59 | 3509 | 684 | 0.0 | 1.1 | 0.2 - /toggle_bf_hud ............. | 253 | 253 | 253 | 0.1 | 0.1 | 0.1 - on_leaveplayer[2] .......... | 91 | 1873 | 466 | 0.0 | 0.5 | 0.2 --------------------------------- | --------- | --------- | --------- | ----- | ----- | ------ ``` what exactly is e.g. `globalstep[1]`? in https://gitea.your-land.de/your-land/bugtracker/issues/2416#issuecomment-66604, i mentioned some changes i made to the profiler to show files and line numbers where these things are defined: ```diff diff --git a/builtin/profiler/instrumentation.lua b/builtin/profiler/instrumentation.lua index 5c1cb191b..42b1c0c5a 100644 --- a/builtin/profiler/instrumentation.lua +++ b/builtin/profiler/instrumentation.lua @@ -61,11 +61,9 @@ local function generate_name(def) elseif label == false then return format("%s", class or func_name):trim() end - - local index_id = def.mod .. (class or func_name) - local index = counts[index_id] or 1 - counts[index_id] = index + 1 - return format("%s[%d] %s", class or func_name, index, class and func_name or ""):trim() + local info = debug.getinfo(def.func) + local worldpath = minetest.get_worldpath() + return format("%s %s#%s", class or func_name, info.source:gsub(worldpath, ""), info.linedefined) end --- diff --git a/builtin/profiler/reporter.lua b/builtin/profiler/reporter.lua index 5928a3718..2e24a1fe0 100644 --- a/builtin/profiler/reporter.lua +++ b/builtin/profiler/reporter.lua @@ -77,7 +77,7 @@ local Formatter = { end } -local widths = { 55, 9, 9, 9, 5, 5, 5 } +local widths = { 80, 9, 9, 9, 5, 5, 5 } local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths)) local HR = {} ``` much better: ![](https://gitea.your-land.de/your-land/bugtracker/attachments/b5844f53-c73a-46ff-ba4e-2edfa15fde68)
flux added the
1. kind/enhancement
label 2023-12-19 21:39:54 +00:00

This will help a lot of serverowners and should go to upstream

Not sure should we consider builtin as source/mod upstream or source/engine?

This will help a lot of serverowners and should go to upstream Not sure should we consider builtin as source/mod upstream or source/engine?
AliasAlreadyTaken added the
3. source/mod upstream
3. source/engine
labels 2023-12-20 02:03:37 +00:00

Not sure should we consider builtin as source/mod upstream or source/engine?

engine, cause upstream is the engine repo and changes only happen on a engine release

> Not sure should we consider builtin as source/mod upstream or source/engine? engine, cause upstream is the engine repo and changes only happen on a engine release
AliasAlreadyTaken removed the
3. source/mod upstream
label 2023-12-20 12:45:55 +00:00
Author
Member

This will help a lot of serverowners and should go to upstream

sure, why not. it needed a bit more work before it was suitable for upstream though, i was being lazy.

https://github.com/minetest/minetest/pull/14142

> This will help a lot of serverowners and should go to upstream sure, why not. it needed a bit more work before it was suitable for upstream though, i was being lazy. https://github.com/minetest/minetest/pull/14142
flux added the
4. step/blocked
label 2023-12-20 22:49:37 +00:00
flux added
4. step/ready to QA test
and removed
4. step/blocked
labels 2024-01-04 01:02:48 +00:00
Author
Member

upstream got merged, though we'll have to wait until 5.9 for this to go live

upstream got merged, though we'll have to wait until 5.9 for this to go live
Author
Member

maybe i should have left this as "blocked"...

maybe i should have left this as "blocked"...

This is one of the issues I'd like to cherrypick into the 5.8.0 engine test

This is one of the issues I'd like to cherrypick into the 5.8.0 engine test
flux added this to the minetest 5.9.0 milestone 2024-03-30 01:20:34 +00:00
flux modified the milestone from minetest 5.9.0 to minetest 5.8.0 2024-03-30 01:20:47 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#5753
No description provided.