Skip to content

perf: move write and relation bodies off the generic types - #224

Open
piwi3910 wants to merge 6 commits into
mainfrom
perf/typed-query-fanout-2
Open

piwi3910 wants to merge 6 commits into
mainfrom
perf/typed-query-fanout-2

Conversation

@piwi3910

@piwi3910 piwi3910 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Refs #217. Phase 3, partial; not for merge. Head 45aeef4, ci 44070740289 green (all jobs), compile-memory 44070740489 green.

Peak compiler RSS of the compile-memory fixture, MiB default / -l / -c=1 (go1.27.4):

chunk head run default -l -c=1
phase 2 final (main 82e8a90) 17cc1e4 44053092210 6189 4813 5097
3a: infoOf and insMetaOf go:noinline 8a8b7e4 44062594253 6010 4724 5114
3b: SelectQuery unexported methods removed fcd7a78 44064173689 5673 4325 5058
3b again, same code dd3f294 44066175274 6170 4415 4803
3b with test fix 45aeef4 44070740489 6112 4364 5119

The same code measured 5673 and 6170 MiB, so a runner varies by about 8 percent; 3b is worth about 2 to 3 percent, not the 6 percent the first run suggested. PEAK_RSS_BUDGET_KB is 7270000 (run 44066175274, 6318800 KiB, plus about 15 percent), which is no real tightening over phase 2.

3b: eight unexported methods of SelectQuery[T] became functions or share one method (selectView). Go builds a wrapper for every method of an instantiated generic type, exported or not, for the value and the pointer type. Instantiated generic text fell from 56.5 MB to 54.2 MB.

Not done: the roughly 65 unexported methods of InsertQuery[T] (the largest remaining item), UpdateQuery, DeleteQuery, ConflictQuery and Relation. The under 5 GB target is not met.

Refs #217. infoOf and insMetaOf are called by almost every wrapper of SelectQuery[T] and InsertQuery[T]; inlined, each wrapper carries its own copy of the field loads.
…lpers

Refs #217. Every method of a generic type, exported or not, gets a wrapper for each instantiated type and its pointer. The renderer's dynamic checks (render, renderBare, needsParens, hasLock, selectArity) now share one method, selectView, and rows, runPreloads and qualifier are plain functions.
Refs #217. Run 44064173689 measured 5809780 KiB (5673 MiB), was 6338328 KiB. Budget is that plus about 15 percent, rounded.
…asurement

Refs #217. The same code measured 5809780 KiB and 6318800 KiB on two runs, so a 15 percent margin on the lower one would flake. Run 44066175274: 6318800 KiB; budget is that plus about 15 percent.
Refs #217. Two internal tests called the removed SelectQuery.render method; they now go through selectView like the renderer.
Refs #217. The removed qualifier method used tableOf; the callers that replaced it now do too. The selectView comment says the view holds a copy of the clauses.

This branch has not been deployed

No deployments
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