Skip to content

perf(spiraldb): remember read keys as 16-byte digests (ITL-1464) - #570

Closed
eywalker wants to merge 5 commits into
mainfrom
eywalker/itl-1464-seen-keys
Closed

eywalker wants to merge 5 commits into
mainfrom
eywalker/itl-1464-seen-keys

Conversation

@eywalker

Copy link
Copy Markdown
Contributor

Draft, for ITL-1464 (stays open). Stacked on #558; review only the last commit.

A SpiralDBTableSource read remembers every row's key for the whole read, to find a key that appears in two rows. It kept the keys' text in a Python set, about 0.3 KiB a row: with the source-info tokens gone it is the largest part of a row-by-row step that still grows with the table. It now keeps 16-byte BLAKE2b digests in sorted numpy arrays (SeenKeys), 16 bytes a row. Same check, same error and message.

A digest is 128 bits, so two different keys with one digest are not expected in any table (for a billion rows, about one chance in 10^21): a digest seen is taken as the key seen, without keeping the text to confirm it.

Not done: keeping nothing at all for a keyed table pinned to one version. No evidence at hand shows that such a scan cannot return a key twice.

Tests: test_seen_keys.py (the answers of a set, over random batches; any text; nothing added by a refused batch; 16 bytes an identifier). The SpiralDB source tests pass unchanged. No hash, identity, stored layout or golden value moves.

Mentions ITL-1464.

🤖 Generated with Claude Code

eywalker and others added 5 commits November 25, 2026 00:56
…one (ITL-1464)

A SpiralDBTableSource read whose table holds no source-info column and no
content hash built one token per row and data column, then dropped them. On
2.2 million rows of 13 columns that was 9.3 GiB of Arrow memory for a 282 MiB
table. The read now builds them only when its result shows or hashes them.

Adds the memory diagnosis (docs/dev/specs/itl-1464-memory-diagnosis.md) and
the scripts it was measured with.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…464 material

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/orcapod/core/sources/seen_keys.py 100.00% <100.00%> (ø)
src/orcapod/core/sources/spiraldb_table_source.py 98.09% <100.00%> (+0.29%) ⬆️
src/orcapod/core/sources/stream_builder.py 98.87% <100.00%> (+<0.01%) ⬆️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eywalker

eywalker commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of the ITL-1464 draft group. The async-route work continues as ITL-1347 stage 5 (ITL-1845). The SpiralDB read work landed in #687 and #679, and continues in #683.

Posted by a Claude Code agent on behalf of @eywalker.

@eywalker eywalker closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant