Skip to content

perf: speed up semantic index preparation - #10

Merged
aldegad merged 2 commits into
NomaDamas:mainfrom
thisisjun786:codex/katok-index-bulk-loader
Aug 12, 2026
Merged

perf: speed up semantic index preparation#10
aldegad merged 2 commits into
NomaDamas:mainfrom
thisisjun786:codex/katok-index-bulk-loader

Conversation

@thisisjun786

@thisisjun786 thisisjun786 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace per-parent SQLite lookups with two ordered bulk queries
  • reuse one parent-window snapshot across planning, document writing, and live indexing
  • bulk-load stored vector metadata and parallelize only in-memory hashing and file preparation
  • count candidate chunks with COUNT(*) instead of materializing every chunk through the N+1 hydration path
  • preserve atomic semantic generations, sequential SQLite mutations, and deterministic parent and child ordering

Why

katok index previously called all_chunks() only to compute candidate_chunks. Each chunk was then hydrated through several point queries, so index startup scaled as multiple SQLite reads per micro-chunk before any semantic output was written. Parent windows and stored vector metadata also used point-query loops.

The implementation keeps SQLite single-connection and single-writer behavior, loads immutable snapshots in bulk, and uses Rayon only after the data is owned in memory.

Verification

  • cargo +1.91.0 fmt --all -- --check - passed
  • cargo +1.91.0 clippy --all-targets -- -D warnings - passed
  • KATOK_EMBEDDER=local-test cargo +1.91.0 test --all-targets - passed, 170 tests
  • cargo +1.91.0 publish --dry-run - passed; upload correctly aborted because this was a dry run
  • python3 scripts/verify_release_config.py - passed
  • GitHub Actions CI run 31572087100 - passed
  • stale generation reuse, orphan removal, failed rebuild preservation, concurrent writer, bulk parent transaction, and candidate count regressions - passed

Synthetic benchmark

All measurements used generated rows and a temporary synthetic SQLite archive. No KakaoTalk archive or message content was used.

  • 5,000 parent windows with one child each, release build, one warm-up and seven measured loads per run
  • latest upstream/main medians across three runs: 51,461 / 54,340 / 55,572 us
  • feature medians across three runs: 3,382 / 3,378 / 3,406 us
  • observed improvement: 15.2x to 16.3x

Privacy boundary

Tests and benchmarks use synthetic fixtures only. No real KakaoTalk database, messages, semantic documents, embeddings, or derived private data are included in this branch.

@thisisjun786
thisisjun786 marked this pull request as ready for review August 10, 2026 02:42

@aldegad aldegad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused indexing work. The implementation and the pinned local checks look good. Before merge, please remove docs/superpowers/plans/2026-08-10-katok-index-bulk-loader.md, rebase onto the latest main, and rerun the repository CI. The submitted change should contain the implementation, tests, and user-facing documentation only.

@aldegad
aldegad force-pushed the codex/katok-index-bulk-loader branch from e475e7e to 6ee94e7 Compare August 12, 2026 06:58

@aldegad aldegad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes are complete: the repository-only plan document is gone, the branch is rebuilt directly on the latest main, and the pinned CI workflow passes. I also verified the atomic semantic generation and stale/orphan recovery contracts against the new bulk preparation path using synthetic fixtures only.

@aldegad
aldegad merged commit e30b810 into NomaDamas:main Aug 12, 2026
1 check passed
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.

2 participants