# Vacuum filter memory boundaries

A filter's table-byte counter need not include its whole implementation.
Hesela's native probe of the author's standalone semi-sorted implementation
finds 512 KiB of inline encoding/decoding arrays per object, outside its
`memory_consumption` counter.

This is a reproducible implementation observation, not a filter ranking or a
reproduction of the paper's throughput results. Read the
[Vacuum filter definition](https://hesela.dev/terms/vacuum-filter/) for the design
and update contract.

## Observations

Each row uses a fresh `VacuumFilter<uint16_t, 16>`, four slots per bucket,
400 maximum kick steps, seed 8585 and consecutive keys from 1 through N.
All N insertions succeeded; all N inserted keys were found.
Bits per key use successful insertions as their denominator.

| Inserted keys | Buckets | Table bytes | Object + table bytes | Table bits/key | Object + table bits/key |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 1,000 | 384 | 2,896 | 527,272 | 23.1680 | 4218.1760 |
| 10,000 | 3,072 | 23,056 | 547,432 | 18.4448 | 437.9456 |
| 100,000 | 32,768 | 245,776 | 770,152 | 19.6621 | 61.6122 |
| 1,000,000 | 262,144 | 1,966,096 | 2,490,472 | 15.7288 | 19.9238 |

Each object contains 524,288 bytes of inline arrays. They are already included
in `sizeof(object)`: do not add them a second time. The observed object size
is ABI-specific. Table allocation is the byte count passed to calloc, not
allocator usable size. The total excludes allocator metadata, executable and
shared libraries, temporary stack and page residency. It is not RSS.

The four rows are deterministic checks, not a population sample or a confidence
interval. No absent-key false-positive rate, saturation, deletion, concurrency
or throughput was measured. Other implementations may use different layouts.
The large object cost matters when budgeting many small independent instances;
these observations do not establish a superior competing filter.

## Reproduce

Requires Python 3, g++ with C++17 support and HTTPS access to raw.githubusercontent.com.
Download the linked files into one directory:
[probe.cpp](probe.cpp), [reproduce.py](reproduce.py), [result.json](result.json),
[test_accounting.py](test_accounting.py), [render.py](render.py), and
[README.template.md](README.template.md), plus this [README.md](README.md).

```sh
python3 -B reproduce.py --output fresh-result.json
python3 -B -m unittest discover -s . -p test_accounting.py
python3 -B -O -m unittest discover -s . -p test_accounting.py
python3 -B render.py --check
```

The first command verifies hashes of the pinned headers and MIT license before
compilation, runs the probe, validates its arithmetic and writes a fresh receipt.
It does not overwrite the published historical receipt.
The tests check the published capture and reject missing keys, failed insertions,
incorrect denominators, non-finite values, non-integer byte counts, omitted object
storage and double counting.
`render.py` generates this table from result.json; `--check` detects drift.
Object layout, compiler and platform changes can alter a fresh observation.
The fixed source revision, source hashes, compiler flags and harness hash are
included in each receipt. The harness uses -fno-strict-aliasing for the upstream
packed table accesses; no upstream source is patched.

## Source and license

[Author code, pinned revision ec234bfc](https://github.com/wuwuz/Vacuum-Filter/blob/ec234bfc189af9e6180688495535c623ad352190/vacuum.h)
defines two arrays of 65,536 uint32_t entries and reports only the separate table
allocation through get_bits_per_item(). The
[upstream MIT license](https://github.com/wuwuz/Vacuum-Filter/blob/ec234bfc189af9e6180688495535c623ad352190/LICENSE)
is retrieved and hash-checked alongside the headers.

The publication is
[Wang et al., PVLDB 2019](https://www.vldb.org/pvldb/vol13/p197-wang.pdf).
Its paper figures are not redistributed here.
