Changes between Version 8 and Version 9 of EngineProfiling


Ignore:
Timestamp:
Jan 29, 2015, 9:59:01 PM (9 years ago)
Author:
Yves
Comment:

Add information about the SpiderMonkey Tracelogger

Legend:

Unmodified
Added
Removed
Modified
  • EngineProfiling

    v8 v9  
    114114
    115115
     116== SpiderMonkey Tracelogger ==
     117SpiderMonkey, the JavaScript engine we are using, has some own performance profiling capabilities for analyzing JS performance.
     118
     119[[Image(tracelogger.png, 25%)]]
     120
     121=== Characteristics ===
     122Compared to the other profiling tools and approaches, the Tracelogger has the following characteristics:
     123
     124 * Shows in which optimization mode the JS code runs (Interpreter, Baseline, Ion Monkey). This is the only profiler listed here that shows this information. Functions which run in Interpreter or Baseline mode too much could be a performance issue (also read the part below about inlining).
     125 * Shows how many times function got compiled by SpiderMonkey.
     126 * Shows how many times function got called in total (also read the part below about inlining).
     127 * Shows total runtime percentages for each function (also read the part below about C++ functions).
     128 * You need a special build of SpiderMonkey. On Linux this isn't an issue, but on Windows we use prebuilt SpiderMonkey binaries, so it's a bit harder to use there.
     129 * There is a small overhead, but it's small enough that you can still play games as normal. The overhead is mainly caused by flushing profiling data to the disk. It reduces performance by around 5%, and you see on the output where the flushing happens, so it's not a big problem.
     130 * The Tracelogger only profiles JavaScript functions (also read the part below about C++ functions).
     131 * Getting profile data from longer games can require quite a lot of harddisk space (around 10-15 GB).
     132 * Larger profile data has to be reduced before it can be viewed. This can take quite a while (up to an hour).
     133
     134==== Inlining ====
     135You have to be a bit careful with your conclusions because SpiderMonkey sometimes inlines functions. If you get much lower numbers of calls for a function than you would expect, then it could be because the function got inlined in a parent function. In this case only the calls of the parent function are counted. Also take a look at the number of calls if you see that a function runs in Baseline mode most of the time. Very low numbers of calls are an indication that it probably got inlined. In this case it's normal that it runs in Baseline most of the time before inlining happens.
     136
     137==== C++ functions ====
     138C++ functions on a C++ only callstack are not shown and ignored in the runtime percentages you see. Time spent from C++ functions which are called from JS functions is included, but not measured separately (these functions count towards the JS function that calls them).
     139
     140=== Using the Tracelogger ===
     141When you use it the first time, you can just do all the steps described below in order.
     142
     143==== Build SpiderMonkey with Tracelogging ====
     1441. In libraries/source/spidermonkey/build.sh, search for "--enable-trace-logging". It's disabled by a comment and you have to enable it.
     1451. One line below, there's the definition of TLCXXFLAGS. This defines the output path and you may want to modify it. Make sure to keep the "/" at the end of the path.
     1461. Run clean-workspaces.sh and update-workspaces.sh (or rebuild-osx-libs.sh --force-rebuild on the Mac) to rebuild SpiderMonkey.
     147
     148==== Getting the Tracelogger ====
     149The tool to view Tracelogging data is not included in SpiderMonkey or bundled with 0 A.D..
     150You can get it from git:
     151{{{
     152git clone https://github.com/h4writer/tracelogger tracelogger
     153}}}
     154
     155Version with git hash a9f37928f95ea46a8c8767497c8fb8223d2b3268 was successfully tested with our version of SpiderMonkey (in case future versions aren't compatible anymore).
     156
     157==== Measuring ====
     158When SpiderMonkey is built with Tracelogging enabled, all you need to do is building the game and running the test.
     159
     160==== Reducing and viewing data ====
     161Data can become quite large (several GB). You could view this data directly in the browser, but it would take forever to load and you usually want to reduce the data before viewing it.
     162
     163Use the reduce.py file from the git checkout. Pypy is a lot faster than python, but some versions of pypy have a bug. You can try with pypy, but if the output files are only 24 bytes, then you are affected by the bug and should probably use python instead. The output path points to a directory and contains a prefix to use for the reduced files ("reduced" in this example).
     164{{{
     165pyp tools_v2/reduce.py /path/to/tracelogging/dir/tl-data.json /path/to/output/reduced
     166}}}
     167
     168To view the data, copy engine.js, tracelogger.js, tracelogger.css and tracelogger.html from the tools_v2 directory to /path/to/output/. Then open tracelogger.html in a browser and append ''?data=reduced.json''. Then select a thread from the list.
     169
     170
    116171== Valgrind ==
    117172