Skip to content

perf(json): bound the row JSON viewer for large values (memory) - #23

Closed
broisnees wants to merge 1 commit into
masterfrom
feat/json-viewer-large-perf
Closed

broisnees wants to merge 1 commit into
masterfrom
feat/json-viewer-large-perf

Conversation

@broisnees

Copy link
Copy Markdown
Collaborator

Fixes memory blowups when expanding a row whose JSON is very large (e.g. resume_parsing rows — a Buffer serialized as a data byte array of thousands of numbers, or large jsonb).

Root cause

In the row expand viewer's Raw mode, the preview (truncateDeep) truncated long strings but kept every array item and object key. So for a big byte array, displayText ballooned to the full size, then got JSON-stringified and (below the 12 KB limit) syntax-highlighted — building a span-per-token HTML string. That's the memory hog.

Fix

RowExpandViewer.svelte (Raw view):

  • Cap arrays/objects to 200 children in the preview (strings already capped), with a … N more items marker. Bounds the stringified size regardless of how big the value is.
  • Track whether anything was truncated and skip per-token highlighting for any large/truncated value — render plain escaped text instead (this is what was requested). Also skips the link-scan pass in that case.
  • Copy JSON still copies the full, untruncated value.

JsonTree.svelte (Tree view):

  • Stop materializing a [index, value] tuple for every element of a huge array just to show its count — use .length for the summary and build only the currently-visible children (up to the page limit).

Verification

npm run build passes. Applied live in a running tauri dev session (HMR, no errors). Disjoint files from #20/#21/#22.

The row expand viewer could blow up memory on rows with big JSON (e.g.
resume_parsing's Buffer 'data' byte arrays / large jsonb):

- Raw view: the preview kept every array item / object key (only strings
  were truncated), so displayText ballooned, then got stringified and
  highlighted. Now cap arrays/objects to 200 children in the preview and
  skip per-token highlighting entirely for any truncated/large value
  (plain escaped text). Copy JSON still copies the full value.
- Tree view: stop materializing a tuple for every element of a huge
  array just to show its count — use .length for the summary and build
  only the currently-visible children.
@changeset-bot

changeset-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 785e64f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@broisnees

Copy link
Copy Markdown
Collaborator Author

Superseded by combined minor-release PR #36 (same changes, rolled up). Closing to keep a single merge.

@broisnees broisnees closed this Jul 5, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant