# Filter positives are not object identities

This bounded example separates a candidate read from a verified cache hit.
It is a constructed model, not an execution of Flashield, a Bloom filter,
the Memcachier traces or an SSD.

## Evidence and interpretation

The Flashield paper's lookup diagram includes a final key comparison after a
filter-positive candidate is read. Section 3.4 reports 1% filter false positives
and 1.03 flash accesses per flash hit for its trace; these are different
denominators. The latter is not a universal performance bound.

- Eisenman et al., NSDI 2019, section 3.4 and Figure 5:
  https://www.usenix.org/system/files/nsdi19-eisenman.pdf
- Broder and Mitzenmacher, Network Applications of Bloom Filters: A Survey,
  section 2.1, DOI 10.1080/15427951.2004.10129096:
  https://www.eecs.harvard.edu/~michaelm/postscripts/im2005b.pdf

## Constructed lookup

The supplied candidate sequence has an empty slot, a negative filter result,
a positive result returning the wrong key, then the requested key. It uses
four candidate probes and two reads to establish one hit. A positive result
returning only the wrong key uses one read and remains a miss.

Filter results and keys are explicit inputs. No hashing, segment placement,
concurrency, updates or I/O are implemented. JavaScript string equality stands
in for exact key comparison; it is not a byte-level storage implementation.
Input validation rejects malformed fixtures, including unreachable suffixes.

## Analytic cost, with assumptions visible

Fix K reached candidates whose segments do not contain the requested key.
Suppose each has marginal false-positive probability p, and every positive
causes one extra candidate read. Linearity of expectation gives K*p extra
reads, without requiring independence. Add one read for the final match on
a successful lookup.

At p = 0.01, K = 0, 1, 3 and 15 give 1, 1.01, 1.03 and 1.15 expected total
reads per successful lookup. A miss visiting 16 such candidates gives 0.16
expected reads per missing-key query, not per hit.

Only under independent outcomes is the probability of at least one extra
read 1 - (1-p)^K. For K = 3 it is 0.029701, whereas the expected count is
0.03. If all three indicators instead share one Bernoulli(0.01) outcome,
the expectation stays 0.03 but the probability of any extra read is 0.01.

The synthetic 1.03 coincidence does not infer three candidates in the paper.
Actual cost also depends on which candidates are reached, whether the key
belongs to their segment, and correlation. The nominal nonmember rate cannot
be applied to true segment members. No confidence interval is appropriate
for these exact constructed calculations.

## Reproduce

Files: [calculation](model.mjs), [tests](model.test.mjs),
[generated results](results.json).

With Node.js and no third-party packages:

```sh
node model.mjs --check
node --test model.test.mjs
```

The first command checks results.json byte for byte; --write regenerates it.
Tests enumerate independent outcomes for K = 0 through 8, test dependent
outcomes separately, and cover exact-key checks and invalid inputs.
