Packline inspects the byte layout of C, Rust and Go structs and finds the smallest field order it can prove optimal. It runs locally in Node or in a browser. Open Studio.
Requires Node 20 or newer. There are no npm dependencies.
node bin/packline.mjs inspect --preset http-request
node bin/packline.mjs optimize --preset http-request --source
node bin/packline.mjs inspect header.h --lang c --abi arm64 --struct Header --json
node bin/packline.mjs svg header.h --out layout.svg
node bin/packline.mjs check header.h --max-waste-pct 12.5
npm testUse - to read stdin. check returns 0 at or under budget, 1 for invalid arguments or input, and 2 above budget. The budget includes padding inside nested structs and arrays. JSON includes the first 128 cache lines. Use svg --start-line N --lines M to export a different range.
The presets include an adaptation of the in-memory Fluent Bit chunk declaration, an HTTP request state in Rust, and an ECS physics component in Go. The latter two are working examples.
| Source | x86_64 SysV | ARM64 AAPCS | wasm32 |
|---|---|---|---|
| C | LP64 | Generic AAPCS64 LP64 | Clang Basic C ABI ILP32 |
| Rust | x86_64 Linux | aarch64 Linux | wasm32, with 32-bit pointers |
| Go | gc amd64 | gc arm64 | gc wasm, with 64-bit words and pointers |
Supported inputs include named structs, C and Go inline structs, fixed arrays with literal lengths, pointers, primitive types, local aliases, and Go slice/string headers. Rust requires named-field #[repr(C)] structs and accepts packed(N) or align(N). C accepts numeric _Alignas, alignas, GNU aligned(N) and GNU packed. Paste declarations with dependencies in the same input. Conditional compilation, C unions, bit-fields, flexible members, preprocessor macros, nonliteral lengths, Rust generics, and external type resolution are outside the supported subset. Pointers to opaque named types are modeled as thin pointers.
A field crosses a cache line when its byte range spans a 64-byte boundary. The calculation treats byte zero as cache-line aligned. Utilization is actual payload bytes divided by full cache-line capacity. Bytes in the final line after the struct ends count against utilization but do not count as struct padding.
Optimization uses exact dynamic programming across equivalent field groups. It minimizes total size, then the number of cache lines touched by hot fields, then the sum of hot offsets. Mark a field with /* @hot */ before its declaration or list field names with --hot name,other. The search reports an error for more than 256 fields or when its state limit is exhausted. Reordering changes offsets and can break an established ABI, serialized format, or positional initializer.
ABI references are the x86-64 psABI, AAPCS64, WebAssembly Basic C ABI, Rust type layout, and Go compiler ABI.
Serve the repository as static files, then open app.html. For example, run python3 -m http.server 8000 and visit http://localhost:8000/app.html. The studio stores drafts in local browser storage and uses the same ES modules as the CLI.
Packline code is MIT licensed. The unchanged tasteskill files under assets/ retain their upstream terms.