ASH-214: ledger perf — synchronous=NORMAL + skip redundant tokenization#16
Merged
Conversation
The two low-risk wins from the ledger-hot-path cluster. The headline restructure (writing the response frame before the ledger row) is left for separate measured work — it trades away the deliberately-preserved LedgerError-in-response behavior and needs a microbenchmark first. - internal/ledger: add `synchronous=NORMAL` to the write-mode DSN. Under WAL this is crash-safe (no corruption; at most the last transaction is lost on an OS/power crash) and skips an fsync per commit. It is already what internal/lsp/cache uses — and that package's comment already (incorrectly) claimed the ledger matched. - cmd/ashd: tokens_out_no_prefix re-tokenized the full response a third time per call purely to measure the path-prefix tax. With no jail prefixes configured (the default), StripPrefixes is a no-op and the value equals tokens_out — so skip the second tokenization entirely in that case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
The two low-risk, unambiguous wins from the ASH-214 ledger-hot-path cluster. The headline restructure (#1) is intentionally not here.
synchronous=NORMALon the ledger's write-mode DSN. Under WAL this is crash-safe (no corruption ever; at most the last transaction is lost on an OS/power crash) and skips an fsync per commit. It is already whatinternal/lsp/cacheuses — and that package's comment already (incorrectly) claimed the ledger matched it.tokens_out_no_prefixre-tokenization when no jail prefixes are configured (the default).StripPrefixesis a no-op then, so the value equalstokens_out— no need to tokenize the full response a third time per call.Deliberately not in this PR
cmd/ashd/main.gokeeps record-before-encode ordering specifically "so a ledger failure is still visible inrsp.Metrics.LedgerError". Reversing that is a real behavior trade-off and needs a microbenchmark to size the win. Left in ASH-214.SetMaxOpenConns(1)— needs load testing to confirm it helps rather than just serializing differently. Left in ASH-214.ASH-214 stays open for that measured work.
🤖 Generated with Claude Code