You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 01ec1f0
Browse filesBrowse the repository at this point in the historyBrowse files
perf: faster inserts and push responses, quicker import, build and map benchmarks (#31)
## Summary
Rebuilt on top of #34, which landed the slotted AST, the inline query
endpoint and the z2s plans this PR first carried. What's left is what
#34 didn't cover:
```diff
tx.mutate.<table>.insert / upsert
- per column: server name, cast lookup, Params.column
+ per-table write plan (quoted name, cast, fetched once); Params.bind inlines the dedup
js_stringify / bind keys
+ exact str and int first, the match only for subclasses
handle_mutate
- MutationID(...), MutationResponse(...), MutateSuccess(...) # validated
+ WireModel.trusted(...) # values it built or already parsed
- MutateParams.from_json(dict(query))
+ MutateParams.from_query(query) # two str keys, else Pydantic
get_query
- regex split
+ str.split when the name has no "|"
import
+ defer_build on wire and schema models; TypeAdapters built on first use
bench
+ build.* and map.*: the query endpoint's two stages, both sides
+ async CodSpeed cases driven without run_until_complete
```
I dropped two pieces of the old #31 after measuring them on top of #34:
- **The transform-request fast path.** #32's `PlainJSON` already matches
it.
- **Copy-on-write in `map_ast`.** It gained 2 to 3% on simple queries,
nothing on complex ones, and would have added branches the compatibility
proof has to cover.
## Evidence
Paired local runs against `main` (c2d58da), best of 15:
| case | main | this PR |
| --- | --- | --- |
| mutate_cpu.crud.n100 | 2.68 ms | 2.26 ms |
| mutate_cpu.put.n100 | 744 µs | 660 µs |
| query.simple.b100 | 838 µs | 810 µs |
| import of the endpoints and asyncpg adapter | 110 ms | 94 ms |
CodSpeed against `main`: 6 benchmarks faster, none slower. The mutate
cases gained 23 to 29%. The single-query async cases (`query.simple.b1`
+31%, `query_json.simple.b1` +21%, `query.complex.b1` +13%) gained
mostly because their harness no longer goes through
`run_until_complete`, not from SDK changes.
- **Before:** n/a, speed only.
**After:** 714 passed, 100% coverage, and `python -m tests.compat`
reports every port module exercised differentially. Python-only paths,
such as str and int subclasses and a `user_id` that is not a str, carry
`# python-only` markers and unit tests.
## Merge Danger
**Door:** two-way
**Blast Radius:** None
Nothing on the wire or in the public API changes. `WireModel.trusted` is
new and builds a model without validating it, so callers must only pass
values they have already checked.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments