Skip to content

perf(server): onshape syncs after an assembly edit make 5x fewer api calls - #235

Merged
AadiJo merged 3 commits into
mainfrom
onshape-fewer-sync-calls
Nov 9, 2026
Merged

AadiJo merged 3 commits into
mainfrom
onshape-fewer-sync-calls

Conversation

@AadiJo

@AadiJo AadiJo commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Every Onshape sync after a document edit cost 11 API calls, the same as a first import. A new microversion discarded everything, so the importer reread the definition and BOM, re-exported the whole assembly as 3MF, and refetched every ambiguous part. The first Sync click also spent 2 calls on catalog discovery.

Syncs now reuse whatever did not change. Each Part Studio's element microversionId serves as its revision. Parts from unchanged studios carry their previous geometry and metadata forward, and linked parts carry forward by their versioned geometry keys. When every part carries forward, the BOM is skipped. When only a few studios need geometry, they are fetched directly instead of through the 3MF export.

Sync Before After
First import (discovery + cold) 13 12
Unchanged 1 1
Assembly-only edit 11 2
Edit to a small Part Studio 11 4
Edit to a 96-part Part Studio 11 5
Edit affecting every Part Studio 11 7
Another project linking the same parts 11 7
Subassembly root at the same revision 11 2

Changes:

  • The workspace assembly definition reports the microversion it evaluated, so it replaces the separate currentmicroversion read.
  • Discovery lists elements at the workspace in one call.
  • Acquisition records a revision per root-document Part Studio. Element kinds not measured, such as Variable Studios, count toward every studio.
  • Direct fetches run when they cost no more than an export. Large studios split into 64-part batches instead of falling back to one request per part.
  • A changed revision keeps the last completed checkpoint until a newer one replaces it, and a failed export writes it back. Element revisions are read whenever a root has a baseline to keep. Versioned instances of root-document parts carry forward by geometry key, never by studio.

Verification

  • A scratch-document experiment measured what changes a Part Studio's revision. Renaming a part, changing its appearance, editing the Feature Studio its feature uses, and adding a feature each changed that studio and a studio deriving from it. Unrelated elements were unaffected. On the measured assembly's last 50 edits, all assembly edits, only the assembly and its BOM element changed.
  • Live runs against a real 490-node robot assembly produced every count above. Every phase matched the original snapshot's nodes, parts, metadata, and dependencies. Assets are byte-identical except refetched studios.
  • onshape-request-experiment.ts gained edit, other-project, and subassembly phases with per-phase request limits. An offline replay of the live recording reproduces every count.
  • New tests cover carry-forward, direct fetch, the 64-part split, which edits refetch, baselines after a failed export or a shared store, and versioned instances. Each reuse test fails without its change.
  • vpr typecheck and vp check are clean, and all 1,733 server tests pass.

Limitations

  • Directly fetched studios use the synchronous glTF tessellation, which is denser than the coarse 3MF. After an edit affecting every studio, the measured assembly grows from 1.07M to 1.26M triangles and from 37.5 to 44.6 MB.
  • Not measured: whether part material edits change the studio revision. Name and appearance do, through the same property mechanism.

Proved with live Onshape runs, an offline replay that asserts each phase's request count, and focused regression tests.

Reviewed with sol-loop: 2 rounds with gpt-6.1-sol. Sol verdict: approved
Also reviewed by Claude Fable 5.1, Gemini 4 Argon, and Grok 4.7. Their findings are fixed or declined below.

Finding Outcome
A discovery list read before the pin could record revisions older than the snapshot Fixed: removed the shortcut, which saved one call per first import
A failed or outdated export deleted the reuse baseline Fixed: the last completed checkpoint is written back
A root found entirely by cache key lost its baseline Fixed: revisions are read whenever a baseline exists
A versioned instance of a root-document part could swap with the workspace instance Fixed: versioned parts carry forward by geometry key
Drawings and imported files force a full refetch Declined: costs calls, never correctness; needs a measurement first
The catalog's microversionId is now a stand-in hash Declined: nothing reads it; a rename belongs in a contracts change
A single-part remainder uses the per-part glTF endpoint Declined: unchanged from before this PR

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cadsense Skipped Skipped Nov 9, 2026 3:35pm UTC

@AadiJo AadiJo changed the title perf(server): onshape syncs after an edit drop from 11 api calls to 2 perf(server): onshape syncs after an assembly edit make 5x fewer api calls Nov 9, 2026
@AadiJo
AadiJo merged commit c54f304 into main Nov 9, 2026
12 checks passed
@AadiJo
AadiJo deleted the onshape-fewer-sync-calls branch November 26, 2026 19:51

This branch was previously deployed

1 inactive deployment
Preview — aae0c9d6 Deployed Nov 9, 2026 by vercel[bot]
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