Repository navigation
Replies: 1 comment
|
This is super useful, thanks G&J! The size map is exactly what I wanted before deciding On the four:
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
@Gaurav-Gosain a few small things that are your call rather than PRs. Each has a patch we tested; we rebase it on main
and open the PR if you want it. Everything below was checked again on main 82e5345.
Size, in golang.org/x/text (about 90 KB). charmap links all 42 code page tables into any program that touches one
of them (through x/image/font/sfnt, which shot, sketch/raster and internal/capture use). The cause is charmap's
listAll: four of its slots are the exported interface vars ISO8859_6E, 6I, 8E and 8I, which are set at run time,
so the package needs init code and the linker keeps the whole array. A 4-line change in tables.go (list the
unexported encodings by address instead), plus the same change in its generator, keeps the API and drops that init.
Measured with release builds and a replace of x/text v0.43.0 (the newest tag; master has the same listAll):
-90,112 B linux/amd64, -100,016 B darwin/arm64 for tuios, and -90,112 / -83,504 B for tuios-web. It is a Go CL, not
a tuios PR; tuios would only bump the pin after a release. We can send the CL to Go if you want.
tuios update passes the ids of the release plugins in plugins.lock to
tuios plugins updatewith no--(cmd/tuios/update.go, updateFirstPartyPlugins). A plugin id may hold -, so an id that starts with - is read as a
flag. In a scratch HOME, a lock entry with the id --yes turned the call into
tuios plugins update --yes, whichupdated a git plugin to a new commit without asking; with
--the same id is only an id. A change to what a pluginruns or asks for still asks under --yes. tuios writes that file itself, and such an id only gets there by hand or
from a copied config, so it is a robustness fix, not a security one: 2 lines.
A sketch plugin installed from its folder or its repository (what a dev build says to do) has only its manifest,
no bin/sketch. For a timeline, tuios mermaid then says "the sketch plugin has no program at .../bin/sketch. Run
tuios plugins update tuios.sketch", and plugins update answers that it does not update a folder. A TML panel shows
"the sketch plugin draws timeline diagrams" and gives no notice, since the plugin counts as installed. You were
changing this code when we found it, so we did not open a PR. The patch tells a plugin that is not from the release
how to build the program, and gives the panel's notice the same reason.
With any plugin enabled, every window title write builds the whole herdr view for an event no hook can take
(pane_updated is not a hook event). A hooks-only translator for the plugin host cuts that by about 84%: about 90 to
15 us and 1100 to 15 allocations per retitle at 50 shell panes in a test daemon (about 28 to 4.5 us at 10).
herdr socket clients keep the full translator and still get pane_updated. If 4 agents rewrite their title 10 times
a second, that is about 3 ms of CPU a second at 50 panes. Size: 0 B on linux/amd64 and +16 B on darwin/arm64 for
tuios. It is a small gain, which is why we ask first.
The size map is below the line: what each feature would take out of the binary as a plugin, since you said non-core
features should slowly move to plugins. The base and the six largest rows were measured again on 82e5345 the way
the release builds; the smaller rows keep their earlier base, named in the table. It only measures; which features
are core is yours.
G&J
What each feature costs in the tuios binary
A size map for the move of non-core features to plugins. It only measures. Which features are core is your call, and
yours alone: this map does not suggest an answer, and no row is a proposal to move anything. Nothing was moved: every
cut is a scratch patch that was built, measured and thrown away.
The base
Upstream main
82e534578(2026-11-05), go1.27.3,CGO_ENABLED=0 -trimpath -ldflags "-s -w" ./cmd/tuios, builtwith
GOWORK=offas the release builds (.goreleaser.yml).With go.work in use (what
scripts/binary-size.shgives when run from the clone) the same commit is 47,321,248 B onlinux and 44,122,258 B on darwin, 12,288 B and 16,528 B less.
Noise. A cut moves the file by whole pages. On linux a number is good to about 4 KiB (one page). On darwin it is
good to about 16.5 KB, sometimes more, because each Mach-O segment rounds to 16 KiB on its own. For the smallest rows
below (sound cues 16 KB, the tplot demo 37 KB) that noise is a quarter of the number on linux and up to half on darwin.
The pattern you already set: sketch
You moved the rare Mermaid types out of the binary (fe5ce61, then e92ade8 and 7c2e198). The steps,
as the code has them now:
library (tuios.dev/sketch with every type).
tuios plugins install sketchtakes it from the release, checked againstchecksums.txt, with no git and no build.tuios mermaidsees a type it does not draw and runs the plugin's program with thesame flags.
<mermaid>of a rare type runs it once persource and width in a goroutine (
-f cells), and the panel draws when the cells come in. No frame waits.sketch". A panel shows the source under a note.
Your
[[saver]]frames file (e263524) and[[theme]](52b539a) add a second pattern: a plugin of files only,which tuios reads and which needs no approval beyond the install.
Each row below says how far it fits these patterns and what plugin API v1 does not have for it.
The table, ranked by linux bytes
"Leaves" is what the stripped binary loses when the feature's code is cut. Rows 1 to 6 were rebuilt on
82e534578in release mode for this table. The other rows were measured on
b74fde8ac(2026-11-03), and are labelled with theirbase and mode. All but the GUI bridge patch need adapting to apply on
82e534578, and each of those features isstill in the binary there. Cut numbers do not add up: all twelve cuts together at b74fde8 took 7,364,608 B on linux
(darwin 6,765,248 B), 290,816 B more than the sum of the single cuts, because shared code leaves too.
tuios tutor)tuios ssh)tuios tmux-shim, thetmuxlink)tuios gui-bridge)herdrlink,tuios pane)tuios mcp)help -i,config browse,keybinds browse)tplotin the tutor's browser shellThe six largest rows are 5,910,528 B on linux together (summed, so a little low). "% of linux" is of the base the
row was measured on.
Row by row
1. Mermaid's eight common types
Detectstill knows them, so every path already in thetree for rare types takes over. On the cut binary,
tuios mermaidon a two-node flowchart prints the plugin linewhere the base prints SVG.
sketch plugin is installed. The tutor's shell and the live kitty view of
tuios mermaiddraw these types in processand have no plugin route today.
command. Steps 1 to 5 already exist for every type.
the same off-frame call that loom got.
because the map was asked for.
2. tutor and learn
tuios tutorcommand and its "getting started" help group. internal/tutor, internal/learn, the lessonsand internal/webshell leave.
tuios help. A new user would install a plugin beforeknowing what a plugin is, unless the release's own plugins cover it (step 2).
import internal/ and cannot draw inside tuios's frame. Two routes exist: a second program built from this repo (as
tuios-web is), which links the app again unless it drives
tuiosfrom outside, or a rewrite as a plugin that drives athrowaway session through the CLI and the JSON socket and checks steps with
waitand events. Either is a rewrite.3. syntax highlighting
highlight_js.go) used for every build. chroma, regexp2,encoding/xml and internal/diffview/lexers leave. The row is 32 KB smaller on linux than at b74fde8, after your
lexer dictionary (09815b5).
view, and the HL fields of the daemon's review-diff verb for any client that reads them. Everything shows as plain
text, which works (the browser build runs that way today).
for the visible lines. An exec per opened file (tens of ms) suits quick look and review on open, not per-frame use.
nearest model for.
4. screen saver effects
stays, so this is what the module costs, and less than the whole feature. The new [motion] code does not use the
module (celebrate.go and spotlight.go name it only in comments), so the cut leaves it whole.
is off by default (
screensaver.enabled = false), so most people lose nothing. Plugin savers from a frames filestill play: that player does not use tuiffects.
[[saver]]is the plugin form for a saver that plays a file. It does not cover an effect that works onthe live screen (burn, matrix over the person's text).
5. ssh server
tuios ssh, its auth check and runSSHServer. wish, charm.land/log, keygen, logfmt, internal/server,internal/served and internal/netutil leave. golang.org/x/crypto/ssh stays (
tuios pairand internal/hostsetup useit).
--ephemeralmode.tuios pairand phone clientsare built on the address it serves.
tuios attachper connection, with
tuios sshrunning it. One condition: PLUGINS.md says a terminal a plugin starts runs as theplugin, and the attach is refused without
admin. So this plugin needs theadmingrant.adminit works as documented.stayed within two pages (651,264 to 659,456). Each step is about one or two 16 KiB pages, inside the darwin noise.
Not traced further.
6. tmux command front
runAsTmux, thetmux,tmux-shimandtmux-panecommands and thetmuxargv[0] dispatch;internal/tmuxcompat leaves. The daemon's tmux-related code stays, so this is the front only.
step. The shim is off until the person runs it.
(atomicfile, config, errfmt, jsonx, procinfo, serverscope, shimlink, sortx) and tuios.dev/vt, which a plugin would
copy or rewrite.
tmuxlink on a pane's PATH; the agent callstmux, nottuios plugins run.7. transcript reader (b74fde8)
(Codex, Gemini, Qwen). Hook-based agents are not affected. The cut kept the join with
doc = false, so it is partial.8. GUI bridge (b74fde8)
cmd/ shipped with the GUI, moves it with no API.
9. push notifications (b74fde8)
push registration needs (a plugin never acts as the person).
10. herdr command front (b74fde8)
$HERDR_BIN_PATH pane split.number. Its patch no longer applies on main (plugins_commands.go moved).
11. MCP server (b74fde8)
tuios mcpandintegration install --mcpneed the plugin first; one more exec at start.12. explorers (b74fde8)
--json.help --json,list-options --json,get-config,keybinds --jsonandset-configare there, and apanepopup plugin can be the explorer. API v1 lacks: nothing found.13. tplot in the tutor shell (b74fde8)
tplotis already its own program in the plot module.14. sound cues (b74fde8)
eventplugin onpane.agent_status_changedcovers part of it. This row is inside the noise band on darwin.Estimated rows (not cut, b74fde8)
These were sized from symbol tables, not cut builds. Where both exist, that method came out 10 to 45 percent under the
cut, so read these as lower bounds. Each is used by the daemon, by agents or by the plugin system itself, which is why
no cut was tried.
Reproduce
Each cut is a small patch; we can post any of them here. Build each with
GOTOOLCHAIN=go1.27.3 GOWORK=off CGO_ENABLED=0 GOOS=<os> GOARCH=<arch> go build -trimpath -ldflags "-s -w" ./cmd/tuiosand take the difference from the base built the same way. On
82e534578the tutor, highlighting and saver cuts applyas they are; the ssh and tmux cuts needed only main's
errfmt.Errorflines in the removed code and the import blocksredone. Every cut binary runs
--versionwith an empty HOME.The Mermaid cut edits sketch/core, which a
GOWORK=offbuild takes from the module cache, so it was measured on twocopies of the pinned module (tuios.dev/sketch v0.4.1-0.20261105132603-47f444c5dae7), one as is and one with the cut,
each named by a
replacein a copy of go.mod passed with-modfile. The unchanged copy builds to the release base tothe byte (47,333,536 and 44,138,786), so the replace adds nothing. On the cut binary
tuios mermaidon a two-nodeflowchart prints "this diagram needs the sketch plugin. Run tuios plugins install sketch" where the base prints SVG.
G&J
All reactions