Skip to content

[Subtask]: Attribute and reduce allocation, minor-fault and kernel CPU costs in warm execution #30851

Open

Description

@aunjgr

Parent Issue

#30838

Detail of Subtask

Evidence reassessment — 2026-10-26

Current delivery/performance status: CAUSAL DIAGNOSIS REQUIRED before selecting pooling, GC, allocator or NUMA changes.

Observed: Historical SF100 Q18 has about 3.24M MO minor faults/call and 90.26 system CPU s (~24%); Q20 about 1.39M and 55.97 s (~35%), versus about 0.248M/0.0146M DuckDB minor faults for Q18/Q20. Major faults/physical I/O/swap are zero. Q6 also has about 9.08% native allocator mutex samples. User-only captures cannot explain kernel stacks; cgroup-v1 total/user/system counters are not exactly additive.

Not yet established: Which faults, allocations, mappings, zeroing, synchronization or syscalls cause the cost; how much belongs to query operators versus engine maintenance. All 22 SF10 callchains were rechecked: explicit mergeObjectsTask ancestry accounts for 11.27%/7.10%/7.82% of Q1/Q9/Q18 user samples. Some UnionOne leaves are entirely maintenance work. Process-wide CPU is not automatically query-operator CPU; separate profiles do not establish maintenance activity in every scored window.

Next discriminating experiment: Separate foreground operators, native allocation, maintenance and kernel CPU using stacks/counters where permitted. Record repeated warm executions, retained bytes and mapping/first-touch behavior. Preserve unknown attribution explicitly when kernel data is unavailable.

Measured target: Reduce attributed allocation/system CPU and target latency in Q18/Q20 or the demonstrated allocator case, without higher unbounded retention.

Mandatory controls and total cost boundary: Repeated and low/high-cardinality runs, pressure, cancellation, release/reset and background-work state. A lower fault count or allocator sample percentage alone is not acceptance.

Performance acceptance and rejection

  • Freeze current-main/candidate sources, executables, real caller shapes and effective settings. Use the unchanged qualification SQL and complete result consumption; exclude cold runs and keep profiles separate from latency scoring.
  • Demonstrate the named work/CPU reduction and an attributable uninstrumented target-query improvement. Include the controls below and full Q1-Q22 comparison; component wins, source changes, functional tests, SCA, merging and profile percentages are separate evidence.
  • A confirmed affected/control slowdown fails; unresolved slower signals are inconclusive. Confirm with an independent longer balanced run. No gain elsewhere, favorable average or self-approved tolerance waives a regression.
  • Complete applicable SF10/SF100 and memory/mixed-I/O acceptance before issue closure under the umbrella protocol. Report uncertainty, absolute CPU/instructions/work, allocations/copies and the same whole-application budget, effective cache, I/O/spill/swap/pressure evidence. Benchmark scripts do not verify input/table/schema/row counts/reference results/checksums.

Semantics and lifecycle requirements retained

  • A causal diagnosis identifies the dominant system/allocator paths and separates single-query warmed replays from scored suite resources.
  • The chosen fix demonstrates reduced system CPU/minor faults or native mutex cost for equivalent work; report user CPU, peak retained memory and uninstrumented latency too.
  • Include repeated execution, high/low-cardinality, cancellation and memory-pressure controls with no unbounded pool/arena growth.
  • Exclude the cold run and keep profiling separate from scoring; report perturbation and residual unknown kernel/off-CPU time explicitly.

Describe implementation you've considered

Choose a bounded reuse, allocation-layout or synchronization change only after identifying its owner and causal cost. Compare retained capacity and cleanup costs; do not suppress faults by retaining all peak memory or assume the issue is Go GC.

Coordination: #30847 owns aggregate state; #30852 critical path. Keep direct system counters separate from total-minus-user residuals.

Additional information

Pinned implementation / plan references

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. added
    severity/s0
    on Oct 22, 2026
  3. aunjgr commented on Oct 31, 2026

    @aunjgr
    ContributorAuthor

    Current-main SF10 allocation/system-CPU diagnosis — 2026-10-31

    Main 1565fb79ab3a230f0e383300b5be47a4b7ae6cda; two independent Q18/Q20 processes, 32 warm executions each, first/cold call excluded. Eight physical application CPUs, metric-verified 16 GiB SHARED CN cache, 32 GiB whole-application budget. These are separate instrumented diagnostic replays, not latency scores or a DuckDB comparison. Unrelated LLVM/LTO activity failed the CPU/compiler gates; no performance PASS is claimed.

    Direct OS counters, normalized per completed warm call

    CPU values use the separate cgroup user/system fields, not total-minus-user residuals. Page-fault deltas come from cgroup memory.stat; major faults were zero. This accounting covers the application group and is not automatically a single operator’s CPU.

    Query Calls User CPU s/call System CPU s/call System share of measured CPU Minor faults/call Conservative peak GiB
    Q18 32 2.499587 0.097831 3.77% 17816.22 8.101
    Q20 32 1.823553 0.125980 6.46% 6305.88 7.507

    Both diagnostic windows had zero measured physical reads/writes, spilling, application swap, OOM and sustained cgroup memory pressure. The host CPU/compiler checks failed. All services exited and owned data-stage directories were removed. Scripts did not verify input/schema/table/row/reference/result/checksums; operator row counts in the separate plan capture are engine diagnostics.

    Caller attribution

    Each sampled user cpu-clock period is counted once. Explicit mergeObjectsTask ancestry takes precedence over operator ancestry; GC and unknown stacks stay separate. This avoids adding overlapping cumulative frames.

    Query Sampled user CPU s Operator/pipeline ancestry Explicit mergeObjectsTask ancestry Go GC ancestry Other/unknown
    Q18 80.051 98.33% 0.00% 0.26% 1.40%
    Q20 58.485 98.15% 0.00% 0.57% 1.28%

    Q18’s largest user leaves are Int64HashMap.PlanInsertBatch (40.54%), decimal SUM batchFill (10.40%), LZ4 decode (8.69%) and vector unionBatch (4.78%). Q20 has SUM batchFill (19.45%), PlanInsertBatch (14.54%), LZ4 decode (6.87%), DATE parameter access (4.65%) and TableScan.evalFilter (4.49%). All observed LZ4 leaf periods in these captures have operator/pipeline ancestry; none has explicit mergeObjectsTask ancestry. Absence of that marker does not prove all maintenance absent. Go GC is a small user-space share here; that does not explain kernel CPU.

    Baseline correction: cache policy was reverted

    PR #31767 merged on 2026-10-29, then #31943 intentionally reverted it on 2026-10-31, following the reported 25.7% TPC-H 1T slowdown in #31868. Current main restores readBlockCnt > threshHold => SkipMemoryCacheWrites; with eight readers the threshold is 128. A large configured cache therefore does not guarantee admission of every warmed decoded column. These captures observe about 393–412 MiB SHARED cache occupancy under a 16 GiB capacity. Foreground decompression is consistent with that restored policy; the precise current per-reader reconstruction count was not newly instrumented.

    The pre-revert warm-cache gains remain historical source-pinned evidence, not current-main scores. This task does not undo the deliberate revert. A replacement admission policy needs separate bounded scan-pollution/large-workload evidence.

    Decision

    No new allocator/pool patch is justified by these captures. The current allocator already has an exact-size mmap cache bounded by min(GlobalCap/4, 1 GiB), with one-second idle release and MADV_FREE handling. Increasing retention or assuming Go GC is the culprit would be unsupported. Current user CPU instead prioritizes transactional group insertion/preflight, aggregate updates and the separately tracked decoded-cache policy. The original SF100 kernel/fault mechanism remains unproven by this SF10, shared-host capture: profiles record user-space only, so kernel stack attribution and quiet-host validation remain open. #30851 stays open.

    Raw aggregate counters and resource receipts
    {
      "18": {
        "calls": 32,
        "user_cpu_s": 79.98679,
        "system_cpu_s": 3.130603,
        "pgfault": 570119,
        "pgmajfault": 0,
        "quality": {
          "accepted_all_memory": false,
          "gates": {
            "complete": true,
            "workload_complete": true,
            "zero_physical_reads": true,
            "zero_spill_events": true,
            "zero_swap": true,
            "zero_oom": true,
            "no_sustained_pressure": true,
            "ram_native_image": true,
            "zero_physical_writes": true,
            "background_cpu_window": false,
            "software_in_memory_budget": true,
            "software_pages_pinned": true,
            "compiler_free_window": false
          },
          "physical_read_bytes": 0,
          "physical_write_bytes": 0,
          "cpu_seconds": 83.117392,
          "peak_memory_bytes": 8152952832,
          "peak_quality": "window",
          "reclaim_deltas": {
            "pgscan": 0,
            "pgscan_direct": 0,
            "pgscan_kswapd": 0,
            "pgsteal": 0,
            "pgmajfault": 0
          },
          "memory_pressure_microseconds": {
            "some": 0,
            "full": 0
          },
          "swap_bytes_before_after": [
            0,
            0
          ],
          "spill_events": 0,
          "ram_image_bytes": 5909600898,
          "shmem_bytes_before_after": [
            6044884992,
            6045188096
          ],
          "pinned_file_bytes": 0,
          "unevictable_bytes_before_after": [
            0,
            0
          ],
          "scope": "query completion/provenance/resource metadata only; no TPC-H result or input verification",
          "software_pinned_bytes": 545645948,
          "conservative_application_bytes": 8698598780
        }
      },
      "20": {
        "calls": 32,
        "user_cpu_s": 58.353703,
        "system_cpu_s": 4.031369,
        "pgfault": 201788,
        "pgmajfault": 0,
        "quality": {
          "accepted_all_memory": false,
          "gates": {
            "complete": true,
            "workload_complete": true,
            "zero_physical_reads": true,
            "zero_spill_events": true,
            "zero_swap": true,
            "zero_oom": true,
            "no_sustained_pressure": true,
            "ram_native_image": true,
            "zero_physical_writes": true,
            "background_cpu_window": false,
            "software_in_memory_budget": true,
            "software_pages_pinned": true,
            "compiler_free_window": false
          },
          "physical_read_bytes": 0,
          "physical_write_bytes": 0,
          "cpu_seconds": 62.385072,
          "peak_memory_bytes": 7514574848,
          "peak_quality": "window",
          "reclaim_deltas": {
            "pgscan": 0,
            "pgscan_direct": 0,
            "pgscan_kswapd": 0,
            "pgsteal": 0,
            "pgmajfault": 0
          },
          "memory_pressure_microseconds": {
            "some": 0,
            "full": 0
          },
          "swap_bytes_before_after": [
            0,
            0
          ],
          "spill_events": 0,
          "ram_image_bytes": 5909600898,
          "shmem_bytes_before_after": [
            6044921856,
            6045052928
          ],
          "pinned_file_bytes": 0,
          "unevictable_bytes_before_after": [
            0,
            0
          ],
          "scope": "query completion/provenance/resource metadata only; no TPC-H result or input verification",
          "software_pinned_bytes": 545645948,
          "conservative_application_bytes": 8060220796
        }
      }
    }
    Raw sampled caller periods (nanoseconds)
    {
      "18": {
        "samples": 7925,
        "period_unit": "user CPU nanoseconds, sampled cpu-clock:u",
        "total_period": 80050504250,
        "exclusive_sample_groups": {
          "operator/pipeline ancestry": 78717170930,
          "other/unknown": 1121212110,
          "Go GC ancestry": 212121210
        },
        "lz4_leaf_by_ancestry": {
          "operator/pipeline ancestry": 6959595890
        },
        "top_exclusive_leaves": [
          [
            "github.com/matrixorigin/matrixone/pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch",
            32454545130
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill",
            8323232240
          ],
          [
            "github.com/pierrec/lz4/v4/internal/lz4block.decodeBlock.abi0",
            6959595890
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/vector.(*Vector).unionBatch",
            3828282790
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/sql/colexec/group.(*container).preflightBuildChunk",
            3212121180
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/hashtable.(*Int64HashMap).CommitInsertBatchPlan",
            2979797950
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/hashtable.(*Int64HashMap).rehashInPlace",
            2282828260
          ],
          [
            "runtime.memclrNoHeapPointers",
            1808080790
          ],
          [
            "runtime.memmove",
            1474747460
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/vector.(*FunctionParameterWithoutNull[github.com/matrixorigin/matrixone/pkg/container/types.Decimal128]).GetValue",
            656565650
          ],
          [
            "runtime.mapaccess2_fast64",
            646464640
          ],
          [
            "__vdso_clock_gettime",
            595959590
          ]
        ]
      },
      "20": {
        "samples": 5790,
        "period_unit": "user CPU nanoseconds, sampled cpu-clock:u",
        "total_period": 58484847900,
        "exclusive_sample_groups": {
          "operator/pipeline ancestry": 57404039830,
          "other/unknown": 747474740,
          "Go GC ancestry": 333333330
        },
        "lz4_leaf_by_ancestry": {
          "operator/pipeline ancestry": 4030302990
        },
        "top_exclusive_leaves": [
          [
            "github.com/matrixorigin/matrixone/pkg/sql/colexec/aggexec.(*sumDecimal64FastExec).batchFill",
            11373737260
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/hashtable.(*Int64HashMap).PlanInsertBatch",
            8505050420
          ],
          [
            "github.com/pierrec/lz4/v4/internal/lz4block.decodeBlock.abi0",
            4020201980
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/vector.(*FunctionParameterWithoutNull[github.com/matrixorigin/matrixone/pkg/container/types.Date]).GetValue",
            2717171690
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/sql/colexec/table_scan.(*TableScan).evalFilter",
            2626262600
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/hashtable.(*Int64HashMap).rehashInPlace",
            2565656540
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/sql/plan/function.opBinaryFixedFixedToFixed[go.shape.int32,go.shape.int32,go.shape.bool]",
            2141414120
          ],
          [
            "runtime.memmove",
            1767676750
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/hashtable.(*Int64HashMap).FindBatch",
            1535353520
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/common/hashmap.fillKeys[go.shape.uint32]",
            1464646450
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/vector.(*Vector).unionBatch",
            1272727260
          ],
          [
            "github.com/matrixorigin/matrixone/pkg/container/vector.shrinkFixed[go.shape.int32]",
            1111111100
          ]
        ]
      }
    }
  4. assigned and unassigned on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/subtaskseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions