Smart2Raw
Home Applications How it works Performance Get started

Commercial

Premium Licensing Investment

More

Technical scope Cite About
Get in touch

A C library in a single file. And no, it is not a compressor.

The server you don't have to buy.

Your integer column takes 8 bytes per element because nobody asked how much it needs. Smart2Raw asks: it measures the real range and stores the column in the smallest native class that range requires — 8, 16, 32 or 64 bits, signed or unsigned. Then it stops. No dictionary, no bit packing, no decode step, because nothing was left encoded to undo.

And that is where the saving turns into speed: because the stored bytes are still integers the machine already knows how to read, a 512-bit register processes 64 of them per instruction instead of 8. The compact format is not a cost paid at read time — it is what unlocks the width.

fewer bytes on a 0..200 telemetry column — 30.52 MB becomes 3.81 MB
13.4×the largest measured gain: signed count_gt on i8, from 1402 to 18833 Mval/s
7areas where the integer column already is — from database to microcontroller
0dependencies. One C11 header, and ~3.4 KB of code on a microcontroller

Where it fits: databases, telemetry, IoT, AI, embedded

The question is always the same one — where is the integer column? Once you start looking, it is almost everywhere, and almost always eight bytes per element, because the width was chosen by the type declaration and not by the data.

Databases and columnar engines

Ids, status codes, dates as day numbers, counters, partition ids. In a columnar layout the column is the unit of storage — the most direct fit there is.

Operating systems and Linux

Counters from /proc, eBPF metrics, PIDs, inodes, uids, log timestamps. A dependency-free header drops into a daemon or an agent without dragging a library along.

Observability, IoT, telemetry

Fixed-interval time series, sensors, counters. This is where the common stride and the per-block frame of reference work together: 4 million timestamps go from 15.26 MB to 4.11 MB.

AI and machine learning

Token ids, vocabulary indices, feature ids, dataset offsets, KV cache. Inference is bound by memory bandwidth, not by FLOPs — and here there is no dequantisation to pay for on the way in.

Embedded, MCU, edge, automotive

Any reading buffer. Fitting four times more samples in the same buffer is not an optimisation, it is a different product. The lean mode — no stdio, no mmap, no SIMD — is one of the test suites.

Financial markets

Prices in cents (a stride!), nanosecond timestamps, instrument ids, volumes. Tick data is the picture of the ideal case.

Developer tools

Symbol tables, offsets, indices inside compilers, linkers and binary formats. A single header drops into any build.

Each one in detail, with where to start →

Bytes are only one axis. The other one decides what it costs to run.

Storing fewer bytes is half the story, and it is the half everyone tells. The other half is what you can ask of the bytes without first turning them into something else — and it only becomes visible when you take bytes out of the equation.

This chart does exactly that. The column is the same one, and both formats take practically the same space: 11.44 MB against 11.45 MB. With the bytes tied, what is left in the drawing is processing alone.

12 million elements · both formats take the same space: 11.44 against 11.45 MB 12 million elements · both formats take the same space: 11.44 against 11.45 MB 12 million elements · both formats take the same space: 11.44 against 11.45 MB Smart2Raw dictionary, implemented at its best 0 2 4 6 8 milliseconds, single core COUNT(x > 100) 0.60 0.63 parity COUNT(x > 100) — Smart2Raw 0.60 ms, dictionary, implemented at its best 0.63 ms SUM(x) 0.44 7.52 SUM(x) — Smart2Raw 0.44 ms, dictionary, implemented at its best 7.52 ms reach a non-SQL kernel * 0.00 · already contiguous 7.90 reach a non-SQL kernel — Smart2Raw 0.00 ms, dictionary, implemented at its best 7.90 ms

The peer is implemented at its best, with the dictionary over sorted distinct values — which is why COUNT comes out level. Saying so is what earns the other two rows their credit. SUM has no such shortcut: a code is not an addable operand. And the 7.9 ms in the last row do not move with a better implementation — that is the format's definition.

A dictionary code is meaningful only to the engine that owns the dictionary. A native-width integer is meaningful to every instruction on the machine — including the ones a warehouse format cannot reach without materialising a buffer first.

Every number, with the command that reproduces it →

wasm

How it works, in three steps

1

Measure the real range

One pass, no allocation. For 0..200 the answer is S2R_8; for −500..500 it is S2R_I16.

int8_t cls = s2r_classify_array(v, n);
2

Store in that class, natively

The elements become real uint8_t in memory — not "8-bit codes". An array any C compiler already knows how to read.

s2r_pool_init(&p, cls, n);
3

Operate without materialising

The predicate runs over the bytes as they are. No decoding, no dictionary lookup, no intermediate buffer.

s2r_count_gt_fast(&p, 100);

There are three shapes, and the library chooses between them by measuring rather than guessing: the flat pool, the affine form (v = base + stride·i, with the stride found by gcd) and the block-wise form, each block relative to its own minimum. s2r_recommend() prices all three — because the obvious entry point is usually the worst one.

The whole mechanism, and why it cannot expand your data →

Against what you already have

Comparing against "a dictionary" is comparing against an abstraction. Almost nobody runs one in production; almost everybody runs a SQLite. The repository ships a comparator that runs on your CSV and prints the whole table:

whatSQLiteSmart2Rawgain
SUM2635 µs16.3 µs161×
COUNT with a filter3900 µs69.5 µs56×
size on disk412.0 KB275.7 KB1.49× smaller
resident memory934.8 KB (int64/float64) → 342.2 KB2.73×
data moved per scan868.1 KB → 275.4 KB3.15×
python benchmarks/maestro/smart2raw_bench.py your_data.csv

Python here is only the conductor: it uses the standard library for SQLite and calls the real C kernels through ctypes. Columns that genuinely need 64 bits, or that are floating point, show 0% on purpose — because this is choosing the right native type, not compressing.

The full table, what the 161× is not, and the 1.18× row where we barely win →

Why this matters now

These three numbers are not ours. They come from third parties, and each one carries its source. The numbers we measured are above, and you reproduce every one of them right here — the separation is deliberate.

3.0× against 1.6×

The bottleneck stopped being arithmetic

Over 20 years, hardware peak compute grew 3.0× every 2 years. DRAM bandwidth grew 1.6×; interconnect, 1.4×. The gap widens every year.

IEEE Micro · arXiv:2403.14123

→ Adding FLOPs stopped solving it. Reading fewer bytes, with no decode to pay for, attacks exactly the side that got narrow.

+58% to 63%

In a single quarter

That is how much DRAM contract prices rose in Q2 2026, in the worst shortage in nearly 15 years. An AI server uses 8 to 10 times the memory of an ordinary one.

TrendForce, April 2026

→ A byte you do not store is money you do not spend — and memory left over for something else.

945 TWh

Data centres by 2030

Data centre electricity consumption is expected to more than double by 2030, reaching about 945 TWh, with AI as the main driver.

International Energy Agency

→ Moving fewer bytes is spending less energy per query. Not a slogan: the same arithmetic, seen from the other side.

Open under AGPL-3.0. And there is a version that is not published.

The edition on this site is the complete, auditable one: the whole core, the .s2r format, the SIMD predicates, the analytics layer, the ports and the 31 test suites. It is free to use, study, modify and redistribute — under AGPL-3.0-or-later, which means everything you build on top, including software offered over a network, is released under the same licence.

That clause is not a trap: it is what makes it possible to publish a complete, auditable, citable edition without giving up the commercial right. If what you build is not published under AGPL — software sold to customers, SaaS, firmware, a device — then it is a commercial licence, and it is a short conversation.

Open · AGPL-3.0-or-later

Everything on this site, nothing held back. Research, study, evaluation and internal tools almost always stop here.

Does AGPL affect you? →

Commercial

The right to embed it in software you do not publish under AGPL, plus support and priority on fixes.

How it works →

Smart2Raw Premium

The edition that is not published. It goes beyond what the smallest native class reaches on its own, and answers composite and multi-column questions.

What it adds →

31 test suites, 0 failures · 100,950 differential fuzz checks with fixed seeds · 6 versions deposited with their own DOI · 2 defects found and published with the minimal case that reproduces each

Why everything on this page can be checked

The demonstration above is not an imitation written in JavaScript. It is include/smart2raw.h itself, compiled to WebAssembly and running in your browser. When it reports a size, the answer came from s2r_pool_bytes(); when it offers a .s2r to download, those bytes were written by s2r_blocked_save().

And every number that can be checked against a naive loop is checked, before it is printed. A disagreement lights a red badge instead of printing a pretty number.

Where to go next

Write the three lines

One header, no build system, no configuration. Or download the single-file demonstration and run it with no internet.

Get started →

See where it loses

The smallest native class is 8 bits, and that has a price. The scope page says what it is, with the number.

Technical scope →

Talk to the person who wrote it

Commercial licence, evaluation with your data, investment — or a defect, which is always welcome.

Contact →