th-2e1ad2: batch-load pearl labels — session start 5.7s → 0.7s#243
Merged
Conversation
🦋 Changeset detectedLatest commit: ec90e65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
brentrager
enabled auto-merge (squash)
July 22, 2026 16:52
brentrager
force-pushed
the
th-2e1ad2-batch-labels
branch
from
July 22, 2026 16:57
a87164f to
90e7a7f
Compare
…tart 5.7s `th prime` (SessionStart) runs `th pearls ready`, which returned ~40 open pearls then fired one more Dolt query PER pearl to load labels. Each Dolt call cold-boots (~140ms), so list-style reads cost 1 + N round-trips — `th agent list` (1 query) 0.5s vs `th pearls list` (1+N) 4.7s against the same DB. Add `attach_labels(Vec<Pearl>)`: one `SELECT ... WHERE pearl_id IN (...)` groups labels in Rust, order preserved, label-sorted. Wire it into ready/list/blocked/ search/due_scheduled (the single-pearl get path keeps load_pearl_with_labels). Measured on the real 1200-pearl store: `th pearls ready` 5.7s -> 0.7s warm. Regression test asserts per-pearl labels with no cross-contamination. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ZctFb4oiWoJraHN2db1nX
brentrager
force-pushed
the
th-2e1ad2-batch-labels
branch
from
July 22, 2026 22:39
90e7a7f to
ec90e65
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
th primeruns on every SessionStart and callsth pearls ready— 5.7s against a 1200-pearl store. Root cause:ready/list/blocked/search/due_scheduledreturned the matching pearls in one query, then fired one more Dolt query per pearl to load labels (N+1). Each Dolt call cold-boots (~140ms), soth agent list(1 query) is 0.5s whileth pearls list(1+N) is 4.7s on the same DB.Fix
attach_labels(Vec<Pearl>)— a singleSELECT pearl_id, label FROM pearl_labels WHERE pearl_id IN (…), grouped in Rust (order preserved, label-sorted). Wired into all five list-style reads. The single-pearlgetpath keepsload_pearl_with_labels(1 pearl = 1 query, nothing to batch).Measured
th pearls readyagainst the real 1200-pearl store: 5.7s → ~0.7s warm.Tests
list_batch_loads_labels_per_pearl— asserts each pearl gets exactly its own labels (no cross-contamination), unlabelled pearls stay empty, label order preserved. Fullsmooth-pearlssuite green.🤖 Generated with Claude Code