Repository navigation
perf(orm): cache SQL shapes and tighten row mapping - #103
Merged
Merged
Conversation
Cache per-model/dialect SELECT/INSERT/UPDATE/DELETE text while still building parameters per call, move mapped rows instead of copying, and resolve each column converter once instead of switching on every cell. Row labels are formatted only on errors.
Owner
Author
|
Local review before merge: ORM model/SQL/SQLite/transaction tests pass (4/4), no DB or API behavior changes, and the A/B benchmark on the same machine shows point-select p50 overhead reduced from ~32% to ~14%, find_all from ~21% to ~11%, with write paths unaffected. The benchmark is on a shared development machine; the fixed-runner p99 gate remains open. |
This was referenced Nov 27, 2026
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.
Part of #95. Parent: #88. This is the ORM hot-path optimization found by the new
uvcpp_bench_ormA/B run; the benchmark itself lands in a separate stacked PR.What changed
src/orm/uvcpp_orm_repository.honly:uvcpp_db_paramsare still built for every call; no query-result caching, no semantic change);*out = std::move(mapped));prepare_bindings, rather than running a type switch for every cell of every row;"row N:"label only when an error actually occurs, instead of allocating it for every successful row.No DB, async, transaction or C ABI behavior changed.
Before/after (development machine, SQLite 3.45.1, 500 end-to-end samples, 50k pure-build ops)
Before (unoptimized ORM):
After:
Absolute point-select: raw mean 6.51 µs vs ORM 7.46 µs. Pure mapping dropped from 0.111 to 0.060 µs/row. The p99
pkfigure is still noisy (outlier on a shared development machine); the 3-round gate report must be run on a fixed runner before release. The hard >25% gate is not claimed as passed on this machine.Verification
The ORM SQLite and transaction/async tests pass after the optimization; model and SQL golden tests are unchanged. Full benchmark methodology/hardware caveats are in
bench/orm/README.mdfrom PR #97 and the forthcoming benchmark PR.Unverified