Skip to content

[Performance]: TPC-H SF10 current-main all-memory profiling — MO vs DuckDB (2026-11-03) #32073

Closed

Description

@aunjgr

Is there an existing issue for performance?

  • I have checked the existing issues.

This is a new, separately scoped profiling round following #30569 and #30716. Companion results: #32072. Those issues retain their historical results. This issue records local SF10 / all-memory storage on the newly built main. server129/SF100 remains deferred.

Environment

  • MO: dd2499cdcdf2722848851d4debca6cd6c66b4751, fresh optimized native CPU build; Go 1.27.1, GOAMD64=v3 GOEXPERIMENT=simd, MO_SIRIUS=0 MO_CL_CUDA=0; optional jemalloc C++ shim disabled.
  • DuckDB: 1.5.6, pinned duckdb-go/v2 v2.10506.0 and native bindings v0.10506.0; the persistent execute-and-drain client uses those unchanged dependencies.
  • CPU: AMD Ryzen 9 7950X3D, 16 physical/32 logical CPUs; both applications use physical CPUs 0–7, controller uses 8–15. Shared host, initially quiet; compiler interference recorded per window.
  • OS: Linux 7.3.1-1-cachyos x86_64; GCC 16.2.1.
  • Memory: equal 32 GiB application cgroups, including the engine/client and staged native image/software; memory.swap.max=0. DuckDB internal memory target is 24 GiB.
  • MO settings: CN SHARED memory cache explicitly 16 GiB; LOCAL/TN caches 512 MiB; disk cache disabled; GOMAXPROCS=8, GOGC=100, agg_spill_mem=2147483648, UTC/ANSI semantics and result saving off. Configured cache capacity does not establish decoded-column residency.
  • Storage: default local DISK file service with CRC framing. Private RAM-backed native images/software staged inside the application cgroup; one engine at a time.
  • Workload: retained SF10 DBGEN/QGEN inputs, canonical decimal schema/primary keys and Q1–Q22 SQL. Fresh database load once per engine; original Q15 create-view/SELECT/drop-view lifecycle retained.

Details of Performance

Measurement type: separate target-warm profiling replays. The first/cold suite and each CPU target warmup are excluded. Three uninstrumented warm executions per query calibrate sampling duration; they are not a new balanced paired latency benchmark. CPU/counters, native execution plans and selected Go snapshots are separate passes.

Common measurements: whole-application user CPU-clock sampling at 99 Hz with user frame-pointer callchains, grouped user cycles/instructions, cgroup CPU/memory/I/O/swap/OOM and spill events. CPU/instructions are normalized by completed executions. No lost samples; counters ran 100% of enabled time. Native operator timers retain their engine-specific meanings.

Wall-time, CPU and instruction comparison

Wall time is the median of the three already recorded uninstrumented warm executions per query. CPU and instruction costs come from the separate profiled replays. Cold runs are excluded.

Query MO wall ms DuckDB wall ms Wall ratio MO CPU s/query DuckDB CPU s/query CPU ratio Instructions ratio
Q1 961.653 124.928 7.70× 7.3234 0.9792 7.48× 10.12×
Q2 40.378 24.183 1.67× 0.2180 0.1081 2.02× 1.70×
Q3 242.240 61.793 3.92× 1.7335 0.4407 3.93× 2.99×
Q4 183.771 79.938 2.30× 1.3318 0.4487 2.97× 2.55×
Q5 198.855 68.147 2.92× 1.4635 0.4755 3.08× 2.32×
Q6 119.382 24.455 4.88× 0.8870 0.1897 4.68× 3.41×
Q7 242.015 57.878 4.18× 1.6603 0.4265 3.89× 2.81×
Q8 291.577 63.498 4.59× 1.7965 0.4242 4.23× 2.51×
Q9 570.268 275.443 2.07× 3.8091 2.0483 1.86× 2.63×
Q10 409.824 136.310 3.01× 3.0428 0.9113 3.34× 4.73×
Q11 63.806 11.942 5.34× 0.3580 0.0672 5.33× 4.60×
Q12 317.399 59.169 5.36× 2.2396 0.4263 5.25× 5.58×
Q13 273.524 211.941 1.29× 2.0400 1.6073 1.27× 1.60×
Q14 134.941 46.418 2.91× 0.9978 0.3292 3.03× 3.32×
Q15 253.601 36.523 6.94× 1.7845 0.2748 6.49× 5.80×
Q16 100.120 51.531 1.94× 0.4830 0.3220 1.50× 1.97×
Q17 212.139 66.126 3.21× 1.5210 0.5050 3.01× 2.59×
Q18 441.898 200.393 2.21× 2.9854 1.5345 1.95× 1.29×
Q19 457.134 90.382 5.06× 3.4154 0.6582 5.19× 6.79×
Q20 251.365 59.680 4.21× 1.8256 0.3858 4.73× 3.14×
Q21 838.459 218.303 3.84× 6.1648 1.3939 4.42× 4.87×
Q22 75.419 56.595 1.33× 0.5718 0.3295 1.74× 3.15×
Total 6679.769 2025.573 3.30× 47.6529 14.2859 3.34× 3.76×

Total sums the 22 per-query wall-time medians and normalized CPU/instruction costs. Each total ratio is calculated from the summed MO and DuckDB values, rather than averaging query ratios.

Main findings

  • Q1: lz4block.decodeBlock.abi0 12.61%; pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill 10.37%; pkg/common/hashmap.fillFlatCharStringHashKey 8.62%.
  • Q6: lz4block.decodeBlock.abi0 35.83%; pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 22.38%; pkg/objectio.selectExactOrdered[go.shape.uint64,go.shape.int64] 10.91%.
  • Q9: pkg/container/hashtable.(*Int64HashMap).FindBatch 26.80%; lz4block.decodeBlock.abi0 12.27%; pkg/container/vector.(*Vector).UnionOne 6.86%.
  • Q15: lz4block.decodeBlock.abi0 28.66%; pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 21.22%; pkg/sql/colexec/aggexec.(*sumAvgDecExec[go.shape.struct { B0_63 uint64; B64_127 uint64 },go.shape.struct { B0_63 uint64; B64_127 uint64; B128_191 uint64; B192_255 uint64 }]).batchFillSum 4.34%.
  • Q18: pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch 35.73%; pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill 10.83%; lz4block.decodeBlock.abi0 9.05%.
  • Q21: pkg/container/hashtable.(*Int64HashMap).FindBatch 16.95%; lz4block.decodeBlock.abi0 9.49%; pkg/sql/colexec/table_scan.(*TableScan).evalFilter 5.02%.

Q1 native plans show generic string-key grouping in MO versus compressed small-domain keys and PERFECT_HASH_GROUP_BY in DuckDB. Both show 59,142,609 rows reaching the main pipeline. The MO tax-adjusted expression still contains DECIMAL256 casts/products; #31034 is already merged. This observation does not by itself prove an incorrect width or authorize narrowing without precision/overflow analysis.

Q15: MO still has two lineitem/revenue producers, while DuckDB materializes one common producer and reads it twice. This is an executed-work difference alongside the measured kernel costs.

Q18 is dominated by group insertion; its instruction gap is smaller than its CPU gap. Lower measured IPC needs additional cache/branch evidence before attribution. Hash probing and scattered gathers remain material in Q9/Q21.

Resource evidence

Engine Zero-I/O/spill/swap/OOM/limit/interference CPU windows Peak application GiB Reads across capture windows GiB Writes across capture windows MiB
mo 22/22 15.04 0.000 0.000
duckdb 22/22 10.09 0.000 0.000

All 44 all-memory CPU windows have zero physical reads/writes, spills, swap, OOM/limit events and memory-pressure stall deltas.

Performance acceptance boundary

A completed profile or resource gate does not establish an optimization speedup. Before accepting a proposed fix: freeze clean baseline/candidate identities and settings; demonstrate less named work and faster uninstrumented target queries; run balanced repeated warm comparisons and Q1–Q22 controls; retain uncertainty and reject confirmed regressions. Apply SF100 acceptance where relevant once server129 is available. No optimization subtask is closed by this profiling-only result.

Additional information

Coverage: 44 CPU recordings, 44 native plans and per-query counters/diagrams for this issue. Both new issues together cover 88 CPU recordings and 88 native plans. Selected MO Q1/Q6/Q9/Q15/Q18/Q21 have before/after Go heap and allocation snapshots in each mode. Go samples can lag GC and do not measure native allocators; no exact allocation-byte claim is made.

Profiles: all recordings and analysis are published in the profile release. Files are compressed individually, with direct per-query links below. Profiles/reports total about 20 MB. Full executable/library archives are separate optional downloads, about 152 MB total; they enable independent raw-perf address/source/disassembly analysis. Precomputed tables and diagrams can be read without downloading them.

Detailed findings · Full CPU comparison · Raw analysis · Complete index · Opening instructions · Asset sizes/hashes

SF10 CPU costs

Opening raw perf: decompress the needed .elf.zst archives and populate a private cache with perf --buildid-dir "$PWD/symbols" buildid-cache -a FILE.elf; then use that same --buildid-dir with perf report/script. software.json maps exact build IDs. Optimized C++ callchains can remain partial even with matching executables; some stripped libc leaves have no additional symbol information.

Method limits: optimized C++ frame-pointer callchains are shallower than Go callchains. DuckDB known-leaf coverage bottoms near 83.6%, principally stripped-libc leaves in Q13/Q14/Q19. Use common CPU/counters and exclusive leaves for comparison. This local DISK configuration does not cover S3-specific shared-decode dispatch. Historical engine/cache/worker differences prevent attributing an old/new timing change solely to MO optimizations.

Preparation/collection: MO preparation 113.79s including statistics/checkpoint (bulk loads about 39s); DuckDB 58.49s. MO successful CPU/native passes took 133.78s and 142.37s. From local protocol creation to capture completion across both modes/engines: about 19m22s, including setup corrections; completed captures were retained. Offline analysis/diagrams completed about 28s later.

Execution policy: load/query scripts execute and drain only; no input/schema/table/row/result/reference/checksum verification. All local benchmark services stopped and RAM copies were removed. Original inputs and new persistent loaded images remain. server129/SF100 was not profiled.

Per-query profile downloads

mo — Q1–Q22 raw CPU, counters, native plans and CPU-leaf diagrams
Query Raw CPU PMU counters Native plan CPU leaf diagram
Q1 perf.data (55.1 KiB) counters (111 B) native (655 B) leaves (10.9 KiB)
Q2 perf.data (42.2 KiB) counters (112 B) native (1.6 KiB) leaves (14.0 KiB)
Q3 perf.data (46.6 KiB) counters (112 B) native (1.1 KiB) leaves (13.8 KiB)
Q4 perf.data (46.2 KiB) counters (111 B) native (794 B) leaves (12.7 KiB)
Q5 perf.data (49.7 KiB) counters (111 B) native (1.4 KiB) leaves (14.2 KiB)
Q6 perf.data (46.0 KiB) counters (111 B) native (534 B) leaves (12.9 KiB)
Q7 perf.data (45.2 KiB) counters (112 B) native (1.5 KiB) leaves (13.6 KiB)
Q8 perf.data (41.5 KiB) counters (111 B) native (1.7 KiB) leaves (13.6 KiB)
Q9 perf.data (49.0 KiB) counters (111 B) native (1.4 KiB) leaves (13.6 KiB)
Q10 perf.data (49.2 KiB) counters (112 B) native (1.2 KiB) leaves (13.6 KiB)
Q11 perf.data (41.6 KiB) counters (111 B) native (1.2 KiB) leaves (12.8 KiB)
Q12 perf.data (45.9 KiB) counters (112 B) native (873 B) leaves (13.7 KiB)
Q13 perf.data (46.7 KiB) counters (111 B) native (838 B) leaves (10.9 KiB)
Q14 perf.data (49.1 KiB) counters (111 B) native (777 B) leaves (14.9 KiB)
Q15 perf.data (47.1 KiB) counters (112 B) native (1014 B) leaves (14.7 KiB)
Q16 perf.data (38.5 KiB) counters (112 B) native (1.1 KiB) leaves (11.6 KiB)
Q17 perf.data (47.6 KiB) counters (111 B) native (1.1 KiB) leaves (14.0 KiB)
Q18 perf.data (44.0 KiB) counters (111 B) native (1.1 KiB) leaves (12.4 KiB)
Q19 perf.data (49.1 KiB) counters (111 B) native (1.0 KiB) leaves (12.1 KiB)
Q20 perf.data (46.4 KiB) counters (111 B) native (1.4 KiB) leaves (12.9 KiB)
Q21 perf.data (52.6 KiB) counters (111 B) native (1.4 KiB) leaves (14.1 KiB)
Q22 perf.data (52.7 KiB) counters (111 B) native (1.1 KiB) leaves (12.4 KiB)
duckdb — Q1–Q22 raw CPU, counters, native plans and CPU-leaf diagrams
Query Raw CPU PMU counters Native plan CPU leaf diagram
Q1 perf.data (52.2 KiB) counters (111 B) native (2.5 KiB) leaves (9.7 KiB)
Q2 perf.data (33.1 KiB) counters (111 B) native (4.3 KiB) leaves (14.4 KiB)
Q3 perf.data (47.3 KiB) counters (110 B) native (2.9 KiB) leaves (14.7 KiB)
Q4 perf.data (38.4 KiB) counters (111 B) native (3.2 KiB) leaves (12.8 KiB)
Q5 perf.data (46.2 KiB) counters (112 B) native (3.4 KiB) leaves (14.1 KiB)
Q6 perf.data (47.0 KiB) counters (112 B) native (1.5 KiB) leaves (11.2 KiB)
Q7 perf.data (48.2 KiB) counters (112 B) native (4.5 KiB) leaves (14.9 KiB)
Q8 perf.data (45.5 KiB) counters (112 B) native (4.3 KiB) leaves (13.5 KiB)
Q9 perf.data (42.2 KiB) counters (112 B) native (4.1 KiB) leaves (13.5 KiB)
Q10 perf.data (43.3 KiB) counters (111 B) native (3.7 KiB) leaves (15.2 KiB)
Q11 perf.data (38.7 KiB) counters (111 B) native (3.5 KiB) leaves (16.2 KiB)
Q12 perf.data (46.9 KiB) counters (111 B) native (3.1 KiB) leaves (13.6 KiB)
Q13 perf.data (42.3 KiB) counters (111 B) native (2.2 KiB) leaves (10.9 KiB)
Q14 perf.data (47.1 KiB) counters (112 B) native (2.0 KiB) leaves (13.3 KiB)
Q15 perf.data (49.7 KiB) counters (111 B) native (3.3 KiB) leaves (13.8 KiB)
Q16 perf.data (42.4 KiB) counters (112 B) native (3.6 KiB) leaves (16.0 KiB)
Q17 perf.data (47.7 KiB) counters (111 B) native (3.1 KiB) leaves (12.4 KiB)
Q18 perf.data (46.6 KiB) counters (111 B) native (4.1 KiB) leaves (12.8 KiB)
Q19 perf.data (45.6 KiB) counters (111 B) native (2.5 KiB) leaves (13.7 KiB)
Q20 perf.data (45.4 KiB) counters (111 B) native (3.6 KiB) leaves (14.1 KiB)
Q21 perf.data (43.1 KiB) counters (112 B) native (4.4 KiB) leaves (14.1 KiB)
Q22 perf.data (34.7 KiB) counters (112 B) native (3.6 KiB) leaves (11.5 KiB)
Selected MO Go heap/allocation snapshots

Sampled Go counters can lag GC and do not include native allocators; these are diagnostic snapshots, not exact query-allocation totals.

Query Before allocs After allocs Before heap After heap
Q1 before allocs (250.1 KiB) after allocs (252.6 KiB) before heap (251.8 KiB) after heap (252.8 KiB)
Q6 before allocs (253.4 KiB) after allocs (253.4 KiB) before heap (253.5 KiB) after heap (253.4 KiB)
Q9 before allocs (253.8 KiB) after allocs (254.2 KiB) before heap (253.6 KiB) after heap (254.4 KiB)
Q15 before allocs (254.5 KiB) after allocs (255.8 KiB) before heap (255.0 KiB) after heap (255.6 KiB)
Q18 before allocs (256.0 KiB) after allocs (255.3 KiB) before heap (256.0 KiB) after heap (255.3 KiB)
Q21 before allocs (255.6 KiB) after allocs (256.8 KiB) before heap (255.6 KiB) after heap (257.4 KiB)
Optional full executable/library archives — download only what your analysis needs
Executable/library Download Compressed size
libc.so.6 exact ELF 1.01 MiB
libgcc_s.so.1 exact ELF 95.8 KiB
mo-service exact ELF 108.63 MiB
tpch-profile-session exact ELF 23.86 MiB
libresolv.so.2 exact ELF 31.9 KiB
ld-linux-x86-64.so.2 exact ELF 145.5 KiB
libstdc++.so.6 exact ELF 1.05 MiB
onnxruntime.so exact ELF 7.21 MiB
libmo.so exact ELF 898.1 KiB
libusearch_c.so exact ELF 820.2 KiB
libm.so.6 exact ELF 536.6 KiB
libmvec.so.1 exact ELF 273.2 KiB
libgomp.so.1 exact ELF 199.6 KiB

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. aunjgr commented on Nov 3, 2026

    @aunjgr
    ContributorAuthor

    mo — Q1–Q22 analyzed CPU profiles (memory)

    Exclusive user-CPU leaves, weighted by sample periods and normalized per completed query. Symbols below are abbreviated for readability. Raw recordings, counters, native plans, leaf diagrams and optional full executable/library archives are linked directly from the issue body. Full profile release.

    Q1 — 7.3234 application CPU s/query; 153.53 billion instructions/query; 100.00% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 12.61%
    pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill 10.37%
    pkg/common/hashmap.fillFlatCharStringHashKey 8.62%
    pkg/common/hashmap.(*strHashmapIterator).prepareHashKeys 6.53%
    runtime.memmove 4.30%
    pkg/sql/colexec/aggexec.(*sumAvgDecExec[go.shape.struct { B0_63 uint64; B64_127 uint64; B128_191 uint64; B192_255 uint64 },go.shape.struct { B0_63 uint64; B64_127 uint64; B128_191 uint64; B192_255 uint64 }]).batchFillSum 3.36%
    pkg/container/types.(*Varlena).GetByteSlice 3.14%
    pkg/sql/colexec/aggexec.(*sumAvgDecExec[go.shape.struct { B0_63 uint64; B64_127 uint64 },go.shape.struct { B0_63 uint64; B64_127 uint64; B128_191 uint64; B192_255 uint64 }]).batchFillSum 2.97%
    Q2 — 0.2180 application CPU s/query; 2.77 billion instructions/query; 99.37% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).FindBatch 27.87%
    runtime.memmove 8.68%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 8.34%
    pkg/container/vector.(*Vector).unionBatchContiguousVarlenRange 4.70%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 3.30%
    lz4block.decodeBlock.abi0 3.30%
    pkg/common/hashmap.(*intHashMapIterator).Find 3.05%
    pkg/sql/colexec/hashjoin.(*container).appendMembershipMatches 2.71%
    Q3 — 1.7335 application CPU s/query; 20.06 billion instructions/query; 99.82% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 25.04%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 21.51%
    pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 12.28%
    pkg/container/vector.unionT[go.shape.int64] 7.09%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 3.02%
    runtime.memmove 2.54%
    pkg/container/hashtable.(*Int64HashMap).InsertBatchWithRing 1.74%
    pkg/sql/colexec/shuffle.(*Shuffle).routeSingleBucket 1.27%
    Q4 — 1.3318 application CPU s/query; 17.22 billion instructions/query; 100.00% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 18.81%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 12.50%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 11.05%
    pkg/container/vector.(*FunctionParameterWithoutNull[pkg/container/types.Date]).GetValue 10.21%
    pkg/sql/colexec/hashjoin.(*container).probe 6.34%
    runtime.memmove 5.72%
    pkg/sql/plan/function.opBinaryFixedFixedToFixed[go.shape.int32,go.shape.int32,go.shape.bool] 3.83%
    pkg/container/vector.shrinkFixed[go.shape.int32] 2.04%
    Q5 — 1.4635 application CPU s/query; 17.31 billion instructions/query; 99.72% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 25.53%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 20.88%
    pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 5.01%
    runtime.memmove 4.97%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 4.94%
    pkg/container/vector.unionT[go.shape.int64] 3.84%
    pkg/common/hashmap.(*intHashMapIterator).Find 2.13%
    internal/runtime/syscall/linux.Syscall6 1.70%
    Q6 — 0.8870 application CPU s/query; 11.78 billion instructions/query; 100.00% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 35.83%
    pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 22.38%
    pkg/objectio.selectExactOrdered[go.shape.uint64,go.shape.int64] 10.91%
    internal/runtime/syscall/linux.Syscall6 2.46%
    hash/crc32.castagnoliSSE42Triple.abi0 1.86%
    context.value 1.86%
    hash/crc32.archUpdateCastagnoli 1.19%
    runtime.step 0.86%
    Q7 — 1.6603 application CPU s/query; 17.69 billion instructions/query; 99.69% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 23.63%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 20.41%
    runtime.memmove 5.51%
    pkg/sql/plan/function.opBetweenFixed[go.shape.int32] 4.77%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 4.35%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 4.00%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 2.25%
    internal/runtime/syscall/linux.Syscall6 1.71%
    Q8 — 1.7965 application CPU s/query; 18.84 billion instructions/query; 99.78% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).FindBatch 28.34%
    lz4block.decodeBlock.abi0 21.16%
    runtime.memmove 5.75%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 3.44%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 3.31%
    pkg/sql/plan/function.opBetweenFixed[go.shape.int32] 2.74%
    internal/runtime/syscall/linux.Syscall6 1.87%
    pkg/common/hashmap.(*intHashMapIterator).Find 1.57%
    Q9 — 3.8091 application CPU s/query; 44.05 billion instructions/query; 99.40% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).FindBatch 26.80%
    lz4block.decodeBlock.abi0 12.27%
    pkg/container/vector.(*Vector).UnionOne 6.86%
    pkg/sql/colexec/hashjoin.(*container).probe 4.38%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 4.24%
    pkg/container/vector.BuildVarlenaFromVarlena 3.39%
    runtime.memmove 3.08%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 2.83%
    Q10 — 3.0428 application CPU s/query; 42.98 billion instructions/query; 99.86% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 19.23%
    pkg/container/types.CompareStringValues 6.34%
    runtime.memmove 5.65%
    cmpbody 4.75%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 3.64%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 3.50%
    pkg/sql/plan/function.equalFn.func20 3.43%
    bytes.TrimRight 3.08%
    Q11 — 0.3580 application CPU s/query; 4.41 billion instructions/query; 99.77% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).FindBatch 34.44%
    pkg/sql/colexec/hashjoin.(*container).appendUniqueMatches 5.63%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 5.26%
    runtime.memmove 4.62%
    pkg/container/vector.(*Vector).UnionMulti 2.54%
    pkg/container/vector.(*Vector).IsConstNull 2.35%
    pkg/common/hashmap.(*intHashMapIterator).Find 1.89%
    pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch 1.62%
    Q12 — 2.2396 application CPU s/query; 32.39 billion instructions/query; 99.93% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 19.99%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 10.08%
    pkg/container/vector.(*FunctionParameterWithoutNull[pkg/container/types.Date]).GetValue 9.35%
    runtime.memmove 6.83%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 4.29%
    pkg/sql/plan/function.opBinaryFixedFixedToFixed[go.shape.int32,go.shape.int32,go.shape.bool] 4.06%
    pkg/container/vector.validateJSONPayload 3.80%
    pkg/container/vector.validateVectorBinary 3.36%
    Q13 — 2.0400 application CPU s/query; 25.24 billion instructions/query; 99.59% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/sql/colexec/aggexec.(*countColumnExec).BatchFill 10.14%
    pkg/container/vector.(*Vector).UnionOne 9.39%
    pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch 9.04%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 8.81%
    indexbody 5.19%
    lz4block.decodeBlock.abi0 4.95%
    indexbytebody 4.71%
    pkg/sql/colexec/shuffle.getShuffledSelsByRangeWithoutNull 4.51%
    Q14 — 0.9978 application CPU s/query; 13.75 billion instructions/query; 99.89% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 23.53%
    pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 18.92%
    pkg/container/vector.(*Vector).UnionOne 5.25%
    internal/runtime/syscall/linux.Syscall6 2.88%
    pkg/sql/colexec/hashjoin.(*container).probe 2.55%
    context.value 1.95%
    hash/crc32.castagnoliSSE42Triple.abi0 1.80%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 1.61%
    Q15 — 1.7845 application CPU s/query; 23.30 billion instructions/query; 99.72% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 28.66%
    pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 21.22%
    pkg/sql/colexec/aggexec.(*sumAvgDecExec[go.shape.struct { B0_63 uint64; B64_127 uint64 },go.shape.struct { B0_63 uint64; B64_127 uint64; B128_191 uint64; B192_255 uint64 }]).batchFillSum 4.34%
    internal/runtime/syscall/linux.Syscall6 2.63%
    pkg/container/vector.unionT[go.shape.int64] 2.27%
    hash/crc32.castagnoliSSE42Triple.abi0 2.11%
    context.value 1.95%
    pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch 1.71%
    Q16 — 0.4830 application CPU s/query; 6.48 billion instructions/query; 99.40% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*StringHashMap).PlanInsertStringBatch 9.68%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 8.64%
    pkg/container/hashtable.(*StringHashMap).rehashInPlace 6.12%
    runtime.memclrNoHeapPointers 5.25%
    runtime.memmove 5.14%
    pkg/common/hashmap.(*strHashmapIterator).prepareHashKeys 4.48%
    pkg/container/vector.unionT[go.shape.int64] 3.83%
    pkg/common/hashmap.fillFlatCharStringHashKey 3.17%
    Q17 — 1.5210 application CPU s/query; 21.42 billion instructions/query; 100.00% known leaves
    Exclusive leaf (abbreviated) User CPU share
    runtime.mapaccess2_fast32 42.76%
    lz4block.decodeBlock.abi0 15.40%
    pkg/sql/plan/function.(*opOperatorIntegerIn[go.shape.int32]).eval 5.04%
    runtime.memmove 4.24%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 2.14%
    internal/runtime/syscall/linux.Syscall6 2.10%
    hash/crc32.castagnoliSSE42Triple.abi0 1.68%
    context.value 1.68%
    Q18 — 2.9854 application CPU s/query; 25.41 billion instructions/query; 99.67% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch 35.73%
    pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill 10.83%
    lz4block.decodeBlock.abi0 9.05%
    pkg/container/vector.(*Vector).unionBatch 5.01%
    pkg/sql/colexec/group.(*container).preflightBuildChunk 4.56%
    pkg/container/hashtable.(*Int64HashMap).CommitInsertBatchPlan 3.86%
    runtime.memmove 2.60%
    pkg/container/hashtable.(*Int64HashMap).rehashInPlace 2.52%
    Q19 — 3.4154 application CPU s/query; 54.50 billion instructions/query; 100.00% known leaves
    Exclusive leaf (abbreviated) User CPU share
    lz4block.decodeBlock.abi0 19.29%
    runtime.memmove 7.96%
    cmpbody 6.21%
    pkg/container/types.CompareStringValues 4.84%
    pkg/container/vector.validateJSONPayload 4.67%
    pkg/container/vector.validateVectorBinary 4.53%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 3.53%
    bytes.TrimRight 3.40%
    Q20 — 1.8256 application CPU s/query; 18.21 billion instructions/query; 99.55% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill 18.63%
    pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch 14.71%
    pkg/objectio.selectExactOrdered[go.shape.int32,go.shape.int32] 11.42%
    lz4block.decodeBlock.abi0 6.12%
    pkg/container/hashtable.(*Int64HashMap).rehashInPlace 4.14%
    pkg/container/vector.(*Vector).unionBatch 3.43%
    pkg/container/hashtable.(*Int64HashMap).FindBatch 2.99%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 2.87%
    Q21 — 6.1648 application CPU s/query; 85.30 billion instructions/query; 99.93% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).FindBatch 16.95%
    lz4block.decodeBlock.abi0 9.49%
    pkg/sql/colexec/table_scan.(*TableScan).evalFilter 5.02%
    pkg/sql/colexec/hashjoin.(*container).probe 4.44%
    pkg/container/vector.(*FunctionParameterWithoutNull[pkg/container/types.Date]).GetValue 4.30%
    runtime.memmove 2.85%
    pkg/container/vector.(*Vector).IsConstNull 2.68%
    pkg/container/vector.GetConstSetFunction.func1 2.10%
    Q22 — 0.5718 application CPU s/query; 9.13 billion instructions/query; 99.47% known leaves
    Exclusive leaf (abbreviated) User CPU share
    pkg/container/hashtable.(*Int64HashMap).FindBatch 16.81%
    pkg/sql/colexec/shuffle.getShuffledSelsByRangeWithoutNull 7.85%
    pkg/container/vector.appendOneBytesWithSource 7.59%
    pkg/sql/colexec/hashjoin.(*container).probe 6.62%
    pkg/container/vector.(*Vector).UnionMulti 2.96%
    pkg/common/hashmap.fillKeys[go.shape.uint32] 2.76%
    internal/runtime/maps.memHashAES 2.73%
    internal/runtime/maps.(*Map).getWithoutKeySmallFastStr 2.46%
  3. aunjgr commented on Nov 3, 2026

    @aunjgr
    ContributorAuthor

    duckdb — Q1–Q22 analyzed CPU profiles (memory)

    Exclusive user-CPU leaves, weighted by sample periods and normalized per completed query. Symbols below are abbreviated for readability. Raw recordings, counters, native plans, leaf diagrams and optional full executable/library archives are linked directly from the issue body. Full profile release.

    Q1 — 0.9792 application CPU s/query; 15.17 billion instructions/query; 99.34% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::AggregateFunction::UnaryScatterUpdate<duckdb::SumState<long>, long, duckdb::(anonymous namespace)::IntegerSumOperation>(duckdb::Vector*, duckdb::AggregateInputData&, unsigned long, duckdb::Vector&, unsign… 16.87%
    void duckdb::AggregateFunction::UnaryScatterUpdate<duckdb::(anonymous namespace)::AvgState<duckdb::hugeint_t>, long, duckdb::(anonymous namespace)::IntegerAverageOperationHugeint>(duckdb::Vector*, duckdb::AggregateInp… 16.15%
    duckdb::PerfectAggregateHashTable::AddChunk(duckdb::DataChunk&, duckdb::DataChunk&) 12.21%
    duckdb::VectorOperations::AddInPlace(duckdb::Vector&, long, unsigned long) 6.92%
    void duckdb::ScalarFunction::BinaryFunction<long, long, long, duckdb::MultiplyOperator>(duckdb::DataChunk&, duckdb::ExpressionState&, duckdb::Vector&) 5.82%
    duckdb::SelectionVector::Slice(duckdb::SelectionVector const&, unsigned long) const 4.88%
    void duckdb::AggregateFunction::NullaryScatterUpdate<long, duckdb::(anonymous namespace)::CountStarFunction>(duckdb::Vector*, duckdb::AggregateInputData&, unsigned long, duckdb::Vector&, unsigned long) 4.25%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 3.18%
    Q2 — 0.1081 application CPU s/query; 1.63 billion instructions/query; 97.89% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 13.75%
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 10.36%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 9.30%
    int duckdb::DeltaDecode<int>(int*, int, unsigned long) [clone .isra.0] 6.20%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 4.45%
    duckdb::FSSTStorage::Select(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, duckdb::SelectionVector const&, unsigned long) 3.04%
    duckdb_fastpforlib::internal::__fastunpack17(unsigned int const*, unsigned long*) 2.93%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 2.93%
    Q3 — 0.4407 application CPU s/query; 6.71 billion instructions/query; 98.88% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 16.54%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 9.25%
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 7.48%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.02%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 4.59%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 3.83%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 3.47%
    duckdb::JoinHashTable::InsertHashes(duckdb::Vector&, unsigned long, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::InsertState&, bool) 3.36%
    Q4 — 0.4487 application CPU s/query; 6.75 billion instructions/query; 99.42% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 24.00%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 11.93%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 5.83%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.61%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 4.35%
    duckdb_fastpforlib::internal::__fastunpack12(unsigned int const*, unsigned int*) 4.08%
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 2.78%
    duckdb::HyperLogLog::Update(duckdb::Vector&, duckdb::Vector&, unsigned long) 2.69%
    Q5 — 0.4755 application CPU s/query; 7.47 billion instructions/query; 99.78% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 24.52%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 11.18%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 6.25%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 4.28%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 3.76%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 3.55%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 2.81%
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 2.67%
    Q6 — 0.1897 application CPU s/query; 3.45 billion instructions/query; 99.84% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::FilterSelectionSwitch<long>(duckdb::UnifiedVectorFormat&, long, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 16.91%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 13.63%
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 11.66%
    duckdb_fastpforlib::internal::__fastunpack13(unsigned int const*, unsigned long*) 6.88%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 6.78%
    duckdb_fastpforlib::internal::__fastunpack4(unsigned int const*, unsigned long*) 5.21%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.21%
    duckdb_fastpforlib::internal::__fastunpack12(unsigned int const*, unsigned int*) 3.83%
    Q7 — 0.4265 application CPU s/query; 6.29 billion instructions/query; 98.47% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 12.36%
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 5.50%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.43%
    void duckdb::PerfectHashJoinExecutor::TemplatedFillSelectionVectorProbe<int>(duckdb::Vector&, duckdb::SelectionVector&, duckdb::SelectionVector&, unsigned long, unsigned long&) 5.33%
    duckdb::JoinHashTable::InsertHashes(duckdb::Vector&, unsigned long, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::InsertState&, bool) 4.49%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 4.25%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 4.11%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 3.86%
    Q8 — 0.4242 application CPU s/query; 7.50 billion instructions/query; 99.39% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 22.11%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 11.48%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 6.20%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.81%
    duckdb_fastpforlib::internal::__fastunpack21(unsigned int const*, unsigned int*) 4.17%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 4.06%
    duckdb_fastpforlib::internal::__fastunpack17(unsigned int const*, unsigned int*) 3.79%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 3.75%
    Q9 — 2.0483 application CPU s/query; 16.78 billion instructions/query; 97.85% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::JoinHashTable::InsertHashes(duckdb::Vector&, unsigned long, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::InsertState&, bool) 27.15%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 8.02%
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 5.62%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 3.01%
    void duckdb::PartitionedTupleData::BuildPartitionSel<true>(duckdb::PartitionedTupleDataAppendState&, duckdb::SelectionVector const&, unsigned long, unsigned long) 2.90%
    void duckdb::(anonymous namespace)::StringCompressFunction<duckdb::uhugeint_t>(duckdb::DataChunk&, duckdb::ExpressionState&, duckdb::Vector&) 2.72%
    duckdb::uhugeint_t duckdb::(anonymous namespace)::StringCompress<duckdb::uhugeint_t>(duckdb::string_t const&) 2.58%
    duckdb::JoinHashTable::Finalize(unsigned long, unsigned long, bool) 2.26%
    Q10 — 0.9113 application CPU s/query; 9.09 billion instructions/query; 95.05% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::ColumnSegment::FilterSelection(duckdb::SelectionVector&, duckdb::Vector&, duckdb::UnifiedVectorFormat&, duckdb::TableFilter const&, duckdb::TableFilterState&, unsigned long, unsigned long&) 15.24%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 6.83%
    [unknown] 4.95%
    duckdb::FastMemcpy(void*, void const*, unsigned long) 4.28%
    void duckdb::UnaryExecutor::ExecuteFlat<duckdb::uhugeint_t, duckdb::string_t, duckdb::UnaryLambdaWrapper, duckdb::(anonymous namespace)::StringDecompressFunction<duckdb::uhugeint_t>(duckdb::DataChunk&, duckdb::Express… 3.04%
    unsigned long duckdb::Hash<duckdb::string_t>(duckdb::string_t) 2.48%
    duckdb::StringHeap::EmptyString(unsigned long) 2.36%
    duckdb_fsst_decompress 2.33%
    Q11 — 0.0672 application CPU s/query; 0.96 billion instructions/query; 98.65% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::PerfectHashJoinExecutor::TemplatedFillSelectionVectorProbe<int>(duckdb::Vector&, duckdb::SelectionVector&, duckdb::SelectionVector&, unsigned long, unsigned long&) 10.37%
    void duckdb::AggregateFunction::StateInitialize<duckdb::SumState<duckdb::hugeint_t>, duckdb::(anonymous namespace)::SumToHugeintOperation, (duckdb::AggregateDestructorType)0>(duckdb::AggregateFunction const&, unsigned… 7.12%
    duckdb::GroupedAggregateHashTable::FindOrCreateGroupsInternal(duckdb::DataChunk&, duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector&) 6.33%
    duckdb::HyperLogLog::Update(duckdb::Vector&, duckdb::Vector&, unsigned long) 5.40%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.35%
    int duckdb::DeltaDecode<int>(int*, int, unsigned long) [clone .isra.0] 4.98%
    duckdb::hugeint_t::operator*(duckdb::hugeint_t const&) const 2.88%
    void duckdb::ColumnDataCopy<int>(duckdb::ColumnDataMetaData&, duckdb::UnifiedVectorFormat const&, duckdb::Vector&, unsigned long, unsigned long) 2.74%
    Q12 — 0.4263 application CPU s/query; 5.81 billion instructions/query; 99.33% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 15.74%
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 10.38%
    unsigned long duckdb::BinaryExecutor::SelectGeneric<int, int, duckdb::GreaterThan>(duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long, duckdb::SelectionVector*, duckdb::SelectionVector*) 8.40%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 7.59%
    duckdb_fastpforlib::internal::__fastunpack12(unsigned int const*, unsigned int*) 5.01%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 4.13%
    duckdb_fastpforlib::internal::__fastunpack3(unsigned int const*, unsigned int*) 2.68%
    std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() 2.44%
    Q13 — 1.6073 application CPU s/query; 15.74 billion instructions/query; 83.61% known leaves
    Exclusive leaf (abbreviated) User CPU share
    [unknown] 16.39%
    duckdb_fsst_decompress 11.56%
    duckdb::GroupedAggregateHashTable::FindOrCreateGroupsInternal(duckdb::DataChunk&, duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector&) 10.14%
    duckdb::FindStrInStr(unsigned char const*, unsigned long, unsigned char const*, unsigned long) 8.57%
    duckdb::HyperLogLog::Update(duckdb::Vector&, duckdb::Vector&, unsigned long) 7.39%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 6.48%
    void duckdb::FSSTStorage::StringScanPartial<true>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.68%
    unsigned long duckdb::TemplatedMatch<true, int, duckdb::Equals>(duckdb::Vector&, duckdb::TupleDataVectorFormat const&, duckdb::SelectionVector&, unsigned long, duckdb::TupleDataLayout const&, duckdb::Vector&, unsigned… 3.86%
    Q14 — 0.3292 application CPU s/query; 4.14 billion instructions/query; 92.98% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 12.43%
    duckdb::JoinHashTable::InsertHashes(duckdb::Vector&, unsigned long, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::InsertState&, bool) 7.24%
    [unknown] 7.02%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 6.81%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 4.80%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 4.30%
    duckdb_fastpforlib::internal::__fastunpack21(unsigned int const*, unsigned int*) 3.91%
    duckdb::FastMemcpy(void*, void const*, unsigned long) 3.26%
    Q15 — 0.2748 application CPU s/query; 4.02 billion instructions/query; 98.78% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 15.86%
    duckdb::GroupedAggregateHashTable::FindOrCreateGroupsInternal(duckdb::DataChunk&, duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector&) 8.64%
    duckdb::HyperLogLog::Update(duckdb::Vector&, duckdb::Vector&, unsigned long) 7.90%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 7.22%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 5.86%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 4.78%
    duckdb_fastpforlib::internal::__fastunpack17(unsigned int const*, unsigned int*) 4.10%
    duckdb_fastpforlib::internal::__fastunpack4(unsigned int const*, unsigned long*) 3.22%
    Q16 — 0.3220 application CPU s/query; 3.28 billion instructions/query; 96.96% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::FastMemcpy(void*, void const*, unsigned long) 9.82%
    duckdb::GroupedAggregateHashTable::FindOrCreateGroupsInternal(duckdb::DataChunk&, duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector&) 8.59%
    duckdb::HyperLogLog::Update(duckdb::Vector&, duckdb::Vector&, unsigned long) 7.81%
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 5.47%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 3.82%
    [unknown] 3.04%
    void duckdb::TupleDataTemplatedScatter<duckdb::string_t>(duckdb::Vector const&, duckdb::TupleDataVectorFormat const&, duckdb::SelectionVector const&, unsigned long, duckdb::TupleDataLayout const&, duckdb::Vector const… 2.71%
    void duckdb::PartitionedTupleData::BuildPartitionSel<true>(duckdb::PartitionedTupleDataAppendState&, duckdb::SelectionVector const&, unsigned long, unsigned long) 2.67%
    Q17 — 0.5050 application CPU s/query; 8.27 billion instructions/query; 99.37% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 22.24%
    duckdb::BloomFilter::LookupHashes(duckdb::Vector const&, duckdb::SelectionVector&, unsigned long) const 17.17%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 15.65%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 6.22%
    duckdb_fastpforlib::internal::__fastunpack13(unsigned int const*, unsigned long*) 4.43%
    duckdb_fastpforlib::internal::__fastunpack21(unsigned int const*, unsigned int*) 4.43%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 3.87%
    duckdb_fastpforlib::internal::__fastunpack24(unsigned int const*, unsigned long*) 3.11%
    Q18 — 1.5345 application CPU s/query; 19.64 billion instructions/query; 98.78% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::GroupedAggregateHashTable::FindOrCreateGroupsInternal(duckdb::DataChunk&, duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector&) 23.26%
    void duckdb::PartitionedTupleData::BuildPartitionSel<true>(duckdb::PartitionedTupleDataAppendState&, duckdb::SelectionVector const&, unsigned long, unsigned long) 6.68%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 6.35%
    duckdb::HyperLogLog::Update(duckdb::Vector&, duckdb::Vector&, unsigned long) 6.21%
    void duckdb::TupleDataTemplatedGather<unsigned long>(duckdb::TupleDataLayout const&, duckdb::Vector&, unsigned long, duckdb::SelectionVector const&, unsigned long, duckdb::Vector&, duckdb::SelectionVector const&, duck… 3.81%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 3.71%
    duckdb::FastMemcpy(void*, void const*, unsigned long) 3.65%
    void duckdb::TupleDataTemplatedGather<unsigned int>(duckdb::TupleDataLayout const&, duckdb::Vector&, unsigned long, duckdb::SelectionVector const&, unsigned long, duckdb::Vector&, duckdb::SelectionVector const&, duckd… 2.13%
    Q19 — 0.6582 application CPU s/query; 8.03 billion instructions/query; 89.79% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::ColumnSegment::FilterSelection(duckdb::SelectionVector&, duckdb::Vector&, duckdb::UnifiedVectorFormat&, duckdb::TableFilter const&, duckdb::TableFilterState&, unsigned long, unsigned long&) 17.14%
    [unknown] 10.21%
    unsigned long duckdb::BinaryExecutor::SelectGeneric<duckdb::string_t, duckdb::string_t, duckdb::Equals>(duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long, duckdb::SelectionVector*, duckdb… 8.67%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 4.02%
    duckdb::JoinHashTable::InsertHashes(duckdb::Vector&, unsigned long, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::InsertState&, bool) 3.85%
    void duckdb::BitpackingScanPartial<long, long, unsigned long>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 3.53%
    duckdb_fastpforlib::internal::__fastunpack3(unsigned int const*, unsigned int*) 2.62%
    duckdb::SelectionVector::Slice(duckdb::SelectionVector const&, unsigned long) const 2.34%
    Q20 — 0.3858 application CPU s/query; 5.80 billion instructions/query; 99.22% known leaves
    Exclusive leaf (abbreviated) User CPU share
    void duckdb::FilterSelectionSwitch<int>(duckdb::UnifiedVectorFormat&, int, duckdb::SelectionVector&, unsigned long&, duckdb::ExpressionType) 13.69%
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 13.66%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 9.36%
    duckdb_fastpforlib::internal::__fastunpack17(unsigned int const*, unsigned int*) 3.90%
    duckdb_fsst_decompress 3.59%
    duckdb_fastpforlib::internal::__fastunpack21(unsigned int const*, unsigned int*) 3.39%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 3.32%
    duckdb_fastpforlib::internal::__fastunpack13(unsigned int const*, unsigned long*) 3.16%
    Q21 — 1.3939 application CPU s/query; 17.51 billion instructions/query; 98.86% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 23.04%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 6.97%
    void duckdb::BitpackingScanPartial<int, int, unsigned int>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 5.41%
    unsigned long duckdb::BinaryExecutor::SelectFlat<int, int, duckdb::GreaterThan, false, false>(duckdb::Vector&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long, duckdb::SelectionVector*, duckdb::Selectio… 3.68%
    void duckdb::PerfectHashJoinExecutor::TemplatedFillSelectionVectorProbe<int>(duckdb::Vector&, duckdb::SelectionVector&, duckdb::SelectionVector&, unsigned long, unsigned long&) 3.49%
    long duckdb::DeltaDecode<long>(long*, long, unsigned long) [clone .isra.0] 3.33%
    duckdb_fastpforlib::internal::__fastunpack17(unsigned int const*, unsigned int*) 2.47%
    duckdb_fastpforlib::internal::__fastunpack12(unsigned int const*, unsigned int*) 2.43%
    Q22 — 0.3295 application CPU s/query; 2.90 billion instructions/query; 99.08% known leaves
    Exclusive leaf (abbreviated) User CPU share
    duckdb::JoinHashTable::GetRowPointers(duckdb::DataChunk&, duckdb::TupleDataChunkState&, duckdb::JoinHashTable::ProbeState&, duckdb::Vector&, duckdb::SelectionVector const*, unsigned long&, duckdb::Vector&, duckdb::Sel… 35.72%
    duckdb::VectorOperations::Equals(duckdb::Vector&, duckdb::Vector&, duckdb::Vector&, unsigned long) 9.05%
    duckdb::StringVector::EmptyString(duckdb::Vector&, unsigned long) 7.43%
    void duckdb::FSSTStorage::StringScanPartial<true>(duckdb::ColumnSegment&, duckdb::ColumnScanState&, unsigned long, duckdb::Vector&, unsigned long) 6.94%
    duckdb::SubstringASCII(duckdb::Vector&, duckdb::string_t, long, long) 6.68%
    duckdb::VectorOperations::Hash(duckdb::Vector&, duckdb::Vector&, unsigned long) 3.51%
    duckdb_fsst_decompress 2.94%
    duckdb::ExpressionExecutor::DefaultSelect(duckdb::Expression const&, duckdb::ExpressionState*, duckdb::SelectionVector const*, unsigned long, duckdb::SelectionVector*, duckdb::SelectionVector*) 1.41%
  4. aunjgr commented on Nov 3, 2026

    @aunjgr
    ContributorAuthor

    Why Q1 remains slow: measured work and implementation comparison

    The existing all-memory warm measurements are MO 0.961653s versus DuckDB 0.124928s, about 7.70×. Separate profiles measure 7.323 versus 0.979 application CPU seconds/query and 153.53 versus 15.17 billion retired user instructions/query (10.12×). MO's measured IPC is 4.42, versus 3.19 for DuckDB. Both native plans send 59,142,609 rows into the main group/projection pipeline and produce four groups. The gap is primarily additional executed work; storage reads, spills and swap were zero in these captures.

    I compared the profiled MO code with the pinned DuckDB C++ implementation, rather than inferring an explanation from language or percentages alone.

    Remaining MO cost center Exclusive user-CPU share Implementation difference
    Group-key/hash work about 21.4% MO retains string-key sizing/encoding/hashing; DuckDB uses compressed integer keys and direct-address grouping.
    Decimal arithmetic and aggregate updates about 30.5% MO materializes wider intermediates and retains wide/update bookkeeping; this DuckDB plan uses narrow arithmetic and statistics-proven SUM kernels.
    LZ4 decompression 12.6% RAM residency does not remove MO decompression; DuckDB's profile uses typed bitpacked scans/unpack kernels.
    Copies/zeroing about 4.8% Additional vector materialization remains visible.

    These are cost centers, not independent counterfactual speedup estimates. The decimal category includes SUM/AVG update work, not just type metadata.

    1. Four groups still incur generic string-key work on every row

    MO's prepareHashKeys sizes the encoded keys, and fillFlatCharStringHashKey reads/canonicalizes CHAR values and appends lengths/payloads before string hashing. The two functions alone account for 6.53% + 8.62%; hash insertion and related helpers add more. Having four result groups does not eliminate this work over roughly 59 million rows.

    DuckDB's native plan compresses the two group keys to tiny integers and uses PERFECT_HASH_GROUP_BY. Its PerfectAggregateHashTable::AddChunk derives a group location with arithmetic/bit shifts and computes state addresses once for the chunk. It then reuses those addresses across aggregate updates. That is a different algorithm from encoding and probing generic string keys.

    2. Optimizing a multiply loop did not narrow the entire decimal pipeline

    Fusion delivery clarification: #31987 is merged and present in this profiled build. The callchain reaches decimalMulSubExecutor.Eval -> TryDecimalMulSub64 -> d64MulInline, so the complete price*(1-discount) argument is already covered. The nested tax-adjusted Decimal256 argument is outside that matcher's admitted shape. EXPLAIN prints logical casts even when the matching runtime root is fused; those casts alone are not evidence of materialization. This distinction does not make the delivered PR unfinished or prove every remaining wider operation unnecessary.

    The recorded MO plan still contains DECIMAL128 casts and a DECIMAL256 tax-adjusted expression. The current d256Mul already has narrow arithmetic tiers, so it would be wrong to claim every row necessarily performs a full general 256-bit multiplication. Even when a narrow arithmetic tier succeeds, the carrier/result vectors remain Decimal256, with widening, 32-byte values and the separate result-precision pass.

    DuckDB's BindDecimalMultiply selects the physical arithmetic width and overflow behavior; its statistics callback can select the plain integer operation when justified. The actual CPU recording shows BinaryFunction<long,long,long,MultiplyOperator>.

    For SUM, SumPropagateStats checks value bounds times maximum cardinality before selecting a 64-bit sum_no_overflow state. That state is visible in this profile. MO's sumDecimal64FastExec.batchFill uses Decimal128 local sums, local group-slot lookup and counters; generic decimal updates retain their own mapping/wide-state work. DuckDB's typed scatter loops update the previously computed state addresses.

    #31034 is already in this main. Preserving expression precision and choosing a narrower physical pipeline are different questions. The remaining wide expression is not, by itself, proof that its declared SQL width is wrong. Any further narrowing needs valid range/overflow handling rather than simply deleting casts.

    3. Memory residency does not eliminate decoding and vector construction

    MO spends about 0.91 estimated user-CPU seconds/query in LZ4 alone, nearly DuckDB's 0.98 CPU seconds for the complete query. Callchains also show vector decode/cache-admission validation and copies. Those validation functions are inside MO, not dataset/result checks in the benchmark scripts. The DuckDB leaves show BitpackingScanPartial and specialized integer unpack routines. These different physical representations retain different CPU costs even with zero storage I/O.

    The remaining priorities indicated by this evidence are small-domain grouping/state-address reuse, narrowing or avoiding materialized decimal intermediates with correct overflow semantics, and decoded-vector reuse/less copying. Improving one existing arithmetic loop addresses only part of these costs; these recordings do not establish the speedup of any unimplemented fix.

    All figures above come from the already published recordings; no benchmark or profile was rerun for this explanation.

  5. aunjgr commented on Nov 3, 2026

    @aunjgr
    ContributorAuthor

    Optimization opportunities from the new SF10 profiles

    Evidence: disk-backed results #32072, all-memory results #32073, and raw profiles/exact binaries. MO source is dd2499cdcdf2722848851d4debca6cd6c66b4751. The relevant hot paths remain unchanged in newer main 1876b2f93e14c03ba538e3806e245e3c3203979a; that intervening change is in MinIO range reads. The captures are not relabelled as runs of that newer binary.

    The summed warm wall times are 13.381s MO / 2.038s DuckDB disk-backed, and 6.680s / 2.026s all-memory. These sum existing per-query medians, not a newly measured suite. Q1/Q21/Q19/Q9/Q10/Q12/Q18 account for about 62% of the all-memory wall-time difference. This investigation used existing recordings and source inspection; no query, benchmark, profile or server129 job was started.

    The important rebaseline: the cache-admission fix was reverted

    #31767 is merged in history but its behavior is not active: #31943 restored the reader cutoff following the reported 25.7% TPC-H 1T regression in #31868. That report has explicit run/cache-state limitations; the rollback did not prove the precise slowdown mechanism.

    Current reader.read adds SkipMemoryCacheWrites after the threshold. GetThresholdForReader(8) returns 128. MemCache.Update then returns without admission. The saved startup logs confirm the CN SHARED cache was initialized at 17,179,869,184 bytes, alongside smaller LOCAL/TN caches: the configured 16 GiB was real, but scan-position policy still suppresses late admission. Current cache occupancy/admission counters were not captured, so no exact occupancy is invented here.

    This explains a concrete route to repeated reconstruction on long scans. It is not a reason to blindly reapply #31767: a replacement must preserve one-pass/large-working-set behavior as well as repeated-query gains. This remains #30849, with encoded page-residency policy separately in #30848.

    Observed cross-query CPU budgets

    The following estimates sum exclusive user-CPU leaves across one normalized execution of each Q1–Q22 query. They identify cost centers, not achievable savings; optimization mechanisms can overlap and introduce other costs.

    Exclusive leaf family Estimated user CPU seconds Share of summed MO user CPU
    LZ4 decode 6.908 15.22%
    Int64 hash lookup 4.322 9.53%
    memmove 1.848 4.07%
    group insertion preflight 1.424 3.14%
    JSON-only payload check 0.500 1.10%
    string comparison and comparison body 0.801 1.76%
    exact int32/date selection 1.212 2.67%
    Date wrapper getter 0.668 1.47%
    Other exclusive user CPU 27.695 61.03%
    Total (all Q1–Q22 normalized user CPU) 45.378 100.00%

    This total is user CPU. Kernel CPU accounts for the difference from the published 47.653s aggregate application CPU. Function-level CPU costs cannot be treated as additive query wall time in parallel execution.

    1. Hoist non-JSON validation work out of every varlen value

    Confirmed code-level opportunity; small first PR. In validateVectorBinary, the type is fixed for the vector, but every live varlen value calls validateJSONPayload(typ, value.GetByteSlice(area)). The callee immediately returns for every non-JSON type. Consequently CHAR/VARCHAR still pay for extracting each payload and dispatching a JSON-only check.

    The new callchains place this in cache-miss reconstruction, not in benchmark verification. It costs about 0.50 normalized user CPU seconds across the all-memory query set: Q19 0.154s, Q1 0.146s, Q12 0.081s, Q10 0.067s. Some GetByteSlice work in the same callers is additional.

    Change direction: select the type-specific validation path once per vector. Keep varlen offset/length checks, NULL-slot rules, array alignment and all actual JSON validation. The already-existing validated-cache marker should remain; do not add a second marker or skip integrity checks. A first patch can limit itself to the JSON-only predicate/payload extraction.

    Acceptance: component coverage for ordinary strings, JSON, arrays, NULLs and malformed vectors; then local Q1/Q10/Q12/Q19 and Q1–Q22 wall-time controls. This is a new concrete mechanism within #30850/#30851, not a claim that the whole vector validator is unnecessary.

    Sources: per-value call, JSON-only guard, existing validation-on-cache-admission.

    2. Specialize constant CHAR comparison once per batch

    Confirmed current caller; another bounded candidate. CompareStringValues and cmpbody together account for about 0.80 normalized user CPU seconds: Q19 0.364s, Q10 0.326s. Callchains place these in TableScan.evalFilter -> equalFn, not in final string sorting.

    CompareStringValues resolves Unicode/byte-domain and CHAR rules on every call, and trims both operands for CHAR. The generic binary evaluator already hoists the constant's vector read, but does not pre-canonicalize that constant for the repeated CHAR comparison.

    Change direction: resolve comparison mode and canonicalize the constant once for the batch/expression, then use a typed flat-vector loop. Keep the existing path for unsupported domains and short/constant/nullable shapes. Preserve CHAR padding, empty-string equivalence, Unicode fallback identities and argument order for ordered comparisons. Do not repeat the already merged CHAR hash-key dispatch optimization; this is the scalar scan-predicate caller.

    Q10 wall is 409.8ms vs 136.3ms, Q19 457.1ms vs 90.4ms, all-memory. A lower comparison cost must improve these full queries without regressions. Track in #30850 with #30841 as related prior CHAR work.

    3. Replace scan-position cutoffs with bounded reuse-aware admission

    Largest shared CPU family; design required. LZ4 contributes about 6.91 normalized user CPU seconds across the all-memory set, even with zero physical I/O. Examples: Q1 12.6%, Q6 35.8%, Q19 19.3%, Q15 28.7% of MO user samples. This does not prove every decode was avoidable, but the restored cutoff supplies a specific missed-admission mechanism.

    Change direction: let repeated accesses become eligible under a bounded reuse/admission policy while protecting one-pass scans and existing hot data. Prefer using the existing cache/FIFO/ghost information and physical reservations over adding another unbounded cache. Preserve explicit caller suppression, leases and pressure handling. First characterize admission/bypass/eviction and constructor counts at real block sizes, not result rows.

    Do not simply remove the cutoff again, increase the cache capacity, or declare local SF10 wins sufficient. The large one-pass/1T regression is a mandatory counterexample. #30849 already tracks this; its older pre-revert comments must not be read as current behavior.

    4. Make encoded file-page retention reuse-aware too

    Separate I/O problem with known negative evidence. The disk-backed captures performed about 79.15 GiB of physical reads over repeated windows, while all-memory windows read zero. The two summed wall totals differ by 6.70s. That is observational storage evidence, not an isolated 6.70s speedup promise.

    LocalFS.read discards the content range after materialization regardless of whether the later memory-cache update actually retains it. This can combine with suppressed decoded admission to repeatedly lose both forms of reuse.

    Change direction: bounded per-read reuse/retention decisions, with charged file pages inside the same application budget. Keep decoded retention and OS encoded pages as separate resources. #30848 already records that blanket DONTNEED suppression improved Q6/Q21 but worsened Q1 through reclaim. That prevents a global "never discard" patch. Current native files, cold/one-pass and pressure/reclaim controls all matter.

    5. Low-cardinality grouping and aggregate state-address reuse

    High-value Q1 opportunity; larger than another CHAR sizing tweak. Q1 is 961.7ms vs 124.9ms and has 10.12× the instructions. Its group-key/hash family costs about 21.4% of user CPU. The source still sizes, canonicalizes and encodes generic string keys for roughly 59 million input rows, despite only four output groups.

    DuckDB's perfect aggregate table computes compact group locations and state addresses once per chunk. MO's SUM fast update and generic decimal SUM/AVG each perform their own local group-slot mapping.

    There are two separable directions: (a) compact small-domain group lookup with a correct fallback; (b) reuse dense group IDs/state addressing for small-group updates instead of rebuilding a local mapping independently per aggregate. The latter can be investigated without changing SQL plans or key semantics.

    Keep arbitrary domains/collations/NULL/GROUPING behavior, exact key encoding contracts, large-group fallbacks and accounting. Do not hard-code four groups or TPC-H CHAR values. Q18/Q20 high cardinality and tiny/empty inputs are required controls. Existing homes: #30841 and #30847.

    6. Decimal implementation delivery: already merged; remove the generic duplicate

    Correction: the earlier wording incorrectly treated the aggregate-root work as an unpublished candidate. #31987 merged as ce17fc588b58f346caae6ef7a78c5bb9ba10fd20 on 2026-11-01 and is an ancestor of the profiled dd2499cdcdf2 build. #30880/#30981 delivered cast setup work; #30885/#30983 delivered multiply dispatch; #31034 delivered intermediate precision; #31987 delivered the aggregate-root fusion. These implementations are not new work to repeat.

    The existing Q1 recording actually traverses decimalMulSubExecutor.Eval -> TryDecimalMulSub64 -> d64MulInline. The current matcher admits only a complete Decimal128 aggregate argument shaped x*(literal-y) with lossless Decimal64 leaves. It does not recursively fuse nested/shared expressions or Decimal256 roots. Native EXPLAIN retains the logical expression, so a displayed cast in a matching root is not proof that the fused executor materialized that cast.

    The Q1 tax-adjusted root price*(1-discount)*(1+tax) is outside that admission and retains a generic Decimal256 path, corroborated by generic multiply/widening callchains. Reuse of the common discounted-price product across the two SUM arguments is another potential distinct investigation. Neither observation proves the declared wider result is wrong, quantifies a new speedup, or means #31987 is unfinished.

    Disposition: remove the broad decimal-fusion item from the active next-PR list. Any nested-tax/shared-product extension needs its own range/overflow, evaluation/error, ownership and fallback design and current-source comparison. Do not revive the rejected global-fusion prototype. #30840/#30860 may retain broader performance-acceptance work, including SF100, without implying that the merged implementation is missing.

    7. Partial safe prefilters and selective varlen materialization

    Concrete exposure limit, substantial design. compileExactScanFilter rejects any varlen projection and requires every conjunct to compile. It only accepts fixed-width column/literal comparisons and BETWEEN; unsupported IN/OR or column-column comparisons reject the whole exact path.

    Thus Q12's simple receipt-date range cannot use this path together with its column-column date comparisons and shipmode; Q10/Q19 also carry text predicates/projections. Q12 wall is 317.4ms vs 59.2ms. Its Date GetValue leaves alone are 9.3% of user CPU. That getter is already a trivial slice read; the opportunity is reducing per-row virtual calls/materialization or how many rows reach it, not removing a nonexistent type check inside the getter.

    Change direction: admit only safe deterministic necessary prefilters, retain the full residual predicate, and materialize the required payload after selection. Supporting varlen outputs requires owned selected payload/area semantics and correct cache-lease lifetimes, not just deleting the eligibility guard. LZ4 is block-based: selecting fewer rows does not automatically reduce decompression or storage bytes when every block still has survivors. Measure decode, I/O, copy and predicate work separately. Preserve NULLs, error/volatile-expression behavior and original row order. #30850 is the existing home.

    The previous single-pass range experiment in #31785 failed its Q7 confirmation and was reverted. The lone-BETWEEN fallback is deliberate; do not undo it. Any compound-range fusion is a separately admitted experiment, not an already accepted fix.

    8. Reduce probes with actual shuffle-aware runtime filters

    Strong work-elimination evidence. In the current Q9 plans, MO's LINEITEM scan passes 59,986,052 rows, versus DuckDB's Bloom-filtered 3,445,118 (about 17.4× fewer). Both current PARTSUPP scans still pass 8 million rows; do not reuse an older assumption that this DuckDB capture prunes PARTSUPP.

    MO HashBuild.handleRuntimeFilter explicitly sends PASS for shuffle joins. This is the reachable branch to design for in Q9/Q21; raising a broadcast IN threshold does not fix it. FindBatch costs about 4.32 normalized user CPU seconds over the query set; reducing actual probe rows can remove more work than another scalar-probe rearrangement.

    Change direction: a bounded filter with correct global/partition scope and routing proof, acceptable false positives and no false negatives; preserve composite-key, NULL and canonical-key semantics. Bound exchange/wait/cancellation cost and retain PASS fallback when readiness/budget fails. Existing home: #30844. The prior probe-geometry candidate in #30846 regressed Q15 and was closed as not planned; it is not being reopened or proposed again.

    9. Batch ordered multi-source join gathers

    Q9 UnionOne is 6.9% of MO user samples, with callers under hashjoin.probe and appendUniqueMatches. Some memmove samples are instead under copyCachedVector: those are different owners and must not be conflated.

    The current unique-match helper already batches consecutive rows from the same build batch. Random build references split into single-row runs, which retain scalar append/admission overhead. Grouping all rows by build batch would reorder output and is not a valid shortcut.

    Change direction: a narrowly admitted ordered gather that reserves destination storage once while following the existing multi-source reference order; retain the one-row path where setup costs dominate. Cache-hit borrowing is a separate, more invasive lifetime/accounting design, not a generic zero-copy promise. Existing home: #30845. The rejected earlier gather prototype is negative evidence to retain, not a reason to assume a new helper will win.

    10. Improve the exact-IN fallback outside the existing bitmap domain

    Q17 still spends 42.8% of user CPU in runtime.mapaccess2_fast32 under opOperatorIntegerIn[int32].eval, about 0.604 CPU seconds/query. Wall time is 212.1ms vs 66.1ms.

    A bitmap already exists in the operator: sorted, non-NULL, at least 16 members, at most 64 KiB, and at most 8 bytes per input member after rounding. Adding another generic bitmap feature would duplicate #31140/#31257.

    The comparable native PART filter has 2,044 keys, and the DuckDB dynamic range is 2409–1999712: an ordinary exact bitmap needs about 249,663 bytes, versus the current 65,536-byte absolute cap and 16,352-byte per-member budget. This supports an admission-limit explanation for the observed map fallback; MO's actual RHS sorted flag/range were not captured, so the exact failed guard is not asserted.

    Change direction: first record representation eligibility/size/probe metadata; then compare bounded exact-set alternatives or an inexpensive prefilter plus exact fallback. Bloom alone cannot implement SQL IN/NOT IN. Preserve NULL three-valued logic, readiness/reuse and signed-endpoint arithmetic. Do not simply enlarge bitmap caps or add another map cache. #31140 is closed for its delivered scope; this is a distinct residual follow-up, not a reopening or proof that its fix failed.

    11. Restrict candidate key pairs before Q20 aggregation

    Current native plans show 5,441,669 MO intermediate aggregate groups versus 58,782 DuckDB groups (about 92.6×). Both already apply the year filter; the next change is not another date predicate. Q20 wall is 251.4ms vs 59.7ms. MO user samples include SUM batch updates 18.6% and group insertion 14.7%.

    Change direction: restrict eligible correlated aggregate work using candidate (partkey,suppkey) keys before building states. Use semijoin/deduplicated membership semantics so candidate duplicates cannot multiply SUM values. Preserve empty SUM/NULL/outer-correlation behavior and optimizer eligibility. This confirms the existing #30843 work-elimination target; group-count reduction is not a 92.6× wall-time prediction.

    What is not the next implementation

    Suggested next wave

    The most bounded independent starts are (1) non-JSON payload-check hoisting, (2) constant CHAR predicate specialization, and (3) small-group aggregate addressing with exact fallbacks. Their likely size and correctness boundaries are much clearer than a global hash or scheduler rewrite. In parallel at the design level, prioritize a bounded cache-admission replacement and shuffle-aware filtering because they can remove repeated work across many queries.

    Every eventual change must meet its issue's agreed wall-time/target/control criterion at the same effective budgets. Keep cold runs excluded, profiles separate from scoring, and source baselines isolated. Confirmed regressions block acceptance; no estimated CPU budget or favorable average waives them. SF100 runs only on server129 when authorized/available; the reported large one-pass counterexample remains required for cache-policy acceptance.

    No kernel code or issue state was changed by this investigation. The profile data are current evidence; proposed gains remain unmeasured.

  6. aunjgr commented on Nov 15, 2026

    @aunjgr
    ContributorAuthor

    Closing this completed measurement/reporting issue at the requester's direction.

    The 2026-11-03 local SF10 all-memory main-versus-DuckDB profiling round is complete. Its full results, per-query analyzed/raw profiles and exact software archives are published.

    The recorded source pins, results, downloads, methodology corrections and uncertainty remain the evidence for that historical round. Completion of this report does not certify current-main performance or close the optimization backlog. Remaining engine optimization work is tracked in #30838 and its subtasks; dictionary execution work remains in #32379.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions