Skip to content

pprof

Decode Go, gperftools, Parca and py-spy pprof profiles into SQL rows for flamegraph diffs and CI performance-regression gates

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/pprof/index.md to help me query pprof 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.

See what you can query

Example output · captured
Connector release
v0.5.1
Engine
2.0.1
VGI protocol
3.4.0
SELECT fn, sum(cpu_ns) AS cpu_ns
FROM (SELECT frame[1].function AS fn, value[2] AS cpu_ns FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA=')) WHERE error IS NULL UNION ALL SELECT frame[1].function, value[2] FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQvU7DQAwHcO4jjXuJFKtCEDGgKFOUoZFu4hEYGJiZCKEqFW3u1GvF6ocAVhBCiIWhb9CdV2CCgYGZHd2J5W/7Z09WEhhyJUGgHKVKCM7wEOnutx4l4HcRbu83/ACBIRHxnGjLq+iIlRkwZDk9Ei/9XVpmwD08BeC4V2YgPDwHEFiXGUgPLwEkxrUChoN8UMSVqhVwhByKYbVbKxCoclUMq6pWIDHJkyKtIr2jY9cu7HzidNSZdb/SorNrnfRtb9ykM/2l06Nm7ZbN3HTtvLmY9U1rrR4u2lk/9qHj0E7Nv92Y5bWOfXpLg12Z1YkxVqsw2XbpJhpCGU/NMdHr5uvh+33/lG5/PsRZeN05vX1KK/4CAAD//2pKKrROAQAA')) WHERE error IS NULL)
GROUP BY fn
ORDER BY cpu_ns DESC, fn
LIMIT 20
Result
fn cpu_ns
main.hotLoop 120,000,000
main.parse 10,000,000

Quick start

Choose where to run pprof, 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 'pprof' AS pprof (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-pprof'
);

3. Run a query

query.sql
SELECT fn, sum(cpu_ns) AS cpu_ns
FROM (SELECT frame[1].function AS fn, value[2] AS cpu_ns FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA=')) WHERE error IS NULL UNION ALL SELECT frame[1].function, value[2] FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQvU7DQAwHcO4jjXuJFKtCEDGgKFOUoZFu4hEYGJiZCKEqFW3u1GvF6ocAVhBCiIWhb9CdV2CCgYGZHd2J5W/7Z09WEhhyJUGgHKVKCM7wEOnutx4l4HcRbu83/ACBIRHxnGjLq+iIlRkwZDk9Ei/9XVpmwD08BeC4V2YgPDwHEFiXGUgPLwEkxrUChoN8UMSVqhVwhByKYbVbKxCoclUMq6pWIDHJkyKtIr2jY9cu7HzidNSZdb/SorNrnfRtb9ykM/2l06Nm7ZbN3HTtvLmY9U1rrR4u2lk/9qHj0E7Nv92Y5bWOfXpLg12Z1YkxVqsw2XbpJhpCGU/NMdHr5uvh+33/lG5/PsRZeN05vX1KK/4CAAD//2pKKrROAQAA')) WHERE error IS NULL)
GROUP BY fn
ORDER BY cpu_ns DESC, fn
LIMIT 20
More example queries →
Technical details
Verified connector release
v0.5.1
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 'pprof' AS pprof (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Decode pprof (profile.proto) CPU/heap/alloc/mutex profiles into SQL rows for bulk profile diffing and CI performance-regression gates.

Catalog

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

pprof 1 schema
main 1 view · 6 functions

Decode pprof profiles into SQL rows: flattened flamegraph-ready stacks, the raw profile.proto graph, and profile metadata.

Schema examples (6)
Examples (6)

Top self-time functions summed across two CPU profiles (a baseline and a candidate run, passed inline as BLOBs; with profiles on disk, pass a path glob or a list of paths).

SELECT fn, sum(cpu_ns) AS cpu_ns
FROM (SELECT frame[1].function AS fn, value[2] AS cpu_ns FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA=')) WHERE error IS NULL UNION ALL SELECT frame[1].function, value[2] FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQvU7DQAwHcO4jjXuJFKtCEDGgKFOUoZFu4hEYGJiZCKEqFW3u1GvF6ocAVhBCiIWhb9CdV2CCgYGZHd2J5W/7Z09WEhhyJUGgHKVKCM7wEOnutx4l4HcRbu83/ACBIRHxnGjLq+iIlRkwZDk9Ei/9XVpmwD08BeC4V2YgPDwHEFiXGUgPLwEkxrUChoN8UMSVqhVwhByKYbVbKxCoclUMq6pWIDHJkyKtIr2jY9cu7HzidNSZdb/SorNrnfRtb9ykM/2l06Nm7ZbN3HTtvLmY9U1rrR4u2lk/9qHj0E7Nv92Y5bWOfXpLg12Z1YkxVqsw2XbpJhpCGU/NMdHr5uvh+33/lG5/PsRZeN05vX1KK/4CAAD//2pKKrROAQAA')) WHERE error IS NULL)
GROUP BY fn
ORDER BY cpu_ns DESC, fn
LIMIT 20;
Result
fn cpu_ns
main.hotLoop 120,000,000
main.parse 10,000,000

A heap profile's sample value types, sampling period, and duration.

SELECT sample_types, period, duration_nanos
FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA'))
WHERE error IS NULL;

Mappings that carry a build id (the binaries still to symbolize).

SELECT mapping_id, filename, build_id
FROM pprof.main.mappings(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA=='))
WHERE error IS NULL AND build_id IS NOT NULL;

Total a heap profile's default sample type (inuse_space) per leaf function, finding the value slot by name from pprof.main.meta instead of hard-coding value[N], so the same query works unchanged on a CPU profile (where it totals cpu).

WITH m AS (SELECT default_sample_type AS sample_type, list_position([t.type FOR t IN sample_types], default_sample_type) AS slot FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) WHERE error IS NULL) SELECT m.sample_type, s.frame[1].function AS fn, sum(s.value[m.slot]) AS total
FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) s,
     m
WHERE s.error IS NULL
GROUP BY ALL
ORDER BY total DESC, fn;
2 more examples

Hottest unsymbolized leaf addresses as symbolizer-ready (binary, build_id, offset in the binary) rows, weighted by CPU time: each sample's leaf location id is joined to pprof.main.locations and on to pprof.main.mappings.

SELECT m.filename AS binary_path, m.build_id,
  printf('0x%x', l.address - m.memory_start + m.file_offset) AS binary_offset,
  sum(s.value[2]) AS cpu_ns
FROM pprof.main.samples(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) s
JOIN pprof.main.locations(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) l ON l.location_id = s.location_ids[1]
JOIN pprof.main.mappings(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) m ON m.mapping_id = l.mapping_id
WHERE s.error IS NULL
GROUP BY ALL
ORDER BY cpu_ns DESC, binary_offset;

Show what the compiler inlined: for every location whose line table has more than one entry, name each function folded into that address (depth 1 = innermost) by joining the line table to pprof.main.functions.

WITH l AS (SELECT location_id, address, unnest(lines) AS ln, generate_subscripts(lines, 1) AS depth FROM pprof.main.locations(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) WHERE error IS NULL AND len(lines) > 1) SELECT l.location_id, l.address, l.depth, f.name AS function_name, f.filename, l.ln.line AS line
FROM l
JOIN pprof.main.functions(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) f ON f.function_id = l.ln.function_id
ORDER BY l.location_id, l.depth;
Views
sample_type_guide 1 example6 cols

Reference table of common pprof sample value-type conventions: which sample_type and unit each value[N] slot carries per (producer, profile_kind). VALUES-backed, so it scans with no file or credential.

Columns
producer VARCHAR
The profiler/runtime that emitted the profile (e.g. 'Go').
profile_kind VARCHAR
The kind of profile within that producer (e.g. 'cpu', 'heap', 'allocs', 'mutex', 'block').
value_index INTEGER
1-based position of this value in the sample's `value` list (value[value_index] in pprof.stacks / pprof.samples).
sample_type VARCHAR
The value type's name at this index, matching meta.sample_types[value_index].type.
unit VARCHAR
The unit the value is measured in (e.g. 'count', 'bytes', 'nanoseconds').
meaning VARCHAR
A plain-language description of what this value slot counts.
Example

Look up which value slot holds CPU time for a Go CPU profile (and in what unit).

SELECT value_index, sample_type, unit
FROM pprof.main.sample_type_guide
WHERE producer = 'Go' AND profile_kind = 'cpu'
ORDER BY value_index;
Link
Table functions
functions (src ANY) 3 examples

Decode a pprof profile's function table

Arguments
src ANY
Where to read the pprof profile(s) to decode. Pass a filesystem path to one gzip-wrapped or raw `profile.proto` file; a path containing glob wildcards such as '/profiles/*.pb.gz' expands to every match in sorted order. A LIST value is read as several such paths scanned together; a BLOB value is read as inline profile bytes. Each file is decoded on its own so that a profile which is absent or fails to decode becomes a single error row (data columns NULL, `file` and `error` set) instead of failing the scan.
Returns columns
function_id UBIGINT
The function's unique id within the profile (verbatim); referenced by pprof.locations.lines[].function_id.
name VARCHAR
Human-readable function name, or NULL if unset.
system_name VARCHAR
System/mangled function name (e.g. the C++ mangled symbol), or NULL if unset.
filename VARCHAR
Source file that contains the function, or NULL if unset.
start_line BIGINT
First source line of the function (0 if unknown).
file VARCHAR
Source path the row came from (NULL when the profile was passed as inline BLOB bytes).
error VARCHAR
NULL on success; otherwise this is an error row for a file that could not be read or decoded, with every data column NULL and the failure message here.
Examples (3)

List the functions defined in a profile.

SELECT function_id, name, filename, start_line
FROM pprof.main.functions(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY function_id;
SELECT function_id, name, filename, start_line
FROM pprof.main.functions(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY function_id
LIMIT 10;
SELECT filename, count(*) AS fns
FROM pprof.main.functions(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
GROUP BY filename
ORDER BY fns DESC, filename
LIMIT 5;
Link
locations (src ANY) 4 examples

Decode a pprof profile's location table

Arguments
src ANY
Where to read the pprof profile(s) to decode. Pass a filesystem path to one gzip-wrapped or raw `profile.proto` file; a path containing glob wildcards such as '/profiles/*.pb.gz' expands to every match in sorted order. A LIST value is read as several such paths scanned together; a BLOB value is read as inline profile bytes. Each file is decoded on its own so that a profile which is absent or fails to decode becomes a single error row (data columns NULL, `file` and `error` set) instead of failing the scan.
Returns columns
location_id UBIGINT
The location's unique id within the profile (verbatim); referenced by pprof.samples.location_ids.
address UBIGINT
Instruction address for this location (0 if unavailable); within its mapping's memory range.
mapping_id UBIGINT
Id of the pprof.mappings row this location belongs to (0 if unknown).
lines STRUCT(function_id UBIGINT, line BIGINT)[]
The line table, innermost inlined frame first; function_id joins to pprof.functions.function_id. Empty for an unsymbolized location.
file VARCHAR
Source path the row came from (NULL when the profile was passed as inline BLOB bytes).
error VARCHAR
NULL on success; otherwise this is an error row for a file that could not be read or decoded, with every data column NULL and the failure message here.
Examples (4)

Locations with their line table (inlined frames).

SELECT location_id, address, mapping_id, lines
FROM pprof.main.locations(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY location_id;

Show what the compiler inlined: for every location whose line table has more than one entry, name each function folded into that address (depth 1 = innermost) by joining the line table to pprof.main.functions.

WITH l AS (SELECT location_id, address, unnest(lines) AS ln, generate_subscripts(lines, 1) AS depth FROM pprof.main.locations(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) WHERE error IS NULL AND len(lines) > 1) SELECT l.location_id, l.address, l.depth, f.name AS function_name, f.filename, l.ln.line AS line
FROM l
JOIN pprof.main.functions(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) f ON f.function_id = l.ln.function_id
ORDER BY l.location_id, l.depth;
SELECT location_id, address, mapping_id, lines
FROM pprof.main.locations(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY location_id
LIMIT 10;
1 more example
SELECT location_id, address, len(lines) AS inline_depth
FROM pprof.main.locations(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY inline_depth DESC, location_id
LIMIT 5;
Link
mappings (src ANY) 2 examples

Decode a pprof profile's mapping table (build_id feeds vgi-symbols)

Arguments
src ANY
Where to read the pprof profile(s) to decode. Pass a filesystem path to one gzip-wrapped or raw `profile.proto` file; a path containing glob wildcards such as '/profiles/*.pb.gz' expands to every match in sorted order. A LIST value is read as several such paths scanned together; a BLOB value is read as inline profile bytes. Each file is decoded on its own so that a profile which is absent or fails to decode becomes a single error row (data columns NULL, `file` and `error` set) instead of failing the scan.
Returns columns
mapping_id UBIGINT
The mapping's unique id within the profile (verbatim); referenced by pprof.locations.mapping_id.
memory_start UBIGINT
Start of the address range the binary/library is loaded at.
memory_limit UBIGINT
Exclusive end of the loaded address range.
file_offset UBIGINT
Offset in the object file that corresponds to memory_start.
filename VARCHAR
Object the mapping is loaded from (a path, or a pseudo-name like '[vdso]'); NULL if unset.
build_id VARCHAR
Build id uniquely identifying the binary version, emitted verbatim so unresolved native frames can be symbolized downstream (vgi-symbols); NULL if unset.
file VARCHAR
Source path the row came from (NULL when the profile was passed as inline BLOB bytes).
error VARCHAR
NULL on success; otherwise this is an error row for a file that could not be read or decoded, with every data column NULL and the failure message here.
Examples (2)

List the mappings that carry a build_id (the binaries still to symbolize), from a native profile passed inline as BLOB bytes.

SELECT mapping_id, filename, build_id
FROM pprof.main.mappings(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA=='))
WHERE error IS NULL AND build_id IS NOT NULL;
SELECT mapping_id, filename, memory_start, memory_limit
FROM pprof.main.mappings(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY mapping_id;
Link
meta (src ANY) 3 examples

Decode a pprof profile's metadata (sample types, period, duration)

Arguments
src ANY
Where to read the pprof profile(s) to decode. Pass a filesystem path to one gzip-wrapped or raw `profile.proto` file; a path containing glob wildcards such as '/profiles/*.pb.gz' expands to every match in sorted order. A LIST value is read as several such paths scanned together; a BLOB value is read as inline profile bytes. Each file is decoded on its own so that a profile which is absent or fails to decode becomes a single error row (data columns NULL, `file` and `error` set) instead of failing the scan.
Returns columns
sample_types STRUCT(type VARCHAR, unit VARCHAR)[]
The value types each sample carries, in order; the Nth entry names value[N] in pprof.stacks / pprof.samples.
period BIGINT
Number of events between sampled occurrences (the sampling period).
period_type STRUCT(type VARCHAR, unit VARCHAR)
The kind of event the period counts (e.g. (cpu, nanoseconds)); NULL if unset.
duration_nanos BIGINT
Wall-clock duration the profile covers, in nanoseconds (0 if not meaningful).
time_nanos BIGINT
Collection time as nanoseconds since the Unix epoch (0 if unset).
default_sample_type VARCHAR
The preferred sample value type's name; NULL if unset.
file VARCHAR
Source path the row came from (NULL when the profile was passed as inline BLOB bytes).
error VARCHAR
NULL on success; otherwise this is an error row for a file that could not be read or decoded, with every data column NULL and the failure message here.
Examples (3)

Inspect a heap profile's sample value types and duration, from a profile passed inline as BLOB bytes.

SELECT sample_types, period, duration_nanos, default_sample_type
FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA'))
WHERE error IS NULL;
SELECT sample_types, duration_nanos, default_sample_type
FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA'))
WHERE error IS NULL;
SELECT period, period_type, duration_nanos
FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL;
Link
samples (src ANY) 3 examples

Decode a pprof profile's raw samples (location ids + values + labels)

Arguments
src ANY
Where to read the pprof profile(s) to decode. Pass a filesystem path to one gzip-wrapped or raw `profile.proto` file; a path containing glob wildcards such as '/profiles/*.pb.gz' expands to every match in sorted order. A LIST value is read as several such paths scanned together; a BLOB value is read as inline profile bytes. Each file is decoded on its own so that a profile which is absent or fails to decode becomes a single error row (data columns NULL, `file` and `error` set) instead of failing the scan.
Returns columns
sample_id BIGINT
1-based index of the sample within its profile; joins to pprof.stacks.sample_id.
location_ids UBIGINT[]
The sample's location ids, leaf first; each joins to pprof.locations.location_id.
value BIGINT[]
The sample's measured values, one BIGINT per meta.sample_types entry, in order.
labels MAP(VARCHAR, VARCHAR)
Sample labels; duplicate keys are de-duplicated (first wins).
file VARCHAR
Source path the row came from (NULL when the profile was passed as inline BLOB bytes).
error VARCHAR
NULL on success; otherwise this is an error row for a file that could not be read or decoded, with every data column NULL and the failure message here.
Examples (3)

Raw samples with their leaf location id.

SELECT sample_id, location_ids[1] AS leaf_loc, value
FROM pprof.main.samples(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL;

Hottest unsymbolized leaf addresses as symbolizer-ready (binary, build_id, offset in the binary) rows, weighted by CPU time: each sample's leaf location id is joined to pprof.main.locations and on to pprof.main.mappings.

SELECT m.filename AS binary_path, m.build_id,
  printf('0x%x', l.address - m.memory_start + m.file_offset) AS binary_offset,
  sum(s.value[2]) AS cpu_ns
FROM pprof.main.samples(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) s
JOIN pprof.main.locations(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) l ON l.location_id = s.location_ids[1]
JOIN pprof.main.mappings(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) m ON m.mapping_id = l.mapping_id
WHERE s.error IS NULL
GROUP BY ALL
ORDER BY cpu_ns DESC, binary_offset;
SELECT sample_id, labels, value
FROM pprof.main.samples(from_base64('H4sIAAAAAAAA/yyNMU7DQBBF2ckaxuugjNJgpbJcWSkIGiEELRVnoAn2skEgy468ThBUcxNaWm4Q0XIMCq6BvEn1Zt7X1zcaFYHROCI9nSKgIiESEZhpjOh4RoMRgVRkB8XJtconqEilshPIh3KTTxAG8R0EUDw3qAhTzOLicW4QyKQmSwrkIz4t67q1y7Z6cbb3HNl20/Sc7K1fl9ZxVL31zrPxz+9uaevSe9aXFzdXnCx8t114121dx+M9zwM4PnxPLdPhbNzr7Wa1ch3HVeAQRmHiTuTz6/fj7+fsXuOY9INIth79BwAA//+aqrQCCgEAAA=='))
WHERE error IS NULL
LIMIT 5;
Link
stacks (src ANY) 4 examples

Flatten a pprof profile into flamegraph-ready stack rows

Arguments
src ANY
Where to read the pprof profile(s) to decode. Pass a filesystem path to one gzip-wrapped or raw `profile.proto` file; a path containing glob wildcards such as '/profiles/*.pb.gz' expands to every match in sorted order. A LIST value is read as several such paths scanned together; a BLOB value is read as inline profile bytes. Each file is decoded on its own so that a profile which is absent or fails to decode becomes a single error row (data columns NULL, `file` and `error` set) instead of failing the scan.
Returns columns
sample_id BIGINT
1-based index of the sample within its profile; joins to pprof.samples.sample_id.
value BIGINT[]
The sample's measured values, one BIGINT per meta.sample_types entry, in that order (e.g. value[2] is cpu/nanoseconds for a Go CPU profile).
labels MAP(VARCHAR, VARCHAR)
Sample labels; duplicate keys are de-duplicated (first wins).
frame STRUCT of 4 fields[]
The call stack, leaf first; inlined frames expanded, unsymbolized frames keep their address. frame[1] is the leaf (self) frame.
STRUCT[] 4 fields
  • functionVARCHAR
  • filenameVARCHAR
  • lineBIGINT
  • addressUBIGINT
file VARCHAR
Source path the row came from (NULL when the profile was passed as inline BLOB bytes).
error VARCHAR
NULL on success; otherwise this is an error row for a file that could not be read or decoded, with every data column NULL and the failure message here.
Examples (4)

Flatten a profile passed inline as BLOB bytes (self-contained): each sample's leaf frame and per-type values.

SELECT sample_id, frame[1].function AS leaf, value
FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL;

Top self-time functions in a CPU profile (value[2] = cpu/nanoseconds).

SELECT frame[1].function AS fn, sum(value[2]) AS cpu_ns
FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
GROUP BY 1
ORDER BY 2 DESC
LIMIT 20;

Total a heap profile's default sample type (inuse_space) per leaf function, finding the value slot by name from pprof.main.meta instead of hard-coding value[N], so the same query works unchanged on a CPU profile (where it totals cpu).

WITH m AS (SELECT default_sample_type AS sample_type, list_position([t.type FOR t IN sample_types], default_sample_type) AS slot FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) WHERE error IS NULL) SELECT m.sample_type, s.frame[1].function AS fn, sum(s.value[m.slot]) AS total
FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) s,
     m
WHERE s.error IS NULL
GROUP BY ALL
ORDER BY total DESC, fn;
1 more example
SELECT fn, sum(cpu_ns) AS cpu_ns
FROM (SELECT frame[1].function AS fn, value[2] AS cpu_ns FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA=')) WHERE error IS NULL UNION ALL SELECT frame[1].function, value[2] FROM pprof.main.stacks(from_base64('H4sIAAAAAAAA/yzQvU7DQAwHcO4jjXuJFKtCEDGgKFOUoZFu4hEYGJiZCKEqFW3u1GvF6ocAVhBCiIWhb9CdV2CCgYGZHd2J5W/7Z09WEhhyJUGgHKVKCM7wEOnutx4l4HcRbu83/ACBIRHxnGjLq+iIlRkwZDk9Ei/9XVpmwD08BeC4V2YgPDwHEFiXGUgPLwEkxrUChoN8UMSVqhVwhByKYbVbKxCoclUMq6pWIDHJkyKtIr2jY9cu7HzidNSZdb/SorNrnfRtb9ykM/2l06Nm7ZbN3HTtvLmY9U1rrR4u2lk/9qHj0E7Nv92Y5bWOfXpLg12Z1YkxVqsw2XbpJhpCGU/NMdHr5uvh+33/lG5/PsRZeN05vX1KK/4CAAD//2pKKrROAQAA')) WHERE error IS NULL)
GROUP BY fn
ORDER BY cpu_ns DESC, fn
LIMIT 20;
Result
fn cpu_ns
main.hotLoop 120,000,000
main.parse 10,000,000
Link

Try these queries

A heap profile's sample value types, sampling period, and duration.

SELECT sample_types, period, duration_nanos
FROM pprof.main.meta(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA'))
WHERE error IS NULL

Uses meta

Mappings that carry a build id (the binaries still to symbolize).

SELECT mapping_id, filename, build_id
FROM pprof.main.mappings(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA=='))
WHERE error IS NULL AND build_id IS NOT NULL

Uses mappings

Hottest unsymbolized leaf addresses as symbolizer-ready (binary, build_id, offset in the binary) rows, weighted by CPU time: each sample's leaf location id is joined to pprof.main.locations and on to pprof.main.mappings.

SELECT m.filename AS binary_path, m.build_id,
  printf('0x%x', l.address - m.memory_start + m.file_offset) AS binary_offset,
  sum(s.value[2]) AS cpu_ns
FROM pprof.main.samples(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) s
JOIN pprof.main.locations(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) l ON l.location_id = s.location_ids[1]
JOIN pprof.main.mappings(from_base64('H4sIAAAAAAAA/+Ji4WAUYOJi4WAWYBHi5mDkYBLgEWiYM8dSiJuDmYNRgF2gYfcGRSkhDkaBhoaGFawSDQ0tK1g1WA3YpMQ4mEBiDQ0P5CUaGg6AaA12Aw4lLg5GAUaJBR0NK1iVeDiYBJgktiwBq1Li4mAWYJRYPbFhBasRgxF7cWJuQU5qsRFrcn5pXokRc3JBqRF3XmJefnFqcn5eSrGRgH5+QYl+cVmyflJmHog24kk0TDJKNk4xSTVNMzOS18/JTNKvsDCLNzPRzcnMK63QTc8rBQkm6xXn65kZ8aSkJqYkpaamJSempXo0NKzY+Hj+89PiAQ2ntr5jjAJ7OqFh7SOWAgZAAAAA//9plBkzCAEAAA==')) m ON m.mapping_id = l.mapping_id
WHERE s.error IS NULL
GROUP BY ALL
ORDER BY cpu_ns DESC, binary_offset

Uses sampleslocationsmappings

Show what the compiler inlined: for every location whose line table has more than one entry, name each function folded into that address (depth 1 = innermost) by joining the line table to pprof.main.functions.

WITH l AS (SELECT location_id, address, unnest(lines) AS ln, generate_subscripts(lines, 1) AS depth FROM pprof.main.locations(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) WHERE error IS NULL AND len(lines) > 1) SELECT l.location_id, l.address, l.depth, f.name AS function_name, f.filename, l.ln.line AS line
FROM l
JOIN pprof.main.functions(from_base64('H4sIAAAAAAAA/zyMMU6EQBSGndlh9+0A+rKJES0MUhEKSV4sLI2VZ7DRAUeDIhCBwu7dRGNl6w3sPYaF1zAMxmbyzf++fFqBQKkVLFBpBZ7jJarNNkgQG7hhPkuZ9w8QBDKzjJg/Zbo6FckOCBQRv7JMpkiQ7IKchjc3LPAkUSDxKNMgECKI16nONEjUkY799DDTsMAgCmI/Jdqi0NR1W161xb0th568sh2bgfx57TtTWvKK58H2FFbN2Nt/05+/s7LJx/4pr9vS1HlRNbnpOlo/mqo5nh5aObxrKXTg4mawBI6mQ/AnP9jz8ZY8V71gfv/4fvn52rtUEKK6Zo675W8AAAD//wt6pw46AQAA')) f ON f.function_id = l.ln.function_id
ORDER BY l.location_id, l.depth

Uses locationsfunctions

Look up which value slot holds CPU time for a Go CPU profile (and in what unit).

SELECT value_index, sample_type, unit
FROM pprof.main.sample_type_guide
WHERE producer = 'Go' AND profile_kind = 'cpu'
ORDER BY value_index

Uses sample_type_guide

List the functions defined in a profile.

SELECT function_id, name, filename, start_line
FROM pprof.main.functions(from_base64('H4sIAAAAAAAA/yzQPU7rQBAH8Lcfjidr63kUIbAokOXKchFLW3EECgpqKoyJQkTiXWUT0U7HBRAtCCGgocgN0nMFKigouATaFc1/Zn4z1SgJDLmSIFCOUiUEZ3iAdPPyf5SA30W4vdvwfQSGRMRzoi2vokNWZsCQ5fRAvPR3aZkB9/AYgONumYHw8BRAYF1mID08B5AY1woYDvJBEVeqVsARciiG1U6tQKDKVTGsqlqBxCRPirSK9D8du3Zh5xOno86s+5UWnV3rpG974yad6S+cHjVrt2zmpmvnzfmsb1pr9XDRzvqxDx2Hdmr+7Nosr3Ts01sa7NKsjo2xWoXJtks30RDKeGqOiF43X/ff73sndPvzIU7D687o7VNa8RsAAP//CRIJN04BAAA='))
WHERE error IS NULL
ORDER BY function_id;

Uses functions

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

pprof 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.