SQLite β steady-state query execution SimPoint traces
DynamoRIO (drmemtrace) SimPoint traces of SQLite 3.53.4 executing queries against an already-populated on-disk database. Database creation, schema initialization and dataset loading are deliberately not in these traces.
| Traces | 4 SimPoints |
| Instructions per trace | 120,000,000 fetched (60M warmup chunk + 60M SimPoint chunk) |
| Format | drmemtrace offline trace (encoded), one .zip per SimPoint |
| Threads | 1 |
| System calls in traced region | 0 |
| Total size | 870 MB |
Recommended Scarab --inst_limit |
120000000 |
sqlite/
βββ README.md this file
βββ README_RELEASE.md release notes, layout, PC->source instructions
βββ RELEASE_MANIFEST.json per-SimPoint segment / cluster / weight / sha256
βββ SHA256SUMS checksums for every file
βββ trace_clustering_info.json segment size, warmup chunks, flow, excluded phases
βββ fingerprint/ BBV fingerprint (bbfp, inscount, pcmap, pieces/)
βββ simpoints/ SimPoint 3.2 output + selection/substitution record
βββ traces_simp/
β βββ trace/{12,22,27,54}.zip the traces
β βββ bin/ modules.log + the module images it references
βββ validation/ counts, zip/invariant checks, steady-state evidence
βββ workload/ workload description, driver sources, scripts
The application
SQLite is an embedded relational database β the query engine runs in-process, so a trace of the client is a trace of the database. Nothing is CPU-idle waiting on a server.
- Source: official amalgamation
sqlite-amalgamation-3530400.zipfrom https://www.sqlite.org/2026/ - Version 3.53.4, source id
2026-07-24 19:02:57 bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc sqlite3.csha256b1dd5d74ec7f29055a6684fa06fb3c2f6821c87dd38f9a458dfd2e8a1db28189- Built with
gcc -O2 -g -no-pie -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_MAX_MMAP_SIZE=4294967296
-no-pie is deliberate: it makes runtime PCs in the trace equal link-time
addresses, so they map straight back to source.
The dataset
Synthetic, generated by the untraced setup binary (workload/src/sqlite_setup.c)
with a fixed LCG seed, so it is reproducible bit-for-bit:
CREATE TABLE records(
id INTEGER PRIMARY KEY, -- 1 .. 3,000,000, dense
k INTEGER NOT NULL, -- scattered over [0, 6,000,000), ~1.27 rows/key
v0 INTEGER NOT NULL,
v1 INTEGER NOT NULL,
payload TEXT NOT NULL); -- 64 bytes
CREATE INDEX idx_k ON records(k);
ANALYZE;
3,000,000 rows, 4 KiB pages, 302 MB database file. k is scattered so the
secondary index imposes a different B-tree order than the rowid table, making
index lookups a genuine second descent plus a rowid seek rather than a
sequential walk.
Connection settings for the traced process: SQLITE_OPEN_READONLY,
PRAGMA query_only=ON, PRAGMA locking_mode=EXCLUSIVE,
PRAGMA mmap_size=2GiB, PRAGMA cache_size=-524288.
locking_mode=EXCLUSIVE takes the shared file lock once instead of fcntl()-ing
on every implicit read transaction β without it two syscalls per query dominate
the profile and bury the B-tree work. mmap_size covers the whole database, so
page reads are served from the mapping and there is no long page-cache warm-up
phase to pollute clustering.
Query mix
Three rounds of four read-only query phases, all issued from statements
prepared once and sqlite3_reset() per iteration:
| phase | query | per round | exercises |
|---|---|---|---|
| 1 | SELECT v0,v1,payload FROM records WHERE id = ? |
60,000 | rowid B-tree descent, record lookup |
| 2 | SELECT id,v0 FROM records INDEXED BY idx_k WHERE k = ? |
50,000 | index B-tree descent + rowid table seek, key comparison |
| 3 | SELECT id,v0,v1 FROM records WHERE id BETWEEN ? AND ? (64 rows) |
4,900 | cursor movement across leaf pages, cell parsing |
| 4 | SELECT id,k FROM records INDEXED BY idx_k WHERE k BETWEEN ? AND ? |
5,000 | covering-index cursor movement, record compare |
Whole traced run: 3,383,340,000 fetched instructions.
How the excluded phases were excluded
The workload is split into two separate binaries, so no excluded-phase code path is even reachable from the traced process:
| binary | phase | traced |
|---|---|---|
sqlite_setup |
database file allocation, CREATE TABLE, CREATE INDEX, schema initialization, bulk INSERT of 3M rows, ANALYZE |
no |
sqlite_query |
steady-state query execution against the existing database | yes |
sqlite_query contains no DDL and no DML. Its only non-query work is
sqlite3_open_v2() plus four sqlite3_prepare_v2() calls: 480,604
instructions, measured on a query-free run. That is 0.014% of the traced run
and under 1% of a single fingerprint segment. The earliest released SimPoint
region starts 660,000,000 instructions in, so none of it appears in any trace.
Collection method
Flow: cluster_then_trace β fingerprint natively, cluster, then capture one
DynamoRIO trace per selected SimPoint. This matches
scarab-infra/common/scripts/run_simpoint_trace.py and avoids materializing a
~16 GB whole-run trace.
Fingerprint.
drrun -disable_traces -max_bb_instrs 256 -opt_cleancall 2 -c libfpg.so -no_use_bb_pc -segment_size 60000000over the wholesqlite_queryrun β 57 segments of 60,000,000 instructions.Cluster. SimPoint 3.2,
-maxK 5 -dim 100 -fixedLength off -numInitSeeds 10 -coveragePct .99. BIC chose k = 4, and the clusters recovered exactly the four query phases and their three repetitions:cluster segments query phase representative 2 0-4, 19-22, 38-41 rowid point lookups 22 3 5-8, 23-27, 42-46 index lookups 27 1 9-13, 28-32, 47-51 rowid range scans 12 0 14-18, 33-37, 52-56 index range scans 54 SimPoint's own representative for cluster 0 was segment 56, the partial trailing segment (16,512,018 instructions). It was replaced by segment 54, the next-closest full segment to the centroid (0.0371956 vs 0.0366442); recorded in
simpoints/substitutions.txt. Every representative's preceding segment is in the same cluster, so each archive's warmup chunk is in the same query phase as its measured chunk.Trace. Per SimPoint,
drrun -t drcachesim -offline -count_fetched_instrs -trace_after_instrs <seg-1>*60M -trace_for_instrs 120000000.Convert.
portabilize_trace.py, thendrraw2trace -chunk_instr_count 60000000.Minimize. Keep
chunk.0000(warmup) +chunk.0001(SimPoint region) β 120,000,000 instructions per released archive.
Tooling: DynamoRIO 10.0.0, SimPoint 3.2, fingerprint client libfpg.so, all
inside container image allbench_traces:00022fc. Capture host
clnode130.clemson.cloudlab.us.
The traces
| file | segment | cluster | weight | query phase | size |
|---|---|---|---|---|---|
traces_simp/trace/22.zip |
22 | 2 | 0.231008 | rowid point lookups | 387 MB |
traces_simp/trace/27.zip |
27 | 3 | 0.248778 | index lookups | 367 MB |
traces_simp/trace/12.zip |
12 | 1 | 0.266548 | rowid range scans | 75 MB |
traces_simp/trace/54.zip |
54 | 0 | 0.253666 | index range scans | 69 MB |
Weights sum to 1.0. All four archives contain exactly 120,000,000 fetched
instructions, pass unzip -t, pass drcachesim -simulator_type invariant_checker, and have distinct sha256 values.
Verification that this is the steady state
Two independent methods, both under validation/steady_state/.
Exhaustive, instruction-exact. function_profile-segment-<N>.txt attributes
100% of each archive's 120,000,000 instructions to functions, computed from the
BBV fingerprint of the identical deterministic run. Query execution accounts for
85.2-96.3% of every window:
| segment | query phase | query-execution share | dominant functions |
|---|---|---|---|
| 22 | rowid point lookups | 85.24% | sqlite3VdbeExec 18.4%, sqlite3BtreeTableMoveto 12.1%, sqlite3GetVarint 10.7%, getPageMMap 5.3% |
| 27 | index lookups | 86.36% | sqlite3BtreeIndexMoveto 13.6%, sqlite3VdbeExec 12.9%, vdbeRecordCompareInt 7.9%, getPageMMap 6.2% |
| 12 | rowid range scans | 96.31% | sqlite3VdbeExec 59.7%, btreeParseCellPtr 5.2%, sqlite3VdbeSerialGet 3.8%, sqlite3BtreeNext 1.7% |
| 54 | index range scans | 96.34% | sqlite3VdbeExec 49.2%, sqlite3VdbeRecordCompareWithSkip 8.9%, sqlite3VdbeMemFromBtreeZeroOffset 4.8% |
The remainder is SQLite support code (memory management, sqlite3VdbeMemRelease,
value conversion) plus a fraction of a percent of libc.
Independent, from the trace files themselves.
trace_hot_functions-segment-<N>.txt runs drcachesim -simulator_type histogram
on each .zip and maps the hot instruction-fetch lines through nm and
modules.log. Same functions, same ordering.
Negative check. excluded_phase_check.tsv reports the instruction count of
every database-creation, schema-initialization, dataset-population and
SQL-compilation function in each archive β sqlite3BtreeInsert,
balance_nonroot, allocateBtreePage, sqlite3PagerWrite, insertCell,
sqlite3CreateIndex, sqlite3StartTable, sqlite3InitOne, sqlite3AnalysisLoad,
sqlite3RunParser, sqlite3Prepare, sqlite3WhereBegin, and others:
0 instructions, in all four archives, in all four categories.
Note on classification: sqlite3BtreeBeginTrans / sqlite3BtreeCommitPhaseTwo
do appear. On a read-only, query_only=ON connection these are the per-query
read-transaction begin and teardown β query execution state management, not
writes β so they are counted as query execution. No write path is reachable.
validation/basic_counts/ additionally shows 1 thread and 0 system-call
markers per archive: the traced regions are pure userspace B-tree work.
Mapping runtime PCs back to source
traces_simp/bin/modules.log is the DynamoRIO module table recorded at capture
time (load base, extent, path for every module). The module images it references
are shipped alongside it, so PCs resolve all the way to source. The main binary
is at 0x400000 (-no-pie) and carries -g debug info, so a trace PC in that
range is already a link-time address:
addr2line -f -C -e traces_simp/bin/sqlite_query 0x497d40
For other modules subtract the module start from modules.log, or pass
-alt_module_dir traces_simp/bin to drcachesim tools.
workload/bin/sqlite_query.nm holds the symbol table.
Reproducing
workload/src/ contains everything: sqlite_setup.c, sqlite_query.c,
build.sh, trace_simpoints.sh, validate.sh, verify_steady_state.py,
fp_funcs.py, trace_pc_funcs.py.
bash build.sh # build both binaries
./sqlite_setup /path/records.db 3000000 # untraced: create + load
./sqlite_query /path/records.db 3 60000 50000 4900 5000 3000000 # the traced phase
Layout note
fingerprint/ holds bbfp, bbfp.inscount, pcmap, pieces/segment.N and
segment_size. It does not have the fingerprint/0..N/PARAMS.in directories or
footprint_pieces/ seen in the leveldb / duckdb / rocksdb folders of this
dataset β those are artifacts of the trace_then_cluster flow, which
fingerprints a materialized whole-run trace with Scarab. Everything else matches
that layout exactly. The flow used here is recorded in
trace_clustering_info.json.