feat: add browser XGo executor#3344
Conversation
xgoexec cost evaluationI measured the current implementation on an ARM64 MacBook Air with Chromium and the local Vite server. The numbers below are intended to establish the order of magnitude; lower-end and mobile devices still need separate validation. Summary
NetworkThe additional payload is almost entirely
At an ideal 10 Mbps, transferring the compressed WASM alone takes about 3.4 seconds with Brotli or 4.3 seconds with gzip. At 50 Mbps it takes about 0.68–0.86 seconds. Serving the uncompressed 25.2 MiB artifact would be unacceptable on slower connections, so production must verify compression and long-lived immutable caching for The WASM is loaded lazily when an executor is created. Multiple executors can reuse the browser's cached network response, but each deployment that changes the content hash requires a complete download again. MemoryObserved
Two concurrent executors used about 98.8 MiB of linear memory in total. This is not the complete browser RSS: compiled WASM code, Worker JS heaps, and browser/runtime bookkeeping are additional, so 50 MiB per executor should be treated as a confirmed baseline rather than an upper bound. Waiting for Startup and concurrencyWarm sequential samples for this small project:
The first run in the browser session took about 690 ms before execution. This is not a strict public-network cold-start measurement, but it demonstrates the additional first-time compilation and initialization cost. Starting plain and tutorial executors concurrently increased build time from roughly 0.1 seconds to roughly 0.3 seconds. The two programs reached execution in approximately 0.66 and 0.95 seconds, showing CPU contention in addition to linear memory growth. Execution and communicationThe integer-loop benchmark was about 450–640 times slower under ixgo interpretation than JavaScript JIT execution. This comparison is specifically ixgo-interpreted XGo versus JavaScript, not native compiled Go/WASM. This makes xgoexec suitable for tutorial orchestration, state changes, and event-driven code, but not for computation-heavy algorithms. Expensive processing should be delegated to a host capability, a specialized compiled module, or a backend. Communication overhead is much less concerning for the tutorial use case:
The event number measures acceptance/queueing, not completion of the whole Additional scaling concernAll supported frameworks and standard packages are linked into the same WASM artifact. Adding frameworks therefore increases download, initialization, and resident-code costs even when a particular project does not use them. We should record the binary-size delta for each new framework and consider separate artifacts only if this monolithic package starts growing materially. Initial recommendation
Overall, the main costs are the 4–5 MiB compressed download and roughly 50 MiB of memory per active executor. For event-driven Tutorial programs, execution and communication costs are acceptable; for CPU-heavy logic or many concurrent executors, the current model is expensive compared with a direct JavaScript implementation. |
Closes #3341
Summary
Tutorial mechanism exploration
The plain XGo case exercises a long-running program and common standard packages. The embedded standard-library set currently includes bytes, encoding/json, errors, fmt, io, math, math/rand, sort, strconv, strings, and time.
Validation