Skip to content

[codex] optimize sqlite bind fast path#1382

Merged
mattn merged 1 commit intomasterfrom
codex/sqlite3-bind-fastpath
Apr 3, 2026
Merged

[codex] optimize sqlite bind fast path#1382
mattn merged 1 commit intomasterfrom
codex/sqlite3-bind-fastpath

Conversation

@mattn
Copy link
Copy Markdown
Owner

@mattn mattn commented Apr 3, 2026

This PR now includes two hot-path reductions.

The first change avoids rebuilding driver.NamedValue slices and unnecessary named-parameter lookup work on the common positional-argument path.

The second change reduces cgo traffic in Rows.Next by fetching one row's column metadata and raw values in a single C helper call before converting them on the Go side.

These results were measured on the same machine.

benchmark before after delta
BenchmarkExec 1893 ns/op 1674 ns/op -11.6%
BenchmarkQuery 4356 ns/op 3992 ns/op -8.4%
BenchmarkParams 4845 ns/op 4359 ns/op -10.0%
BenchmarkStmt 2911 ns/op 2878 ns/op -1.1%
BenchmarkRows 143348 ns/op 135534 ns/op -5.5%
BenchmarkStmtRows 137675 ns/op 131549 ns/op -4.5%
BenchmarkQueryParallel 1809 ns/op 1811 ns/op +0.1%
benchmark before allocs after allocs before bytes after bytes
BenchmarkParams 26 24 1104 B/op 848 B/op
BenchmarkStmt 24 23 920 B/op 824 B/op
BenchmarkExec 6 6 128 B/op 128 B/op
BenchmarkQuery 22 22 688 B/op 688 B/op
BenchmarkRows 524 524 11128 B/op 11128 B/op
BenchmarkStmtRows 523 523 11104 B/op 11104 B/op
BenchmarkQueryParallel 16 16 592 B/op 592 B/op

Validated with go test ./..., go test -run '^$' -bench . -benchmem, and go test -run '^$' -bench 'BenchmarkSuite/(BenchmarkRows|BenchmarkStmtRows)$' -benchmem.

@mattn mattn marked this pull request as ready for review April 3, 2026 02:51
@mattn mattn merged commit cc39db7 into master Apr 3, 2026
20 checks passed
@mattn mattn deleted the codex/sqlite3-bind-fastpath branch April 3, 2026 03:00
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.

1 participant