Skip to content

Memo example memo-ratio-of-quantiles.json is 2.9 MB: store each schema once and write the memo section compact #1033

Open

Description

@zzylol

Problem, by example

tools/dag-viewer/examples/memo-ratio-of-quantiles.json, the memo example for

avg by (job) (quantile_over_time(0.5, data[5m]) / quantile_over_time(0.5, data[5m]) + quantile_over_time(0.9, data[5m]))

is 2,895,266 bytes on main. #1031 shrank it from 13.8 MB by storing each memo node once in memo.nodes. The target in #1027 was under 1 MB, and the example still misses it.

Measured on main (f49900b):

Part Bytes
Whole document, pretty-printed (as committed) 2,895,266
Whole document, compact JSON (separators=(',', ':')) 1,154,941
memo.nodes[*].schema, compact 391,263
memo.nodes count / distinct schemas among them 1,099 / 15

Over a third of the compact size is the 1,099 copies of only 15 distinct schemas. The rest of the pretty-printed size is indentation.

Why

  • stage_pipeline writes the document with serde_json::to_writer_pretty.
  • Each entry of memo.nodes carries its full output schema, although almost every node shares its schema with many others. Typical cases: a candidate's estimate and its finalize, or the 336 PaneChain state groups.

Proposal

  1. Schema table. Store each distinct schema once as memo.schemas, and have each node in memo.nodes hold schema: <index>. memoNodeDag in tools/dag-viewer/stages.js resolves the index when it rebuilds a DAG, so memo.js and enumeration.js don't change.
  2. Compact JSON. Write the committed memo examples compact.
    • Alternative: pretty-print everything except memo.
    • Estimated with both: about 1,154,941 − 391,263 + ~30,000 ≈ 0.8 MB.

Only the memo section changes format. Documents without memo stay as they are.

Scope and acceptance

Related

Activity

  1. added
    enhancement
    dag-viewer
    dev-tools
    on Oct 28, 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

    dag-viewerdev-toolsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions