linux-perf: Read files generated by perf on Linux
This library is for parsing, representing in Haskell and pretty printing
the data file output of the Linux perf
command.
The perf
command provides performance profiling information for
applications running under the Linux operating system. This information
includes hardware performance counters and kernel tracepoints.
Modern CPUs can provide information about the runtime behaviour
of software through so-called hardware performance counters
http://en.wikipedia.org/wiki/Hardware_performance_counter.
Recent versions of
the Linux kernel (since 2.6.31) provide a generic interface
to low-level events for running processes.
This includes access to hardware counters but also a wide array
of software events such as page faults,
scheduling activity and system calls. A userspace tool called perf
is built on top of the kernel interface,
which provides a convenient way to record and view events
for running processes.
The perf
tool has many sub-commands which do a variety of things,
but in general it has two main purposes:
Recording events.
Displaying events.
The perf record
command records information about performance
events in a file called (by default) perf.data
.
It is a binary file format which is basically a memory dump
of the data structures used to record event information.
The file has two main parts:
A header which describes the layout of information in the file (section sizes, etcetera) and common information about events in the second part of the file (an encoding of event types and their names).
The payload of the file which is a sequence of event records.
Each event field has a header which says what general type of event it is plus information about the size of its body.
There are nine types of event:
PERF_RECORD_MMAP
: memory map event.PERF_RECORD_LOST
: an unknown event.PERF_RECORD_COMM
: maps a command name string to a process and thread ID.PERF_RECORD_EXIT
: process exit.PERF_RECORD_THROTTLE
:PERF_RECORD_UNTHROTTLE
:PERF_RECORD_FORK
: process creation.PERF_RECORD_READ
:PERF_RECORD_SAMPLE
: a sample of an actual hardware counter or a software event.
The PERF_RECORD_SAMPLE
events (samples) are the most interesting
ones in terms of program profiling. The other events
seem to be mostly useful for keeping track of process technicalities.
Samples are timestamped with an unsigned 64 bit
word, which records elapsed nanoseconds since some point in time
(system running time, based on the kernel scheduler clock).
Samples have themselves a type which is defined
in the file header and linked to the sample by an integer identifier.
Below is an example program which reads a perf.data
file and prints out
the number of events that it contains.
module Main where import Profiling.Linux.Perf (readPerfData) import Profiling.Linux.Perf.Types (PerfData (..)) import System.Environment (getArgs) main :: IO () main = do args <- getArgs case args of [] -> return () (file:_) -> do perfData <- readPerfData file print $ length $ perfData_events perfData
[Skip to Readme]
Modules
[Index]
Downloads
- linux-perf-0.3.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.3 |
---|---|
Dependencies | base (>=4 && <5), binary (>=0.5 && <0.7), bytestring (>=0.9), containers (>=0.4 && <0.6), directory (>=1.1 && <2), filepath (>=1.2 && <2), ghc-events (>=0.4.2), linux-perf (>=0.2), mtl (>=2 && <3), pretty (>=1 && <2), process (>=1.1 && <1.2), unix (>=2.5 && <2.7) [details] |
License | BSD-3-Clause |
Author | Simon Marlow, Bernie Pope, Mikolaj Konarski, Duncan Coutts |
Maintainer | Bernie Pope <florbitous@gmail.com> |
Category | Development, GHC, Debug, Profiling, Trace |
Home page | https://github.com/bjpop/haskell-linux-perf |
Bug tracker | https://github.com/bjpop/haskell-linux-perf/issues |
Source repo | head: git clone git://github.com/bjpop/haskell-linux-perf.git |
Uploaded | by MikolajKonarski at 2012-11-03T10:14:13Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Executables | count-events, ghc-events-perf, ghc-events-perf-sync, ghc-events-perf-record, dump-perf |
Downloads | 1357 total (8 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |