Skip to content

perf(data): fill the Data tab index from raw column bytes - #33

Open
A13xB0 wants to merge 3 commits into
feat/data-tabfrom
perf/data-fill-raw-bytes
Open

A13xB0 wants to merge 3 commits into
feat/data-tabfrom
perf/data-fill-raw-bytes

Conversation

@A13xB0

@A13xB0 A13xB0 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Requires #16 first. This is built on feat/data-tab, and the PR targets that branch.

Problem

The Data tab fill (readPackets) reads every packet of the window with every observation. For each observation it:

  • scanned the ~420-character resolved_path and the path into strings;
  • copied both into []byte for the decoder;
  • decoded the resolved path into a pointer per hop and copied it again;
  • declared its scan targets inside the row loop.

A fill landing on top of the store's startup load is what set off the pre-prod OOM kills (see #16).

Change

  • The JSON columns are scanned as sql.RawBytes and read straight from the driver's buffer.
  • Arrays of escape-free strings and nulls (every one on live data) are read in place, with each distinct hop or key held once per read. Anything else is decoded as before.
  • decoded_json is selected only for the payload types that use it (4, 5, 6).
  • The scan targets are declared once.
  • The output is identical, pinned against a copy of the previous code with odd JSON included.

Measured

before after
allocated by one fill (copy of a busy week) 862 MB 581 MB
fill time 4.07 s 2.62 s
server CPU over the run 86.6 s 79.1 s
fixture, bytes per packet with one observation 2390 1735

Tests

  • TestDataReadPacketsAllocationsPerObservation (limit 2000): red commit first, then green.
  • TestDataReadPacketsMatchesReference compares against the previous readPackets on the Data fixture plus edge rows: null hops, [], invalid JSON, non-string elements, escapes.
  • go test ./cmd/server passes.

No config or UI changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H

A13xB0 and others added 2 commits October 11, 2026 03:43
Red: readPackets allocates about 2390 bytes per packet with one
observation on the fixture (limit 2000). The equivalence test compares
it with a copy of itself as it stands, odd JSON included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
readPackets reads every packet of the window with every observation. It
scanned each observation's resolved_path (~420 chars on live data) and
path into strings, copied them into []byte for the decoder, decoded the
resolved path into a pointer per hop and copied it again, and declared
its scan targets per row.

The JSON columns are now scanned as sql.RawBytes and read from the
driver's buffer. Arrays of escape-free strings and nulls (all of them on
live data) are read in place, with each distinct hop or key held once per
read; anything else is decoded as before. decoded_json is selected only
for the payload types that use it, and the scan targets are declared
once. The output is identical (pinned against the previous code, odd JSON
included).

On a copy of a busy week: allocated by one fill 862MB -> 581MB, fill
time 4.07s -> 2.62s, server CPU over the run 86.6s -> 79.1s. Fixture:
2390 -> 1735 bytes per packet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
@A13xB0 A13xB0 added upstream: not submitted Fork only so far; not opened upstream performance Memory or speed improvement live: pre-prod In the image running on CoreScope pre-production labels Oct 11, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
A13xB0 added a commit that referenced this pull request Oct 14, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live: pre-prod In the image running on CoreScope pre-production performance Memory or speed improvement upstream: not submitted Fork only so far; not opened upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant