Skip to content

perf(wab): read the merge's head pkg versions without loading their model - #172

Closed
jameswillis99 wants to merge 1 commit into
plasmicapp:masterfrom
jameswillis99:perf/merge-head-pkg-versions-without-model
Closed

jameswillis99 wants to merge 1 commit into
plasmicapp:masterfrom
jameswillis99:perf/merge-head-pkg-versions-without-model

Conversation

@jameswillis99

@jameswillis99 jameswillis99 commented Oct 8, 2026 •

Copy link
Copy Markdown

Summary

The merge reads only id, version and revisionId from the to and from head pkg versions, but getPkgVersion loads each whole row, including the project-sized model column (about 8 MB each on a project with a 4 MB main revision). A new private getPkgVersionHead reads them through the version-only mode from cb401ee18, which skips the model column.

_tryMergeBranch
  latestToPkgVersion    getPkgVersion(...)  ->  getPkgVersionHead(...)   no model column
  latestFromPkgVersion  getPkgVersion(...)  ->  getPkgVersionHead(...)   no model column

The version-only projection gains revisionId, which the merge compares with the latest revision id. getLatestPkgVersionNumber shares that projection, so its query selects one more small column. Same permission checks and not-found messages as getPkgVersion. The two prefill reads are not changed.

A new spec in branching.spec.ts checks that a merge preview reads one pkg version model row (the ancestor's) from the database instead of three.

Evidence

  • Less data read: a merge preview now reads 1 pkg version model row from Postgres (the ancestor's, which the merge needs) instead of 3. On a project with a 4 MB main revision, that is 8.3 million fewer characters read per merge call. The new spec fails without the change.
  • Less memory held: the two skipped head strings are about 8.3 MB each and no longer stay referenced through the publishes. In a replay with the Node heap capped at 640 MB, the heap left after the last full GC went from 386 MB to 369 MB (median of three runs, lower in all three paired runs).
  • No behaviour change: 17 merge scenarios on real Postgres (preview, conflicts, picks, resolved bundle string, concurrent change, both auto-commits, app host mismatch, soft-deleted heads) and a replay of a real-size project (5 dependencies) give responses, write statements and rows identical to master.

Merge Danger

Door: two-way

Blast Radius: branch merge. The loader's version-only query selects one more small column (revisionId, 37 bytes a row). The head objects are typed as Pick<PkgVersion, "id" | "version" | "revisionId">, so a later edit that reads .model from them fails to compile.

@vercel

vercel Bot commented Oct 8, 2026

Copy link
Copy Markdown

@jwillis24 is attempting to deploy a commit to the Plasmic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

Thank you for your submission, we really appreciate it! ❤️

Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. If you are contributing on behalf of a company, please contact us at help@plasmic.app to sign a Corporate Contributor License Agreement.

You can sign the individual CLA by posting a comment with the below text.


I have read, agree to, and hereby sign Plasmic's Individual Contributor License Agreement


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@jameswillis99
jameswillis99 force-pushed the perf/merge-head-pkg-versions-without-model branch from 66d6db8 to d017917 Compare October 8, 2026 09:46
…odel

The merge uses only id, version and revisionId of the to and from head pkg
versions, so getPkgVersionHead selects just those through the version-only
lookup and skips the model column.
@sampullman

Copy link
Copy Markdown
Contributor

Fixed in a4e0313.

@sampullman sampullman closed this Oct 26, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants