Skip to content

Hold the L4 result with integer keys instead of strings #89

Backlog

Description

@rahlk

Is your feature request related to a problem? Please describe.

Follow-up to #62. The L4 result (sdg.Result) stays in memory until the Neo4j push finishes its second pass. On gitea v1.25.3, --emit neo4j in a 16 GB container now peaks at 13.8 GiB, against the 14 GiB target (#87). The peak comes during the second push pass, while the L4 result is still in memory, so the margin is 0.2 GiB.

The largest live allocations after the analysis are all L4 (gitea heap profile, #62):

  • sdg.sortedPortEdges: 1.47 GB
  • sdg.(*sdgBuilder).fill: 1.42 GB (5.31 GB cumulative)
  • sdg.(*ports).vertices: 0.88 GB
  • sdg.(*sdgBuilder).summaryEdges: 0.74 GB

PortEdge, Vertex and SummaryEdge (internal/sdg/ir.go) hold their keys as strings, each built separately, for example c12/actual_in:0.

Describe the solution you'd like

  • Store the keys as uint32 indices into a per-callable key table, and intern Var and Of.
  • The emitter's l4Overlay (emit/emit_l4.go) turns the indices back into keys while it writes a module.
  • No output change: analysis.json and graph.cypher stay byte-identical, and TestSDG_OutputUnchangedByMemoryLevers and the Neo4j stream parity tests stay green.
  • Measure gitea's peak before and after with the memory test (-tags memtest).

Estimated gain: 1.5 to 2.5 GB of gitea's 5.3 GB L4 result. This is an estimate, not a measurement. The change touches about four files in internal/sdg, plus l4Overlay and the sdg tests that build IR literals.

Describe alternatives you've considered

  • Stream the L4 result per callable instead of building it up front. Rejected: param edges and summaries are whole-program facts (computed in SCC order), so this is a redesign of internal/sdg.
  • Raise the 16 GB target. Not wanted (Reduce analysis memory at -a 4 #62).

Additional context

The two cheaper steps from #62, the Go memory limit and the per-stage memory log under -v, landed in #87.

Activity

  1. added
    enhancement
    Performance
    on Dec 1, 2026
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

    Performanceenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions