Files
vercel-labs--zerolang/docs/articles/optimization.md
T
wehub-resource-sync e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:29:30 +08:00

78 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## Make Retention Visible
Zerolang optimization docs should answer a concrete question: why did this graph
input retain these bytes, helpers, allocations, or runtime shims?
```json-render
{
"messages": [
{
"role": "user",
"text": "why is this binary bigger now?"
},
{
"role": "assistant",
"text": "Ill inspect the size report and trace what is being retained."
},
{
"role": "tools",
"calls": [
{
"command": "zero size --json",
"output": "{\"sizeBreakdown\":{},\"retentionReasons\":[\"std.http.fetch retained by handle\"]}"
}
]
}
]
}
```
## What This Means
Use graph inputs or graph-first packages:
```sh
zero size --json examples/fixed-vec.graph
zero mem --json examples/allocator-collections.graph
zero build --json --profile tiny --target linux-musl-x64 examples/hello.graph --out .zero/out/hello
```
## Profiles
| Profile | Use when | Contract |
| --- | --- | --- |
| `debug` | You need diagnostics and local symbols. | Keeps diagnostic/debug metadata. |
| `fast` | Throughput matters more than minimum size. | Optimizes for speed within current direct codegen limits. |
| `small` | You want the normal release shape. | Pay-as-used helpers and deterministic artifacts. |
| `tiny` | Artifact size is the main constraint. | Minimum runtime metadata and strict helper budget. |
Build JSON includes `profileSemantics`, `profileCatalog`, `profileBudget`, and
`safetyFacts`.
## Size Reports
`zero size --json` adds:
- `sizeBreakdown`
- `retentionReasons`
- `optimizationHints`
- retained function and helper facts
- literal and section cost
- target and profile facts
Use `retentionReasons` when an agent needs to explain why a helper, literal, or
debug metadata block stayed in the artifact.
## Memory Reports
`zero mem --json` includes:
- `memoryBudgets`
- `allocatorFacts`
- `allocationInstrumentation`
- `collectionFacts`
- `safetyFacts`
These fields are the public way to check whether an example remains
fixed-capacity, caller-buffered, or heap-free.