TaskTracer: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎How to use Task Tracer: Add addition description about the use of GeckoProfiler.)
(→‎How to use TaskTracer: Add description about stop command.)
Line 9: Line 9:
== How to use TaskTracer ==
== How to use TaskTracer ==
=== mozilla-central ===
=== mozilla-central ===
1. Build and flash (built-in)
'''1. Build and flash (built-in)'''


  cd B2G
  cd B2G
Line 15: Line 15:
  ./flash.sh gecko
  ./flash.sh gecko


2. Start profiling
'''2. Start profiling'''


  ./profile.sh start -f tasktracer
  ./profile.sh start -f tasktracer
Line 23: Line 23:
Please note that because TaskTracer is design to record the correlation of tasks between threads and processes, enabling this feature will start profiling on all processes, which says, later commands such as <code>./profile.sh start -p aProcessName</code> will be invalid.
Please note that because TaskTracer is design to record the correlation of tasks between threads and processes, enabling this feature will start profiling on all processes, which says, later commands such as <code>./profile.sh start -p aProcessName</code> will be invalid.


3. Get results
'''3. Get results'''


3.1. Capture current results
'''3.1. Capture current results'''


  ./profile.sh capture
  ./profile.sh capture
Line 31: Line 31:
In additional to the original results of GeckoProfiler, turning on <code>-f tasktracer</code> should find a section of TaskTracer data inserted into each output files. The first recording period is from the time of <code>./profile.sh start</code> till the time of first <code>./profile.sh capture</code>, the next recording period is then from the time of this <code>capture</code> till the next <code>capture</code>...and so on.
In additional to the original results of GeckoProfiler, turning on <code>-f tasktracer</code> should find a section of TaskTracer data inserted into each output files. The first recording period is from the time of <code>./profile.sh start</code> till the time of first <code>./profile.sh capture</code>, the next recording period is then from the time of this <code>capture</code> till the next <code>capture</code>...and so on.


3.2. Get TaskTracer Converter
<code>./profile.sh stop</code> kills all processes and reboots b2g.
 
'''3.2. Get TaskTracer Converter'''


  git clone https://github.com/ginayeh/task-tracer-converter -b v2.0
  git clone https://github.com/ginayeh/task-tracer-converter -b v2.0


3.3. Convert results
'''3.3. Convert results'''


  mv profile_*.txt task-tracer-converter/log/
  mv profile_*.txt task-tracer-converter/log/

Revision as of 06:59, 18 November 2014

Introduction

TaskTracer aims at the correlation between Tasks and Runnables, across threads and processes.

By looking at a task, TaskTracer tells you:

  • The “source events” of this task.
    • IO events: touch events, key events, wifi daemon signal
  • Where it is dispatched from.

How to use TaskTracer

mozilla-central

1. Build and flash (built-in)

cd B2G
export MOZ_TASK_TRACER=1; ./build.sh gecko
./flash.sh gecko

2. Start profiling

./profile.sh start -f tasktracer

You can still combine the "tasktracer" feature with other supported flags of "start" command. For example, ./profile.sh start -f tasktracer,js,leaf -i 50 will start profiling on all processes with tasktracer and default features, and longer the sampling interval to 50 milliseconds.

Please note that because TaskTracer is design to record the correlation of tasks between threads and processes, enabling this feature will start profiling on all processes, which says, later commands such as ./profile.sh start -p aProcessName will be invalid.

3. Get results

3.1. Capture current results

./profile.sh capture

In additional to the original results of GeckoProfiler, turning on -f tasktracer should find a section of TaskTracer data inserted into each output files. The first recording period is from the time of ./profile.sh start till the time of first ./profile.sh capture, the next recording period is then from the time of this capture till the next capture...and so on.

./profile.sh stop kills all processes and reboots b2g.

3.2. Get TaskTracer Converter

git clone https://github.com/ginayeh/task-tracer-converter -b v2.0

3.3. Convert results

mv profile_*.txt task-tracer-converter/log/
cd task-tracer-converter/
./tasktracer.sh get_mmaps
./task_tracer_converter.py -sp $B2G/objdir/dist/bin/libxul.so \
                           -np $B2G/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/x86_64-linux/bin/nm

v1.3T

1. Get the source code of TaskTracer.

git clone https://github.com/shellylin/gecko-dev/tree/tt-1.3t

2. Build and flash to a real device.

cd B2G
export MOZ_TASK_TRACER=1; ./build.sh gecko
./flash.sh gecko

3. Get the source code of data retriever and data converter.

git clone https://github.com/ginayeh/task-tracer-converter

4. Start profiling.

cd task-tracer-converter
./tasktracer.sh start

5. Stop profiling.

 ./tasktracer.sh stop

The raw log is written into task_tracer_data.logcat.

6. Get memory maps from the real device.

mkdir mmaps
./tasktracer.sh get_mmaps

The memory maps pulled out from the real device are put under mmaps directory automatically.

7. Prepare data for extracting class/task name.

./prepare-data.sh mmaps $objdir

Two intermediate files are generated for later use: mem_offset, symbol.

8. Convert raw log to JSON format.

python task_tracer_converter.py -i task_tracer_data.logcat [-o task_tracer_data.json] [-w]

Default output filename: task_tracer_data.json.

How to read the profile using Nephthys

Import the json file to Nephthys, http://alivedise.github.io/nephthys/

Reference links

TODO

  • Integrate with built-in profiler
    • Timestamp
    • Start/Stop
  • Thread pool
  • CpuTime
  • Integrate with Cleopatra
  • Nested loop
  • Ruler