-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
395 lines (364 loc) · 24 KB
/
Copy pathindex.html
File metadata and controls
395 lines (364 loc) · 24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SQUISH — a context-mixing file compressor</title>
<meta name="description" content="SQUISH is a context-mixing file compressor that outcompresses zip -9, bzip2 -9, and rar -m5 on 23 of 24 standard-corpus files. A linkable C library and command-line tool.">
<link rel="icon" href="squish.png">
<meta property="og:title" content="SQUISH — a context-mixing file compressor">
<meta property="og:description" content="Ten statistical models, an online-trained mixer, and an arithmetic coder. Outcompresses zip -9, bzip2 -9, and rar -m5 on 23 of 24 corpus files.">
<meta property="og:image" content="squish.png">
<meta name="theme-color" content="#6d28d9">
<style>
:root {
--bg: #ffffff;
--bg-soft: #f6f5fb;
--bg-panel: #ffffff;
--fg: #1a1523;
--fg-soft: #5b5470;
--border: #e6e2f0;
--accent: #6d28d9;
--accent-2: #8b5cf6;
--accent-ink: #ffffff;
--code-bg: #1c1730;
--code-fg: #e7e2f5;
--win: #16a34a;
--shadow: 0 1px 2px rgba(26,21,35,.06), 0 8px 24px rgba(26,21,35,.06);
--grad: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 55%, #5b21b6 100%);
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #0f0b1a;
--bg-soft: #15102260;
--bg-panel: #171128;
--fg: #efeaf9;
--fg-soft: #a79fc0;
--border: #2a2140;
--accent: #a78bfa;
--accent-2: #8b5cf6;
--accent-ink: #150f26;
--code-bg: #0c0917;
--code-fg: #e7e2f5;
--win: #4ade80;
--shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
}
}
:root[data-theme="dark"] {
--bg: #0f0b1a; --bg-soft: #15102260; --bg-panel: #171128; --fg: #efeaf9;
--fg-soft: #a79fc0; --border: #2a2140; --accent: #a78bfa; --accent-2: #8b5cf6;
--accent-ink: #150f26; --code-bg: #0c0917; --code-fg: #e7e2f5; --win: #4ade80;
--shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
}
:root[data-theme="light"] {
--bg: #ffffff; --bg-soft: #f6f5fb; --bg-panel: #ffffff; --fg: #1a1523;
--fg-soft: #5b5470; --border: #e6e2f0; --accent: #6d28d9; --accent-2: #8b5cf6;
--accent-ink: #ffffff; --code-bg: #1c1730; --code-fg: #e7e2f5; --win: #16a34a;
--shadow: 0 1px 2px rgba(26,21,35,.06), 0 8px 24px rgba(26,21,35,.06);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
margin: 0;
background: var(--bg);
color: var(--fg);
font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 24px; }
/* Nav */
nav {
position: sticky; top: 0; z-index: 20;
backdrop-filter: saturate(180%) blur(12px);
background: color-mix(in srgb, var(--bg) 82%, transparent);
border-bottom: 1px solid var(--border);
}
nav .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .5px; }
nav .brand img { width: 26px; height: 26px; border-radius: 6px; }
nav .links { margin-left: auto; display: flex; gap: 22px; align-items: center; }
nav .links a { color: var(--fg-soft); font-size: 14.5px; font-weight: 500; }
nav .links a:hover { color: var(--accent); text-decoration: none; }
.theme-btn {
background: transparent; border: 1px solid var(--border); color: var(--fg-soft);
width: 34px; height: 34px; border-radius: 8px; cursor: pointer; font-size: 15px;
display: grid; place-items: center;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 680px) { nav .links a:not(.gh) { display: none; } }
/* Hero */
.hero { padding: 76px 0 60px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
content: ""; position: absolute; inset: -40% 0 auto 0; height: 520px;
background: radial-gradient(closest-side, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%);
pointer-events: none; z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.logo-lg { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); }
.hero h1 {
font-size: clamp(40px, 8vw, 68px); margin: 22px 0 6px; letter-spacing: -1.5px; font-weight: 800;
background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .tag { font-size: clamp(18px, 3.4vw, 23px); color: var(--fg); font-weight: 600; margin: 0 0 14px; }
.hero p.lead { font-size: 18px; color: var(--fg-soft); max-width: 640px; margin: 0 auto 30px; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 10px;
font-weight: 600; font-size: 15px; border: 1px solid transparent; cursor: pointer;
}
.btn.primary { background: var(--grad); color: #fff; box-shadow: var(--shadow); }
.btn.primary:hover { text-decoration: none; filter: brightness(1.06); }
.btn.ghost { background: var(--bg-panel); border-color: var(--border); color: var(--fg); }
.btn.ghost:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
/* Stat band */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border);
border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin: 44px 0 10px; }
.stats div { background: var(--bg-panel); padding: 20px 14px; text-align: center; }
.stats .n { font-size: clamp(22px, 4vw, 30px); font-weight: 800; color: var(--accent);
background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stats .l { font-size: 12.5px; color: var(--fg-soft); margin-top: 4px; letter-spacing: .3px; }
@media (max-width: 620px) { .stats { grid-template-columns: repeat(2, 1fr); } }
/* Sections */
section { padding: 56px 0; border-top: 1px solid var(--border); }
section:first-of-type { border-top: none; }
h2 { font-size: clamp(26px, 5vw, 34px); letter-spacing: -.6px; margin: 0 0 6px; }
h2 + .sub { color: var(--fg-soft); margin: 0 0 28px; font-size: 16.5px; }
h3 { font-size: 19px; margin: 30px 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 14px;
padding: 22px 22px 20px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; display: flex; align-items: center; gap: 9px; }
.card .ico { width: 30px; height: 30px; border-radius: 8px; background: var(--grad); color: #fff;
display: grid; place-items: center; font-size: 15px; flex: none; }
.card p { margin: 0; color: var(--fg-soft); font-size: 15px; }
/* Code */
pre { background: var(--code-bg); color: var(--code-fg); border-radius: 12px; padding: 18px 20px;
overflow-x: auto; font-size: 14px; line-height: 1.7; margin: 14px 0; border: 1px solid var(--border); }
pre code { color: inherit; }
.cmt { color: #9a8fc0; }
p code, li code { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 5px;
padding: 1px 6px; font-size: 13.5px; }
/* Table */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 640px; }
th, td { padding: 9px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--bg-soft); font-weight: 700; color: var(--fg); position: sticky; top: 0; }
tbody tr:hover td { background: var(--bg-soft); }
td.sq { font-weight: 700; color: var(--accent); }
tfoot td { font-weight: 800; border-top: 2px solid var(--border); background: var(--bg-soft); }
.win { color: var(--win); font-weight: 700; }
.lose { color: var(--fg-soft); }
ul.clean { padding-left: 20px; color: var(--fg-soft); }
ul.clean li { margin: 7px 0; }
ul.clean b, ul.clean strong { color: var(--fg); }
footer { border-top: 1px solid var(--border); padding: 40px 0 60px; color: var(--fg-soft); font-size: 14px; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; }
footer a { color: var(--fg-soft); }
footer a:hover { color: var(--accent); }
.note { font-size: 13.5px; color: var(--fg-soft); margin-top: 12px; }
</style>
</head>
<body>
<nav>
<div class="wrap">
<span class="brand"><img src="squish.png" alt="SQUISH logo">SQUISH</span>
<span class="links">
<a href="#how">How it works</a>
<a href="#results">Results</a>
<a href="#cli">CLI</a>
<a href="#library">Library</a>
<a href="#build">Build</a>
<a class="gh" href="https://github.com/squish/squish.github.io">GitHub</a>
<button class="theme-btn" id="theme" aria-label="Toggle theme" title="Toggle light / dark">◐</button>
</span>
</div>
</nav>
<header class="hero">
<div class="wrap">
<img class="logo-lg" src="squish.png" alt="SQUISH">
<h1>SQUISH</h1>
<p class="tag">A context-mixing file compressor.</p>
<p class="lead">
Ten statistical models predict every bit, an online-trained logistic mixer fuses their
votes, and an arithmetic coder turns the probabilities into bits. It outcompresses
<code>zip -9</code>, <code>bzip2 -9</code>, and <code>rar -m5</code> on
23 of 24 standard-corpus files — shipped as a linkable C library and a CLI.
</p>
<div class="cta">
<a class="btn primary" href="#build">Get started →</a>
<a class="btn ghost" href="https://github.com/squish/squish.github.io">View on GitHub</a>
</div>
<div class="stats">
<div><div class="n">0.214</div><div class="l">compression ratio (315 MB corpus)</div></div>
<div><div class="n">23 / 24</div><div class="l">files beat zip · bzip2 · rar</div></div>
<div><div class="n">10</div><div class="l">specialist models mixed per bit</div></div>
<div><div class="n">0</div><div class="l">dependencies beyond libc / libm</div></div>
</div>
</div>
</header>
<main class="wrap">
<!-- HOW IT WORKS -->
<section id="how">
<h2>Compression is prediction</h2>
<p class="sub">If you can estimate the probability of the next bit accurately, an arithmetic coder converts those probabilities into a near-optimal code for free. All the effort goes into one fast, online-learning predictor.</p>
<div class="grid2">
<div class="card">
<h3><span class="ico">▦</span> Ten specialist models</h3>
<p>Order-0…6 byte contexts, a word model, an auto-detected record model, and an unbounded-window match model each vote on <em>P(bit=1)</em> — so SQUISH behaves like LZ on repetitive data, like PPM on text, and like a record codec on tables, without being told which is which.</p>
</div>
<div class="card">
<h3><span class="ico">∑</span> Logistic mixing</h3>
<p>A tiny one-layer network fuses the ten opinions as a weighted sum of log-odds, with the weight set chosen by context and trained online by gradient descent on real coding loss. Useless models are learned away in a few KB.</p>
</div>
<div class="card">
<h3><span class="ico">⇄</span> Match & record models</h3>
<p>A rolling hash finds the most recent identical context and predicts the history simply repeats — LZ77’s long-range power with an unbounded window, but probabilistically. A vote table detects fixed row lengths, lighting up “cell above” contexts that beat RAR’s filters on spreadsheets.</p>
</div>
<div class="card">
<h3><span class="ico">◈</span> The model is the format</h3>
<p>The decompressor runs the identical predictor in lockstep, so the format needs no dictionaries, tables, or block structure. Every coded block carries a 32-bit checksum; incompressible data falls back to stored blocks, so expansion is bounded.</p>
</div>
</div>
<h3>The pipeline, per bit</h3>
<pre><code>order-0..6 byte contexts (7) ┐
word model ├─▶ each emits P(bit=1) from an adaptive counter
record model (row length R) │
match model (6-byte hash) ┘
│
▼ logistic mixer — 11 inputs, 1024 context-selected weight sets
▼ 2 chained APM/SSE stages — recalibrate against what happened
▼ carryless 32-bit binary arithmetic coder
output bits</code></pre>
<p class="note">Full algorithm write-up: <a href="https://github.com/squish/squish.github.io/blob/main/SQUISH.md">SQUISH.md</a> · byte-level spec: <a href="https://github.com/squish/squish.github.io/blob/main/docs/FORMAT.md">docs/FORMAT.md</a></p>
</section>
<!-- RESULTS -->
<section id="results">
<h2>Results</h2>
<p class="sub">Silesia + Canterbury + enwik8 — 315 MB across 24 files, every file round-trip verified. Ratio-optimal single-block SQUISH against each rival’s strongest setting.</p>
<div class="tablewrap">
<table>
<thead>
<tr><th>file</th><th>original</th><th>zip -9</th><th>bzip2 -9</th><th>rar -m5</th><th>xz -9e</th><th>SQUISH</th><th>vs best</th></tr>
</thead>
<tbody>
<tr><td>enwik8</td><td>100,000,000</td><td>36,493,328</td><td>29,008,758</td><td>26,922,421</td><td>24,831,648</td><td class="sq">22,461,575</td><td class="win">+9.5%</td></tr>
<tr><td>silesia/mozilla</td><td>51,220,480</td><td>19,032,067</td><td>17,914,392</td><td>15,147,513</td><td>13,376,240</td><td class="sq">14,305,318</td><td class="lose">−6.9%</td></tr>
<tr><td>silesia/webster</td><td>41,458,703</td><td>12,114,412</td><td>8,644,714</td><td>9,030,482</td><td>8,368,672</td><td class="sq">6,584,906</td><td class="win">+21.3%</td></tr>
<tr><td>silesia/nci</td><td>33,553,445</td><td>2,998,618</td><td>1,812,734</td><td>1,858,838</td><td>1,449,272</td><td class="sq">1,643,448</td><td class="lose">−13.4%</td></tr>
<tr><td>silesia/samba</td><td>21,606,400</td><td>5,406,446</td><td>4,549,759</td><td>4,107,454</td><td>3,739,524</td><td class="sq">3,529,273</td><td class="win">+5.6%</td></tr>
<tr><td>silesia/dickens</td><td>10,192,446</td><td>3,859,202</td><td>2,799,520</td><td>3,032,424</td><td>2,831,212</td><td class="sq">2,300,272</td><td class="win">+17.8%</td></tr>
<tr><td>silesia/osdb</td><td>10,085,684</td><td>3,667,602</td><td>2,802,792</td><td>3,237,063</td><td>2,844,556</td><td class="sq">2,401,772</td><td class="win">+14.3%</td></tr>
<tr><td>silesia/mr</td><td>9,970,564</td><td>3,656,264</td><td>2,441,280</td><td>2,775,664</td><td>2,751,892</td><td class="sq">2,200,359</td><td class="win">+9.9%</td></tr>
<tr><td>silesia/x-ray</td><td>8,474,240</td><td>5,957,301</td><td>4,051,112</td><td>4,162,449</td><td>4,491,264</td><td class="sq">3,732,271</td><td class="win">+7.9%</td></tr>
<tr><td>silesia/sao</td><td>7,251,944</td><td>5,318,180</td><td>4,940,524</td><td>5,542,741</td><td>4,425,664</td><td class="sq">3,968,327</td><td class="win">+10.3%</td></tr>
<tr><td>silesia/reymont</td><td>6,627,202</td><td>1,826,497</td><td>1,246,230</td><td>1,444,933</td><td>1,315,592</td><td class="sq">1,112,376</td><td class="win">+10.7%</td></tr>
<tr><td>silesia/ooffice</td><td>6,152,192</td><td>3,078,367</td><td>2,862,526</td><td>2,302,529</td><td>2,427,224</td><td class="sq">2,412,103</td><td class="lose">−4.8%</td></tr>
<tr><td>silesia/xml</td><td>5,345,280</td><td>661,981</td><td>441,186</td><td>484,735</td><td>434,892</td><td class="sq">385,143</td><td class="win">+11.4%</td></tr>
<tr><td>canterbury/kennedy.xls</td><td>1,029,744</td><td>207,125</td><td>130,280</td><td>35,651</td><td>51,868</td><td class="sq">25,479</td><td class="win">+28.5%</td></tr>
<tr><td>canterbury/ptt5</td><td>513,216</td><td>52,783</td><td>49,759</td><td>49,348</td><td>39,860</td><td class="sq">46,231</td><td class="lose">−16.0%</td></tr>
<tr><td>canterbury/plrabn12.txt</td><td>481,861</td><td>194,869</td><td>145,577</td><td>175,669</td><td>165,456</td><td class="sq">130,534</td><td class="win">+10.3%</td></tr>
<tr><td>canterbury/lcet10.txt</td><td>426,754</td><td>144,475</td><td>107,706</td><td>126,510</td><td>119,488</td><td class="sq">94,649</td><td class="win">+12.1%</td></tr>
<tr><td>canterbury/alice29.txt</td><td>152,089</td><td>54,320</td><td>43,202</td><td>51,262</td><td>48,528</td><td class="sq">38,687</td><td class="win">+10.5%</td></tr>
<tr><td>canterbury/asyoulik.txt</td><td>125,179</td><td>48,950</td><td>39,569</td><td>47,009</td><td>44,592</td><td class="sq">35,725</td><td class="win">+9.7%</td></tr>
<tr><td>canterbury/sum</td><td>38,240</td><td>12,976</td><td>12,909</td><td>11,684</td><td>9,500</td><td class="sq">11,447</td><td class="lose">−20.5%</td></tr>
<tr><td>canterbury/cp.html</td><td>24,603</td><td>8,069</td><td>7,624</td><td>8,156</td><td>7,652</td><td class="sq">6,787</td><td class="win">+11.0%</td></tr>
<tr><td>canterbury/fields.c</td><td>11,150</td><td>3,212</td><td>3,039</td><td>3,202</td><td>3,032</td><td class="sq">2,819</td><td class="win">+7.0%</td></tr>
<tr><td>canterbury/xargs.1</td><td>4,227</td><td>1,830</td><td>1,762</td><td>1,860</td><td>1,812</td><td class="sq">1,710</td><td class="win">+3.0%</td></tr>
<tr><td>canterbury/grammar.lsp</td><td>3,721</td><td>1,316</td><td>1,283</td><td>1,359</td><td>1,292</td><td class="sq">1,252</td><td class="win">+2.4%</td></tr>
</tbody>
<tfoot>
<tr><td>TOTAL</td><td>314,749,364</td><td>104,800,190</td><td>84,058,237</td><td>80,560,956</td><td>73,780,732</td><td class="sq">67,432,463</td><td class="win">+8.6%</td></tr>
</tfoot>
</table>
</div>
<p class="note">SQUISH beats zip + bzip2 + rar on 23/24 files, and beats all four (including <code>xz -9e</code>) on 19/24. “vs best” compares SQUISH to the smallest rival output for that file. The trade: ~0.6 MB/s, symmetric, ~150 MB of model memory per active block — SQUISH spends CPU that zip/bzip2/rar don’t and buys ratio with it. Full table: <a href="https://github.com/squish/squish.github.io/blob/main/bench/RESULTS.md">bench/RESULTS.md</a>.</p>
</section>
<!-- CLI -->
<section id="cli">
<h2>Command-line tool</h2>
<p class="sub">Everything SQUISH writes is one format: a SQUISH archive. The input may be a file or a whole directory tree — either way the output is an archive, each file its own member.</p>
<pre><code>./squish c bigfile bigfile.sqsh <span class="cmt"># compress a file</span>
./squish d bigfile.sqsh restored <span class="cmt"># restore it (checksum-verified)</span>
./squish c project project.sqsh <span class="cmt"># pack a whole directory tree</span>
./squish l project.sqsh <span class="cmt"># list the archive's contents</span>
./squish x project.sqsh src/main.c <span class="cmt"># extract one file (or a subtree)</span>
./squish d project.sqsh restored-dir <span class="cmt"># recreate the whole tree</span>
./squish -t 0 c bigfile bigfile.sqsh <span class="cmt"># compress on all cores</span>
./squish -t 0 -b 4 c big big.sqsh <span class="cmt"># ... with 4 MiB blocks (more parallel)</span></code></pre>
<ul class="clean">
<li>Members are stored <b>sorted</b>, so output depends only on the tree; extraction refuses absolute paths and <code>..</code>, so an archive never writes outside its target.</li>
<li><code>-t N</code> splits each member into independently modeled blocks for near-linear speedup, at ~1–2% ratio cost. The default <code>-t 1</code> keeps the ratio-optimal single-block layout.</li>
<li>A live status line (percent, bytes, throughput) shows while working; <code>-q</code> suppresses it.</li>
</ul>
</section>
<!-- LIBRARY -->
<section id="library">
<h2>Library</h2>
<p class="sub">SQUISH is a linkable C library — <code>squish.h</code> + <code>libsquish.so</code> (or <code>squish.dll</code> on Windows). Python needs no wrapper; <code>libsquish.so</code> loads directly with ctypes.</p>
<h3>Compress a buffer and back</h3>
<pre><code>#include <squish.h>
/* trailing args: threads (0 = all cores, 1 = serial),
* chunk size (0 = 16 MiB), progress callback + user pointer */
void *c, *d; size_t cn, dn;
squish_compress_alloc(data, n, &c, &cn, 1, 0, NULL, NULL);
squish_decompress_alloc(c, cn, &d, &dn, 0, NULL, NULL); <span class="cmt">/* integrity-checked */</span>
squish_free(c); squish_free(d);</code></pre>
<h3>Pack a tree, reach one member without inflating the rest</h3>
<pre><code>squish_archive_create("project", "project.sqsh", 0, 0, NULL, NULL);
squish_archive *a;
squish_archive_open("project.sqsh", &a);
squish_archive_extract_path(a, "src/main.c", &d, &dn); <span class="cmt">/* just this file */</span>
squish_free(d); squish_archive_close(a);</code></pre>
<p class="note">Link with <code>-lsquish -lm -pthread</code> (or <code>pkg-config --cflags --libs squish</code> after install). Full reference: <a href="https://github.com/squish/squish.github.io/blob/main/docs/API.md">docs/API.md</a> · examples: <a href="https://github.com/squish/squish.github.io/blob/main/examples/example.c">example.c</a>, <a href="https://github.com/squish/squish.github.io/blob/main/examples/example.py">example.py</a>.</p>
</section>
<!-- BUILD -->
<section id="build">
<h2>Build & install</h2>
<p class="sub">No dependencies beyond libc / libm.</p>
<pre><code>make <span class="cmt"># libsquish.so + squish CLI</span>
make test <span class="cmt"># build and run the test suite</span>
make install <span class="cmt"># headers, libs, CLI, pkg-config to /usr/local</span>
make dll <span class="cmt"># squish.dll + squish.exe via mingw-w64</span>
make windows-dll <span class="cmt"># ... via MSVC (cl.exe on PATH)</span></code></pre>
<p class="note">On Windows without make, run <code>build-windows.bat</code> — it locates Visual Studio automatically and builds <code>squish.dll</code> + <code>squish.exe</code>.</p>
<h3>Guarantees & limits</h3>
<ul class="clean">
<li><b>One on-disk format</b> — every output is a SQUISH archive (magic <code>SQSH</code>).</li>
<li><b>Round-trip fidelity</b> — every coded block carries a 32-bit checksum; decompression fails loudly on corruption.</li>
<li><b>Bounded expansion</b> — incompressible data falls back to stored blocks.</li>
<li><b>No global mutable state</b> — concurrent (de)compressions on different buffers are safe. Up to 4 GiB per member.</li>
</ul>
</section>
</main>
<footer>
<div class="wrap">
<span>SQUISH — context-mixing compression. Composes primitives from the PAQ family; the model set, record contexts, and implementation are original to this project.</span>
<span><a href="https://github.com/squish/squish.github.io">GitHub</a> · <a href="https://github.com/squish/squish.github.io/blob/main/LICENSE">License</a></span>
</div>
</footer>
<script>
(function () {
var root = document.documentElement;
var btn = document.getElementById('theme');
var saved = null;
try { saved = localStorage.getItem('sq-theme'); } catch (e) {}
if (saved) root.setAttribute('data-theme', saved);
function cur() {
var attr = root.getAttribute('data-theme');
if (attr) return attr;
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
btn.addEventListener('click', function () {
var next = cur() === 'dark' ? 'light' : 'dark';
root.setAttribute('data-theme', next);
try { localStorage.setItem('sq-theme', next); } catch (e) {}
});
})();
</script>
</body>
</html>