Parse and analyse data from Linux ftrace.
This tool helps to parse the traces from the Linux kernel, and help to analyse using custom queries.
- trace is a good method of identifying performance problems
- Manually analysing and walking through the huge traces is a pain
- Simple parsing tool can help simplying the process by getting specific information in matter of seconds
- Specific tracepoints can be turned on or off, which require lot of parsing tools for a specific job
- Combining and getting them under a common umbrella for wider reach and reusability is needed.
- ftrace is a key tracing infrastructure on Linux.
A partial list
- Process runtimes
- System call time by Process
- Process CPU migration history
- Locks
- Interrupts
- CPU idle time
Uses a python regular expression to parse the ftrace file and extract useful
information and stores in a sqlite
database. What data to extract and how to
save is described in a config file. The config file is in JSON format.
A JSON based config file, which contains what to ’grep’ for and what to data to collect and store Based on the config file, tables are created in a sqlite database, which is convinient for repeated queries, otherwise which takes minutes to parse a normal trace file.
The queries in the config file are basic SQL statements.
$ sudo python setup.py install
$ traceworks [OPTION]... [dbfile] [tracefile]
$ traceworks [-h] [--type TYPE] [--query QUERY [QUERY ...]] [--qargs QARGS [QARGS ...]] [--list] [--generate] [--debug] [--verbose] [--logfile LOGFILE] [--config CONFIG] [--version] [tracefile] [dbfile]
- tracefile - ftrace file (default: None)
- sqlite3 database file (default: tracedump.db)
−h, −−help
show this help message and exit
−t, −−type
Top level type from the config file (default: ftrace)
−−query QUERY [QUERY ...], −q QUERY [QUERY ...]
the query number to run (default: None)
−−qargs QARGS [QARGS ...], −a QARGS [QARGS ...]
arguments to the query if any (default: None)
−−list, −l
List all the available queries (default: False)
−−generate, −g
Store data in database from tracefile (default: False)
−−debug, −d
Print debug information (default: False)
−−verbose, −v
Increase output verbosity (default: False)
−−logfile LOGFILE, −f LOGFILE
Save all logging and debug information to this file (default: None)
−−config CONFIG, −c CONFIG
JSON config file (default: traceconfig.json)
−−version
show program’s version number and exit
$ traceworks -g tracefile
$ traceworks -l
1. process names (Map process names and PIDs)
2. cpuidle (List idle times of each CPU)
3. syscall duration for a pid (List time taken by each syscall for a process)
Requires the following 1 argument(s)
1. pid
4. syscall duration (List time taken by each syscall)
5. syscall duration by cpu (List the time taken by each system call on each CPU)
6. Top n syscalls (List the top n syscalls that consume cpu time)
Requires the following 1 argument(s)
1. number
Query context switches
$ traceworks -q 2
The unit of time is microseconds
================================
cpu idle_time context_switches
----- ----------- ------------------
0 3060257 587
1 3200971 354
2 3763700 1215
3 4295133 938
Anybody is welcome to contribute to the project. Some general rules to contribution are: