Skip to content

[Profile #478] Add hardware-counter profiling for every canonical losing hot path #499

Open

Description

@godofecht

Parent: #478. Related: #479-#488 #498.

Wall-clock and Python/native attribution are not enough to distinguish compute, memory, branch and vectorization failures. Add Linux perf/PMU profiling where available and equivalent macOS sampling/counter evidence where practical.

Capture cycles, instructions/IPC, branch misses, cache misses, vectorization/code-shape evidence and hot symbols for each canonical losing operation, with a portable fallback when counters are unavailable. Normalize interpretation by work units rather than comparing raw counters across machines.

Acceptance: every current canonical loss has a saved hot-symbol/profile report; issues #479-#488 cite the dominant bottleneck class before optimization; post-fix profiles demonstrate whether the intended bottleneck actually moved.

Activity

  1. godofecht commented on Aug 26, 2026

    @godofecht
    OwnerAuthor

    I worked through the normalization layer for this profile work and archived the full derivation + Flow witness in godofecht/OpenProjects as ml/work-normalized-hardware-counter-decomposition.md / .flow.

    The key identity is exact:

    (cycles/work)_Flow / (cycles/work)_ref = [(instructions/work)_Flow / (instructions/work)_ref] * [IPC_ref / IPC_Flow].

    So every cycle loss can first be split cleanly into dynamic instruction inflation versus IPC degradation before looking at branch/cache evidence. This avoids a common misdiagnosis: a Flow path can be slower while having better IPC if it simply retires far more instructions per unit work. The fixed witness is cycle ratio = 1.5, instruction ratio = 1.8, IPC penalty = 0.8333....

    Branch and cache misses admit the same exact secondary split: misses/work = references(or branches)/work × miss-rate. Those should remain secondary evidence for the IPC term rather than being converted into additive guessed cycle penalties, because PMU stall causes overlap.

    The profile artifact should therefore store raw counts + event definitions for audit, but diagnose using same-machine Flow/reference ratios normalized by the certified logical work unit. Repetition count cancels exactly when counts/work scale together, so longer PMU profiling runs remain comparable to shorter timing runs.

    I locally tested the primary identity over 100,000 random positive counter/work tuples; maximum relative floating error was ~4.43e-16. The adjacent Flow experiment covers instruction-inflation, pure-IPC, mixed, branch/cache decomposition, and repetition invariance.

    No hosted CI/workflow run was added or used.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions