TaskTracer: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Add bugzilla queries)
Line 8: Line 8:


== How to use TaskTracer ==
== How to use TaskTracer ==
see https://bitbucket.org/thinker/tttools
=== mozilla-central ===
=== mozilla-central ===
'''1. Build and flash (built-in)'''
'''1. Build and flash (built-in)'''

Revision as of 05:52, 25 November 2016

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

see https://bitbucket.org/thinker/tttools

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 add TaskTracer labels

Our ultimate goal is to leverage labels or debugging information that already existed in the gecko code base. As in current phase, we provide a quick and easy way for developers to add debugging messages.

For Gecko developers

 #include "GeckoTaskTracer.h"
 mozilla::tasktracer::AddLabel(msg_with_printf_format_string);

For example, AddLabel("Function %d is called %d times.", name, count);

For Gaia developers

Simply prefix #tt# to your console.log message, message can still be found in adb logcat.

 console.log("#tt#"+console_log_format_string);

In frank, AddLabel() functions like printf and console.log.

How to read the profile using Nephthys

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

Work in progress

Full Query
ID Summary Priority Status
908995 [B2G] Task tracer -- RESOLVED
916409 Data retriever for task tracer -- RESOLVED
916410 Show data generated by Task Tracer in Cleopatra -- RESOLVED
956620 [B2G] Task tracer converter -- RESOLVED
992454 [B2G] Integrate Task tracer with GeckoProfiler -- RESOLVED
1000847 Task Tracer: trace task in thread pool -- RESOLVED
1062794 Task tracer ignores zero SourceEventId -- RESOLVED
1064672 Task Tracer: Deleting TLS doesn't function properly -- RESOLVED
1064673 Task Tracer: Use mozilla::TimeStamp instead of prtime -- RESOLVED
1074122 Task Tracer: Handle signal interrupt with semaphore -- RESOLVED
1074203 Task Tracer: Implement a circular buffer to store log data -- RESOLVED
1076772 Task Tracer: Enable TaskTracer with engineering build of B2G -- RESOLVED
1084226 Add a new TaskTracer feature to profile.sh -- RESOLVED
1089514 Task Tracer: Some traced tasks/runnables have record of dispatch, but no records of execution -- RESOLVED
1091479 TaskTracer: SourceEvent have no record of vptr -- RESOLVED
1091533 Task Tracer: reset thread ids after content processes are forked from Nuwa -- RESOLVED
1095433 Task Tracer: crash in the preallocated process after Task Tracer is turned on -- RESOLVED
1098217 Convert TaskTracer data during profile capture -- RESOLVED
1098681 TaskTracer should call GetCurTraceInfo() on message earlier -- RESOLVED
1100259 TaskTracer: Add labels in EventDispatcher and console.log -- RESOLVED
1103915 Task Tracer: timestamp skew in different processes -- RESOLVED
1104414 [TaskTracer] mozilla-central/ipc/chromium/src/chrome/common/ipc_message.cc:39:33: error: 'UNKNOWN' is not a member of 'mozilla::tasktracer::SourceEventType' -- RESOLVED
1111949 [TaskTracer] Bulid error: mozilla-central/tools/profiler/GeckoTaskTracer.cpp:115:31: error: expected ')' before 'false' -- RESOLVED
1111952 [TaskTracer] Assertion failure: !sTraceInfoTLS, at mozilla-central/tools/profiler/GeckoTaskTracer.cpp:204 -- RESOLVED
1113562 Task Tracer: Timer delay should not be the latency of a timer event -- RESOLVED
1117711 [TaskTracer] Add marks from User Timing spec to task tracer labels -- RESOLVED
1118209 TaskTracer doesn't aware that profiler could be initialized multiple times -- RESOLVED
1118210 TaskTracer: FakeTracedTask created and used on different thread -- RESOLVED
1124972 TaskTracer: (Re-review bug 1100259) Add labels in EventDispatcher -- RESOLVED
1319669 Add more information/labels for TaskTracer. -- RESOLVED
1325526 Remove IPC message overhead for TaskTracer being disabled -- RESOLVED
1330244 TaskTracer task timestamps should use mozilla::TimeStamp and have the same precision + origin as profiler marker timestaps -- RESOLVED
1330246 TaskTracer labels should probably become profiler markers -- RESOLVED
1336004 build error in Sampler.cpp after enable Task Tracer -- RESOLVED

34 Total; 0 Open (0%); 34 Resolved (100%); 0 Verified (0%);

Reference links

TODO

  • Thread pool
  • CpuTime
  • Integrate with Cleopatra
  • Nested loop
  • Ruler