RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/AGENTS.md/ghostty-org/ghostty

AGENTS.md

src/terminal/compress/AGENTS.md
AGENTS.md

Quality

76/100

Scores the file, not the repository.

Length

632 words

7 headings · 0 code blocks

Repository

59k

— · pushed 0 days ago

Last changed

3 days ago

First indexed 3 days ago.
ghostty-org/ghostty/src/terminal/compress/AGENTS.mdRawGitHub
1# Terminal Compression
2 
3Guidance for the codecs and the compressed page representation
4(`Page.zig`) in this directory. These compress terminal page backing
5memory (`terminal.Page`).
6 
7## Priorities
8 
9When making tradeoffs, in order:
10 
111. **Compression ratio on page-shaped data.** Encoded bytes are retained
12 scrollback memory, and raw `terminal.Page` backing memory is the only
13 thing we actually compress. Ratio on text files or synthetic data is a
14 secondary signal.
152. **Decompression throughput.** Pages are compressed once when they go
16 cold but restored on demand (scrollback access, search, inspection), so
17 restore latency is felt directly.
183. **Compression throughput.** Runs on idle pages in the background; being
19 fast is nice, being slow is tolerable.
20 
21## Testing
22 
23- Targeted tests: `zig build test -Dtest-filter=<codec>`
24- Prefer `zig build test-lib-vt -Dtest-filter=<codec>` when practical;
25 this code ships in libghostty-vt.
26- Codecs must keep building for `wasm32-freestanding` (libghostty-vt):
27 no libc, no `src/simd` (Highway) dependencies. Verify with
28 `zig build -Demit-lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall`.
29- Every codec needs a differential property suite: round-trip identity,
30 an independent format walker, wrong-size output rejection, and
31 corruption/truncation decoding. Keep a light version in normal unit
32 tests and gate the exhaustive version behind an environment variable so
33 the default test suite stays fast.
34 
35## Verifying Correctness
36 
37- Decoders must be memory-safe for arbitrary input bytes. Every blind or
38 wide copy needs a stated margin argument bounding it by the output
39 buffer; keep those arguments in comments next to the code.
40- Writing scratch bytes past a copy's logical end is safe only inside the
41 output buffer, because in-order decoding rewrites them before any match
42 can read them back. Do not weaken the exact-size output contract.
43- When a change should not alter compressor output, prove it: compare
44 encoded sizes (or a sequence-count fingerprint) on the same corpus
45 before and after. Ratio drift is a functional change, not noise.
46 
47## Benchmarking
48 
49- Use `ghostty-bench +page-compression` (see `src/benchmark/AGENTS.md`
50 for the general workflow). Modes: `compress`, `decompress`, `store`,
51 and `report` for ratio.
52- Build: `zig build -Demit-bench -Doptimize=ReleaseFast -Demit-macos-app=false`
53- The most representative corpus is a raw dump of real page backing
54 memory, chunked at the page size (400 KiB on ReleaseFast targets).
55 Supplement with a text corpus and random bytes for worst cases, but
56 weigh page corpora highest per the priorities above. Keep corpora
57 outside the repository and reuse identical files across comparisons.
58- `ghostty-bench +scrollback-compression` measures the PageList
59 transitions around the codec rather than the codec itself.
60- For fast iteration, keep codecs dependent only on `std` so a standalone
61 harness can build them directly with `zig build-exe -O ReleaseFast` and
62 time the codec in-process (report min-of-N, verify round-trips).
63- Measure one change at a time and re-measure the final state; run-to-run
64 noise is a few percent, so re-run before believing small deltas.
65 
66## Performance Notes
67 
68- Real page data decodes as millions of tiny operations (in LZ4: mostly
69 zero literals plus a 4-18 byte match). Per-item overhead dominates, so
70 branch-light fast paths with blind fixed-size copies win.
71- Wide copies are the only SIMD that pays here. Vectorized compares and
72 other wide-stride tricks measured as net losses because matches are
73 short; prefer the simple word loop unless a measurement on page corpora
74 says otherwise.
75- `@memcpy` beats stride loops only for long copies (roughly 64 bytes and
76 up); call overhead loses below that.
77 
78## LZ4 Specific
79 
80- The codec is `lz4.zig`, an allocation-free raw block (not frame)
81 implementation. Blocks do not carry their decoded size; callers supply
82 an exact-size output buffer.
83- Tests: `zig build test -Dtest-filter=lz4`. The differential suite is
84 `lz4_differential.zig`; run the exhaustive version for any codec
85 change:
86 `GHOSTTY_LZ4_SLOW=1 zig build test -Dtest-filter="lz4 differential"`
87- The compressor must keep the standard format restrictions (final five
88 bytes literal, matches start at least twelve bytes before the end) so
89 blocks stay consumable by optimized external decoders. The differential
90 walker checks this.
91 

Commands it names

  • zig build test -Dtest-filter=<codec>
  • zig build test-lib-vt -Dtest-filter=<codec>
  • zig build -Demit-lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall
  • zig build -Demit-bench -Doptimize=ReleaseFast -Demit-macos-app=false
  • zig build-exe -O ReleaseFast
  • zig build test -Dtest-filter=lz4

Sections

  • Terminal Compression
  • Priorities
  • Testing
  • Verifying Correctness
  • Benchmarking
  • Performance Notes
  • LZ4 Specific

What it covers

testcode-styleperformance

Stack — with the evidence

zig

(1.00)

swift

(0.60)

cpp

(0.60)

github-actions

(0.60)

Format

AGENTS.md

A plain-markdown README for coding agents, deliberately unopinionated: no frontmatter, no globs, no vendor keys. That minimalism is why it became the one file a dozen different agents will read, and why it carries the least per-file targeting power of any format here.

What the corpus says about it

Repository

Owner
ghostty-org
Language
—
License
—
Archived
no

All configs in this repo

Also in ghostty-org/ghostty

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
ghostty-org/ghosttymacos/AGENTS.md · 59kAGENTS.mdzigswift+2style51/1003 days ago
ghostty-org/ghosttysrc/benchmark/AGENTS.md · 59kAGENTS.mdzigswift+2buildstyledo-notagent-behaviour74/1003 days ago
ghostty-org/ghosttysrc/terminal/snapshot/AGENTS.md · 59kAGENTS.mdzigswift+2no sections16/1003 days ago
ghostty-org/ghosttytest/fuzz-libghostty/AGENTS.md · 59kAGENTS.mdzigswift+2style64/1003 days ago
ghostty-org/ghosttysrc/inspector/AGENTS.md · 59kAGENTS.mdzigswift+2no sections16/1003 days ago
ghostty-org/ghosttysrc/terminal/apc/glyph/AGENTS.md · 59kAGENTS.mdzigswift+2style20/1003 days ago
ghostty-org/ghosttysrc/terminal/c/AGENTS.md · 59kAGENTS.mdzigswift+2styleapi43/1003 days ago
ghostty-org/ghosttyAGENTS.md · 59kAGENTS.mdzigswift+2lint-formatstylearchgit+176/1003 days ago
Diff against macos/AGENTS.md Diff against src/benchmark/AGENTS.md Diff against src/terminal/snapshot/AGENTS.md Diff against test/fuzz-libghostty/AGENTS.md Diff against src/inspector/AGENTS.md Diff against src/terminal/apc/glyph/AGENTS.md Diff against src/terminal/c/AGENTS.md Diff against AGENTS.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70AGENTS.mdtypescriptjavascript+5buildteststylearch+3100/1003 days ago
vllm-project/vllmAGENTS.md · 88kAGENTS.mdpythonpytorch+3setuptestlint-formatstyle+5100/1003 days ago
netdata/netdatasrc/go/plugin/ibm.d/AGENTS.md · 80kAGENTS.mddockerinfrastructure+7buildtestlint-formatarch+399/1003 days ago
react/react-nativepackages/react-native-compatibility-check/AGENTS.md · 126kAGENTS.mdreactreact-native+11testlint-formatstylearch+499/1003 days ago
duckdb/duckdbAGENTS.md · 40kAGENTS.mdcppswift+1buildtestlint-formatstyle+896/100today
dragonflydb/dragonflyAGENTS.md · 31kAGENTS.mdcppredis+6setupbuildtestlint-format+1096/1002 days ago
steipete/CodexBarAGENTS.md · 20kAGENTS.mdswiftgithub-actionsbuildteststylearch+493/1003 days ago
buzz-language/buzzAGENTS.md · 1.5kAGENTS.mdzigjavascript+1styledo-not93/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack