← Back to Pull requests

ebpf: optimyze native stackdelta map #2103

Closed
unknown closed this pull request without merging on Nov 18, 2026 12:56 UTC
View on GitHub
unknown unknown commented on Nov 10, 2026 13:23 UTC
Author

The stack_delta_page_to_info is problematic for sparse stackdeltas (e.g. Go executables with huge framepointer areas) as it is a global hash that limits total amount of pages in a system.

Refactor stack delta data structures as follows to optimize ebpf map memory overhead:

  • Remove stack_delta_page_to_info, and put the FileID specific data needed to end of the inner exe_id_to_XX_stack_deltas data area. This allows removing stack_delta_page_to_info and its static overhead.

  • Store a StackDeltaPair instead of StackDelta in the inner map because kernel rounds up the element size to 8 bytes. This effectively halves the amount of memory used for stack deltas.

  • The above inner exe_id_to_##X##_stack_deltas entries now are either a StackDeltaPair or a StackDeltaPageDesc.

  • A new exe_id_to_stackdelta_meta hash map (one per FileID) replaces the other half of stack_delta_page_to_info and maps the lookup to correct stack delta map with needed meta data.
  • To accommodate the data structure changes:

  • Every page slice is padded to a pair boundary with a duplicate of the page's last delta, so the binary search always compares the first element of a pair.

  • One less binary search iteration is needed as we compare pairs reducing code size.

  • Pages without own deltas have an empty pair range that resolves to the covering delta of a previous page, replacing the routing of the retired page map.

  • Optimize ebpf stack delta updates to avoid memory allocation and copying where possible.
  • Bloat check report using tooling from #2113:
    | program/function | amd64 | diff | arm64 | diff |
    |---|---:|---:|---:|---:|
    | unwind_native | 1348 | -27 | 1760 | -43 |
    | unwind_python | 1965 | +7 | 1973 | -6 |
    | Total insns | 21431 | -20 | 21876 | -49 |
    | .rodata bytes | 18730 | -32 | 16404 | -34 |
    | File bytes | 496184 | -440 | 498576 | -688 |

    Diff: 233 lines (+174 / -59) across 2 files Reviewer: wehzzz Review duration: 11493m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 233 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.326
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2103"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.1% (MEDIUM) · Higher = larger blast radius
    37.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.6% · Safe to merge
    14.6%