Skip to content

Perf

Decode Linux perf.data captures into SQL tables of samples, memory mappings, and event metadata for bulk profile analysis

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/perf/index.md to help me query Perf with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find the files consuming the most CPU samples

Replace /data/perf.data with the path to a perf recording on the machine running the connector.

SELECT m.filename, count(*) AS hits
FROM perf.main.samples('/data/perf.data') s
JOIN perf.main.mmaps('/data/perf.data') m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
GROUP BY m.filename
ORDER BY hits DESC, m.filename

Quick start

Choose where to run Perf, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'perf' AS perf (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-perf'
);

3. Run a query

query.sql
SELECT m.filename, count(*) AS hits
FROM perf.main.samples('/data/perf.data') s
JOIN perf.main.mmaps('/data/perf.data') m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
GROUP BY m.filename
ORDER BY hits DESC, m.filename
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'perf' AS perf (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Decode the Linux perf.data binary profiling format into SQL tables: samples (with raw call chains), memory mappings (with build-ids), comm records, event attributes, and capture metadata.

Catalog

Everything perf exposes once attached — read straight from the worker's released build.

perf 1 schema
main 1 view · 5 functions

perf.data decode functions: samples, mmaps, comms, events, meta.

Schema examples (8)
Examples (8)

Read the capture-wide metadata (one row).

SELECT hostname, arch, nrcpus, perf_version, cmdline, total_events
FROM perf.main.meta('/data/perf.data');

List the events the capture sampled and how.

SELECT name, type, sample_period, sample_freq
FROM perf.main.events('/data/perf.data')
ORDER BY name;

The first ten samples with their raw call chains.

SELECT time, pid, ip, callchain
FROM perf.main.samples('/data/perf.data')
ORDER BY time
LIMIT 10;

Every mapped DSO and its build-id (the vgi-symbols input).

SELECT filename, build_id
FROM perf.main.mmaps('/data/perf.data')
WHERE build_id IS NOT NULL
ORDER BY filename;
4 more examples

Hottest mapped files: sample ips range-joined to mmaps.

SELECT m.filename, count(*) AS hits
FROM perf.main.samples('/data/perf.data') s
JOIN perf.main.mmaps('/data/perf.data') m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
GROUP BY m.filename
ORDER BY hits DESC, m.filename;

Hot mapped files per process name: samples range-joined to mmaps, labelled with each pid's latest command name from comms (exec renames keep the newest), with hits and total sample period.

WITH names AS (SELECT pid, arg_max(comm, coalesce(time, 0)) AS comm FROM perf.main.comms('/data/perf.data') GROUP BY pid) SELECT n.comm, m.filename, count(*) AS hits, sum(s.period) AS total_period
FROM perf.main.samples('/data/perf.data') s
JOIN perf.main.mmaps('/data/perf.data') m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
LEFT JOIN names n ON n.pid = s.pid
GROUP BY n.comm, m.filename
ORDER BY hits DESC, m.filename;

Self vs inclusive samples per mapped file: unnest every call-chain frame, range-join it to mmaps, and count samples whose leaf ip is in the file (self) vs samples with any frame in it (inclusive).

WITH s AS (SELECT row_number() OVER () AS sample_id, pid, ip, callchain FROM perf.main.samples('/data/perf.data') WHERE callchain IS NOT NULL), frames AS (SELECT sample_id, pid, ip, unnest(callchain) AS frame FROM s) SELECT m.filename, count(DISTINCT f.sample_id) FILTER (WHERE f.frame = f.ip) AS self_samples, count(DISTINCT f.sample_id) AS inclusive_samples
FROM frames f
JOIN perf.main.mmaps('/data/perf.data') m ON f.pid = m.pid AND f.frame >= m.addr AND f.frame < m.addr + m.len
GROUP BY m.filename
ORDER BY inclusive_samples DESC, m.filename;

Symbolication input for vgi-symbols: each sampled ip's DSO build-id and file offset (ip - addr + pgoff), with hit counts.

SELECT m.filename, m.build_id, s.ip - m.addr + m.pgoff AS file_offset,
  count(*) AS hits
FROM perf.main.samples('/data/perf.data') s
JOIN perf.main.mmaps('/data/perf.data') m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
WHERE m.build_id IS NOT NULL
GROUP BY m.filename, m.build_id, file_offset
ORDER BY hits DESC, m.filename, file_offset;
Views
functions 1 example5 cols

Browsable reference of the perf worker's decode functions — one row per object, with the columns it returns. Browse it to discover the surface before decoding a capture.

Columns
object_name VARCHAR
The function name to call, e.g. `samples`, `mmaps`, `meta`.
object_kind VARCHAR
The kind of object — always `table function` here (each decodes a capture into rows).
category VARCHAR
The navigation category the object belongs to (Profile Samples, Address Space, Capture Context).
summary VARCHAR
A one-line description of what the function decodes / returns.
result_columns VARCHAR
Comma-separated list of the columns the function returns.
Example

List the decode table functions and the columns each one returns.

SELECT object_name, result_columns
FROM perf.main.functions
WHERE object_kind = 'table function'
ORDER BY object_name;
Link
Table functions
comms (src ANY) 2 examples

Decode perf.data process/thread name (COMM) records into rows

Arguments
src ANY
The perf.data capture to decode: either a filesystem path to a perf.data file, or the raw perf.data bytes themselves (e.g. a capture already loaded into a column). It is read as a sequential binary event stream.
Returns columns
pid INTEGER
Process id this name applies to.
tid INTEGER
Thread id this name applies to.
comm VARCHAR
The command / thread name.
time UBIGINT
Record timestamp; NULL if not recorded.
Examples (2)

The distinct process/thread names in a capture, one row per pid — the lookup that turns a numeric pid from `samples` into a human-readable command.

SELECT DISTINCT pid, comm
FROM perf.main.comms(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000'))
ORDER BY pid;

Hot mapped files per process name: samples range-joined to mmaps, labelled with each pid's latest command name from comms (exec renames keep the newest), with hits and total sample period.

WITH names AS (SELECT pid, arg_max(comm, coalesce(time, 0)) AS comm FROM perf.main.comms(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) GROUP BY pid) SELECT n.comm, m.filename, count(*) AS hits, sum(s.period) AS total_period
FROM perf.main.samples(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) s
JOIN perf.main.mmaps(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
LEFT JOIN names n ON n.pid = s.pid
GROUP BY n.comm, m.filename
ORDER BY hits DESC, m.filename;
Link
events (src ANY) 1 example

Decode perf.data event attributes (name, type, sampling policy) into rows

Arguments
src ANY
The perf.data capture to decode: either a filesystem path to a perf.data file, or the raw perf.data bytes themselves (e.g. a capture already loaded into a column). It is read as a sequential binary event stream.
Returns columns
event_id UBIGINT
Primary event id, or the attribute index.
name VARCHAR
Event name, e.g. 'cycles'.
type VARCHAR
Event kind: 'hardware', 'software', 'tracepoint', 'hw_cache', 'breakpoint', or 'dynamic_pmu'.
config UBIGINT
Tracepoint/dynamic-PMU integer config; NULL for hardware/software/hw_cache/breakpoint.
sample_period UBIGINT
Fixed sampling period; NULL if frequency-sampled.
sample_freq UBIGINT
Target samples/sec; NULL if period-sampled.
Example

The events a capture sampled, with each event's kind and its fixed sampling period (or target frequency).

SELECT name, type, sample_period, sample_freq
FROM perf.main.events(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000'))
ORDER BY name;
Link
meta (src ANY) 1 example

Decode perf.data capture-wide metadata (host, arch, cmdline, …) into one row

Arguments
src ANY
The perf.data capture to decode: either a filesystem path to a perf.data file, or the raw perf.data bytes themselves (e.g. a capture already loaded into a column). It is read as a sequential binary event stream.
Returns columns
hostname VARCHAR
Capture host name; NULL if absent.
arch VARCHAR
Machine architecture, e.g. 'x86_64'; NULL if absent.
nrcpus UINTEGER
CPUs available on the capture host; NULL if absent.
perf_version VARCHAR
perf tool version; NULL if absent.
cmdline VARCHAR[]
The 'perf record' command line, split into arguments; NULL if absent.
total_events UBIGINT
Count of event records in the data section.
Example

Read the capture-wide metadata of a perf.data file (exactly one row): host, arch, tool version, and the total event-record count.

SELECT hostname, arch, nrcpus, perf_version, cmdline, total_events
FROM perf.main.meta(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000'));
Link
mmaps (src ANY) 3 examples

Decode perf.data memory mappings (with build-ids) into rows

Arguments
src ANY
The perf.data capture to decode: either a filesystem path to a perf.data file, or the raw perf.data bytes themselves (e.g. a capture already loaded into a column). It is read as a sequential binary event stream.
Returns columns
pid INTEGER
Process id the mapping belongs to.
tid INTEGER
Thread id the mapping belongs to.
addr UBIGINT
Start address of the mapping.
len UBIGINT
Length in bytes; the mapping covers [addr, addr+len).
pgoff UBIGINT
Offset into the mapped file.
filename VARCHAR
Mapped file path, e.g. '/usr/lib/libc.so.6'.
build_id VARCHAR
DSO build-id (lowercase hex); NULL if unknown.
Examples (3)

Mapped DSOs with a known build-id (for vgi-symbols).

SELECT filename, build_id
FROM perf.main.mmaps(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000'))
WHERE build_id IS NOT NULL
ORDER BY filename;

Hottest mapped files: sample ips range-joined to mmaps.

SELECT m.filename, count(*) AS hits
FROM perf.main.samples(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) s
JOIN perf.main.mmaps(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
GROUP BY m.filename
ORDER BY hits DESC, m.filename;

Symbolication input for vgi-symbols: each sampled ip's DSO build-id and file offset (ip - addr + pgoff), with hit counts.

SELECT m.filename, m.build_id, s.ip - m.addr + m.pgoff AS file_offset,
  count(*) AS hits
FROM perf.main.samples(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) s
JOIN perf.main.mmaps(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
WHERE m.build_id IS NOT NULL
GROUP BY m.filename, m.build_id, file_offset
ORDER BY hits DESC, m.filename, file_offset;
Link
samples (src ANY) 3 examples

Decode perf.data profiling samples (with raw call chains) into rows

Arguments
src ANY
The perf.data capture to decode: either a filesystem path to a perf.data file, or the raw perf.data bytes themselves (e.g. a capture already loaded into a column). It is read as a sequential binary event stream.
Returns columns
time UBIGINT
Capture timestamp (perf clock, nanoseconds); NULL if not recorded.
pid INTEGER
Process id the sample was taken in.
tid INTEGER
Thread id the sample was taken in.
cpu UINTEGER
CPU the sample was taken on; NULL if not recorded.
ip UBIGINT
Raw (unsymbolicated) instruction pointer.
period UBIGINT
Sample period at the time of the sample.
event VARCHAR
Event name, e.g. 'cycles'.
callchain UBIGINT[]
Raw IP frames, innermost to outermost; NULL if no call chains.
Examples (3)

The ten most frequent raw instruction pointers in a capture — the hottest addresses, pre-symbolication.

SELECT ip, count(*) AS hits
FROM perf.main.samples(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000'))
GROUP BY ip
ORDER BY hits DESC
LIMIT 10;

The deepest call chains: each sample's leaf ip and how many frames its stack carries.

SELECT ip, length(callchain) AS depth
FROM perf.main.samples(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000'))
WHERE callchain IS NOT NULL
ORDER BY depth DESC, ip
LIMIT 10;

Self vs inclusive samples per mapped file: unnest every call-chain frame, range-join it to mmaps, and count samples whose leaf ip is in the file (self) vs samples with any frame in it (inclusive).

WITH s AS (SELECT row_number() OVER () AS sample_id, pid, ip, callchain FROM perf.main.samples(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) WHERE callchain IS NOT NULL), frames AS (SELECT sample_id, pid, ip, unnest(callchain) AS frame FROM s) SELECT m.filename, count(DISTINCT f.sample_id) FILTER (WHERE f.frame = f.ip) AS self_samples, count(DISTINCT f.sample_id) AS inclusive_samples
FROM frames f
JOIN perf.main.mmaps(from_hex('50455246494c45326800000000000000400000000000000068000000000000004000000000000000a800000000000000a00100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000a00f000000000000a70100000000000000000000000000000000000000000000000000000000000000000000000000000300000002001800d2040000d20400006c6f6f70000000000a00000002405800d2040000d204000000004000000000000010000000000000000000000000000014000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00000000000000002f7573722f62696e2f6c6f6f700000000a00000002406000d2040000d204000000000000007f00000000200000000000000000000000000014000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000002f7573722f6c69622f6c6962632e736f2e3600000000000009000000020048000001400000000000d2040000d2040000e8030000000000000200000000000000a00f000000000000020000000000000000014000000000005000400000000000090000000200480000010000007f0000d2040000d2040000d0070000000000000200000000000000a00f000000000000020000000000000000010000007f0000000140000000000009000000020040000001400000000000d2040000d2040000b80b0000000000000300000000000000a00f00000000000001000000000000000001400000000000')) m ON f.pid = m.pid AND f.frame >= m.addr AND f.frame < m.addr + m.len
GROUP BY m.filename
ORDER BY inclusive_samples DESC, m.filename;
Link

Try these queries

Read the capture-wide metadata (one row).

SELECT hostname, arch, nrcpus, perf_version, cmdline, total_events
FROM perf.main.meta('/data/perf.data')

Uses meta

List the events the capture sampled and how.

SELECT name, type, sample_period, sample_freq
FROM perf.main.events('/data/perf.data')
ORDER BY name

Uses events

The first ten samples with their raw call chains.

SELECT time, pid, ip, callchain
FROM perf.main.samples('/data/perf.data')
ORDER BY time
LIMIT 10

Uses samples

Every mapped DSO and its build-id (the vgi-symbols input).

SELECT filename, build_id
FROM perf.main.mmaps('/data/perf.data')
WHERE build_id IS NOT NULL
ORDER BY filename

Uses mmaps

Hot mapped files per process name: samples range-joined to mmaps, labelled with each pid's latest command name from comms (exec renames keep the newest), with hits and total sample period.

WITH names AS (SELECT pid, arg_max(comm, coalesce(time, 0)) AS comm FROM perf.main.comms('/data/perf.data') GROUP BY pid) SELECT n.comm, m.filename, count(*) AS hits, sum(s.period) AS total_period
FROM perf.main.samples('/data/perf.data') s
JOIN perf.main.mmaps('/data/perf.data') m ON s.pid = m.pid AND s.ip >= m.addr AND s.ip < m.addr + m.len
LEFT JOIN names n ON n.pid = s.pid
GROUP BY n.comm, m.filename
ORDER BY hits DESC, m.filename

Uses commssamplesmmaps

List the decode table functions and the columns each one returns.

SELECT object_name, result_columns
FROM perf.main.functions
WHERE object_kind = 'table function'
ORDER BY object_name

Uses functions

12 more examples in the Catalog, each listed under the table or function it uses.

Perf is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.