Skip to content

Declaration bundling peaks at ~9 GB on the ontology integration branch #653

Closed

Description

@pdlug

Observation

The tsup declaration bundle (dts: true in packages/typegraph/tsup.config.ts) now peaks at about 9.3 GB of resident memory in the DTS worker, measured with /usr/bin/time -l node --max-old-space-size=12288 node_modules/tsup/dist/cli-default.js on the integration branch that combines the ontology and semantics program (acyclic relations, composition, typed subsumption, identity transition log, meta-edge removal). On main the same build fits under 6 GB. The largest emitted chunk grew only from 392 KB to 432 KB over the same span, so output size does not explain a ~50% jump in bundling memory.

The CI ceiling has been raised twice to keep the build running (#643 to 8 GB, #652 to 12 GB). Public runners have 16 GB, so there is one more bump left before the build stops fitting at all.

Suspects

  • Deeply nested conditional/mapped types on the public query surface (the polymorphic supertype default and includeNarrower, parts() / wholes() return-type generics) expanding during declaration rollup.
  • One dts rollup for every entrypoint re-traversing the same backend and store type graph; per-entrypoint memory is not freed between rollups inside one worker.

Options to evaluate

  • experimentalDts: true (TypeScript's own declaration emit plus a lighter rollup) and compare peak RSS.
  • Emitting declarations once and rolling entrypoints from that emit rather than from source per entrypoint.
  • Measuring which entrypoint's rollup drives the peak (--dts-only per entry) and whether one type family dominates.

The 12 GB ceiling is a stopgap; the fix is to bring the bundle back under the previous ceiling.

Activity

  1. added
    bugSomething isn't working
    on Sep 9, 2026
  2. added a commit that references this issue on Sep 11, 2026
    c276098
  3. pdlug commented on Sep 11, 2026

    @pdlug
    ContributorAuthor

    Fixed on the integration branch for #637 (no release carried the defect); closing now rather than waiting for the merge to main.

  4. added a commit that references this issue on Sep 23, 2026
    6d8cb0e
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions