Struct layout analyzer

See how C, Rust and Go lay out a struct. Find padding, trace 64-byte cache lines and compare the smallest field order.

Runs in your browser or terminal. Your declarations stay on your device.

Targets
x86_64, ARM64 and wasm32
Packline Studiox86_64 SysV
HttpRequestRust · repr(C)
#[repr(C)]
struct HttpRequest {
    ready: bool,
    body: *const u8,
    method: u8,
    consumed: usize,
    status: u16,
    scratch: [u8; 36],
    retry: bool,
    deadline_ns: u64,
}
80 BStruct size
15 BPadding
2Cache lines
Optimal order 80 B72 B 8 bytes saved per struct

Struct padding budgets

Run the same parser and ABI rules from Node. Give a struct a padding budget and let the exit code decide whether CI passes.

Terminalpackline check
$ node bin/packline.mjs check \
    --preset http-request --max-waste-pct 19

HttpRequest (x86_64): 80 B, alignment 8 B,
  15 B padding (18.75%)
Padding: 15 B interior, 0 B tail, 0 B nested
Cache: 2 × 64 B, 50.78% payload utilization
PASS max waste 19%
0 Within budget1 Input error2 Over budget
Read CLI usage

Struct layouts and byte maps

  1. Find struct offsets

    Pick the target ABI to see field sizes, alignment and padding, including gaps inside nested structs.

    HttpRequestField offsets
    FieldOffsetSizePad
    ready0 B1 B0 B
    body8 B8 B7 B
    method16 B1 B0 B
    consumed24 B8 B7 B
  2. Compare field orders

    Mark the fields you read together. Packline finds the smallest layout and prefers orders that touch fewer hot cache lines.

    Optimal order8 B saved
    80 B72 B
  3. Export a byte map

    Save an SVG showing which bytes hold data, where padding sits and which fields span a cache-line boundary.

    HttpRequest.svgCache-line view
    Field bytePadding byte
Read layout rules