TaskTracer
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. Get TaskTracer Converter
https://bugzilla.mozilla.org/show_bug.cgi?id=1098217
Since Converter hasn't been landed yet, please manually download the patch and apply to your B2G repo.
3. 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.
4. Capture profiling 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.
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
- bug 995058 - [Meta] TaskTracer and Nephthys
- bug 908995 - [B2G] Task tracer
- bug 916409 - Data retriever for task tracer
- bug 916410 - Show data generated by Task Tracer in Cleopatra
- bug 956620 - [B2G] Task tracer converter
- bug 992454 - [B2G] Integrate Task tracer&Nephthys with GeckoProfiler&Cleopatra
- Nephthys
- FoxGuide
TODO
- Thread pool
- CpuTime
- Integrate with Cleopatra
- Nested loop
- Ruler