Changes between Version 6 and Version 7 of Profiler2


Ignore:
Timestamp:
Jan 29, 2021, 9:37:42 AM (3 years ago)
Author:
Langbart
Comment:

instruction added for non-visual replay (command line)

Legend:

Unmodified
Added
Removed
Modified
  • Profiler2

    v6 v7  
    11= Using Profiler2 for profiling =
    2 Profiler2 is 0 A.D.'s advanced profiler. It is defined for very finely grained profiling, since it can measure events down to every single occurrence. A simple use of Profiler 2 would be to track down framerate spikes, or measure absolute performance improvements over a simulation turn.
     2Profiler2 is 0 A.D.'s advanced profiler. It is defined for very finely grained profiling, since it can measure events down to every single occurrence. A simple use of Profiler 2 would be to detect frame rate spikes or measure absolute performance improvements over a simulation turn.
    33
    4 == Enabling Profiler2 ==
    5 By default, profiler2 is not activated. To see the results, you need to enable the HTTP server. You can do this by setting the following configuration in your user.cfg file: "profiler2.autoenable = true". Alternatively, you can press Ctrl+F11 (by default) to activate the HTTP profiler in-game. Currently, enabling Profiler2 in replay mode can only be done by recompiling the game with the following patch:
     4== Creating a Profiler2 file ==
     5=== non-visual replay (command line) ===
     6You will need a replay file (command.txt) that you can create yourself or get from someone else, make sure it is compatible with your Alpha version. When you run the following command, a ''profiler2.jsonp'' file is automatically created in your working directory (~/0ad).
     7
     8{{{
     9pyrogenesis -mod=public -replay=[PATH to a command.txt file]
     10}}}
     11Non-visual replay is also '''recommended''' if you want to compare two different states of your working copy with the same replay file. This ensures that your two ''.jsonp'' files are in sync and can be better compared using the ''source/tools/profiler2/profiler2.html'' file.
     12
     13=== visual replay (game interface) ===
     14By default, profiler2 is not enabled. To see the results, you need to enable the HTTP server. You can do this by setting the following configuration in your user.cfg file: "profiler2.autoenable = true". Alternatively, you can press Ctrl+F11 (by default) to activate the HTTP profiler in-game. Currently, enabling Profiler2 in replay mode can only be done by recompiling the game with the following patch:
    615
    716{{{
     
    2029        g_ScriptRuntime = ScriptInterface::CreateRuntime(shared_ptr<ScriptRuntime>(), runtimeSize, heapGrowthBytesGCTrigger);
    2130}}}
    22 Once the HTTP server is activated, you simply need to open source/tools/profiler2/profiler2.html in a modern web browser. You should see the "Live" report being loaded. If you have not enabled the HTTP profiler, nothing will show up, otherwise, you should get a screen with a timeline of frames and events
     31Once the HTTP server is enabled, you simply need to open ''source/tools/profiler2/profiler2.html'' in a modern web browser. You should see that the " Live" report is loaded. If you don't have HTTP profiler enabled, nothing will be displayed, otherwise you should get a screen with a timeline of frames and events. You can save report sessions by clicking "Save Live Report to file". This will save the file to your log folder instead of your working directory as with non-visual replay. If you do this over a few runs, you can get several report files to compare.
     32
     33== Comparing reports ==
     34You can easily compare multiple runs using the ''source/tools/profiler2/profiler2.html'' file by loading multiple profiling reports. Load them in the interface and click on some of the events. The graphs will then show you the event for all the reports so you can easily compare them. You will also get a table recapitulating some information to help you decide if an optimisation is worth it.
     35
     36[[Image(https://trac.wildfiregames.com/raw-attachment/wiki/Profiler2/compare-reports.PNG, 800px, border=2)]]
     37
     38  ==
    2339
    2440== The Report interface ==
     
    2743[[Image(https://trac.wildfiregames.com/raw-attachment/wiki/Profiler2/report-timeline.PNG, 700px, border=2)]]
    2844
    29 The top timeline shows you the time taken by each frame to complete. The higher and wider, the slower. This allows you to easily notice spikes. The scale is logarithmic.[[BR]]
    30 Clicking anywhere on the frame timeline will show you the events around that point.
     45The top timeline shows you the time taken by each frame to complete. The higher and wider, the slower. This allows you to easily notice spikes. The scale is logarithmic.[[BR]] Clicking anywhere on the frame timeline will show you the events around that point.
    3146
    32 The events timeline gives you a finely grained view of all profiled events, as well as their duration. Clicking on this view allows you to zoom in.[[BR]]
    33 This view can help you notice which parts of the engine have suddenly spiked, and how frames generally go.
     47The events timeline gives you a finely grained view of all profiled events, as well as their duration. Clicking on this view allows you to zoom in.[[BR]] This view can help you notice which parts of the engine have suddenly spiked, and how frames generally go.
    3448
    3549Profiler2 allows you to open several reports (even in addition to the live report). You can open older profiling run using the top button. If you have several reports open, you can select the one you which to examine by clicking on it.
     50
    3651== The Analysis interface ==
    3752The lower part of the screen shows you useful graphs. On the "choices" panel, you will see a list of all profiled events. If you click on one or more of these events, you will get 2 graphs showing you information.
     
    4358[[Image(https://trac.wildfiregames.com/raw-attachment/wiki/Profiler2/analysis-long.PNG, 400px, border=2)]][[Image(https://trac.wildfiregames.com/raw-attachment/wiki/Profiler2/analysis-short.PNG, 400px, border=2)]]
    4459
    45 
    4660This graph shows you a function which generally takes under 5ms, but about 50% of the time takes 40ms or more.
    4761
     
    4963
    5064The frame-by-frame graphs shows you how long an event took frame-by-frame, which can be used along with the report timelines to find out precisely what frames are slow and thus what causes the slowness.
    51 
    52 == Comparing reports ==
    53 You can easily compare several runs using the profiler2 by loading several profiling reports. When you are profiling a game, press the "save Live Report to file" button to save the current profiler2 report in your log folder (it is named profiler2.jsonp). If you do this over a few runs, you can get several report files to compare.
    54 
    55 Load them up in the interface and click on some of the events. The graphs will then show you the event for all reports, so you can easily compare them. You will also get a table recapitulating some information to help you decide if an optimization is worth it.
    56 
    57 [[Image(https://trac.wildfiregames.com/raw-attachment/wiki/Profiler2/compare-reports.PNG, 800px, border=2)]]
    5865
    5966= Choosing what you wish to profile =
     
    6875
    6976=== Profiling in case of spikes ===
    70 Sometimes, you don't really care about a certain event, unless it suddenly goes above a certain treshold and causes the game to hang. To profile such events, you can use the 'PROFILE2_IFSPIKE(name,minimal time in seconds)' macro. The events will only show up in the timeline if they are above this treshold. This can help you profile events over a long time if you were otherwise running in the buffer limit.
    71 Note that any "nested" profiler2 call inside a spiked region will be discarded if the spiked event does not hold, so you can get very finely grained profiling in case of spikes without cluttering your timeline by using this function.
     77Sometimes, you don't really care about a certain event, unless it suddenly goes above a certain treshold and causes the game to hang. To profile such events, you can use the 'PROFILE2_IFSPIKE(name,minimal time in seconds)' macro. The events will only show up in the timeline if they are above this treshold. This can help you profile events over a long time if you were otherwise running in the buffer limit. Note that any "nested" profiler2 call inside a spiked region will be discarded if the spiked event does not hold, so you can get very finely grained profiling in case of spikes without cluttering your timeline by using this function.
    7278
    7379=== Aggregated profiling ===