Repository navigation
perf(cad): send 25% less geometry to browsers on a tailnet or lan address - #212
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CAD loaded noticeably slower when Cadsense was opened at a tailnet or LAN address (plain
http://100.x…) than on the same machine. Browsers only advertise Brotli over HTTPS or localhost, so those pages never received the prepared.brgeometry ranges. The server fell back to gzip level 1 on every range instead. On a real 467-part robot that is 80.7 MB instead of 68.6 MB, plus gzip CPU on the server for each request.Transfer range requests now add
decode=br. When the browser did not negotiatebr, the server sends the prepared Brotli bytes unchanged asapplication/vnd.cadsense.geometry-bundle+br, with noContent-Encoding. The client decodes them withbrotli-dec-wasmbefore the range cache, so the cache still holds decoded bytes. Browsers that do negotiatebrkeep the native decoder. The decoder (208 kB wasm, 99 kB gzipped) loads only when the first such range arrives. Decoding the robot's whole 120 MB transfer takes about 0.6 s, about 20 ms per 4 MiB range. A body that is corrupt, truncated, or decodes past its range fails the optimized load, which falls back to the original bundle as before.Results
apps/server/scripts/cad-remote-load-e2e.tsruns the real app on a fresh data directory and imports a STEP file. It then opens the chat from a fresh browser profile through a forwarder on the machine's LAN address, capped at 40 Mbit/s, so the page is plain http and not localhost. It keeps that page open through a re-export sync and a one-part edit, then reloads. It records every/api/cad-panelresponse insummary.json.76-part, 22 MB STEP motor, geometry bytes on the wire:
Chromium sent
Accept-Encoding: gzip, deflateon every request, and the page reportedisSecureContext: false. The re-downloads after each sync are fixed separately in the stacked PR.The script gives Codex a throwaway home whose only provider is a closed local port. Opening a chat needs one message, and this way the turn fails at once without reaching a model.
Proof
decode=brgets the prepared bytes, and abrbrowser still getsContent-Encoding: br.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.