{
  "slug": "xor-filter",
  "term": "XOR filter",
  "aliases": [
    "xor membership filter"
  ],
  "definition": "An XOR filter is a static approximate-membership structure that answers a lookup by comparing a key fingerprint with the XOR of three array entries.",
  "note": "For a key set S and k-bit fingerprints, the array holds floor(1.23|S|) + 32 entries in three equal ranges, one per hash function. Construction maps every key to its three slots, repeatedly peels a slot that holds exactly one key onto a stack and then assigns fingerprints in reverse order, so the three entries of each key XOR to its fingerprint. A failed peel is retried with new hash seeds. For small sets the measured success rate per attempt stayed above 0.8, and it approaches 1 for large sets. [xor-paper]\n\nA lookup computes three hashes and reads three entries regardless of the false-positive probability, with no branches. The false-positive probability is 1/2^k, and space is about 1.23 log2(1/e) bits per key, for example 9.84 bits per key with 8-bit fingerprints and a false-positive probability of 1/256, about 0.39%. [xor-paper]\n\nThat is 23% above the lower bound of log2(1/e) bits per key. The 3-wise binary fuse variant uses three locations; the 4-wise variant uses four. For sets of at least a million keys, reach 9 bits per key with a 3-wise layout, 12.5% above the bound, or about 8.6 bits per key with a 4-wise layout that gives up some query speed. Their construction can be more than twice as fast. [fuse-paper]",
  "related": [
    "binary-fuse-filter",
    "bloom-filter",
    "ribbon-filter",
    "sstable",
    "zor-filter",
    "retrieval-data-structure"
  ],
  "status": "shipping",
  "advantages": [
    {
      "text": "About 19% of the entries stay empty, so sending an occupancy bitmap plus only the occupied entries shrinks an 8-bit filter from 9.84 to 9.23 bits per key for transmission.",
      "citationIds": [
        "xor-paper"
      ]
    },
    {
      "text": "The xor+ variant compresses empty entries in the last third of the array with a rank structure and uses 1.0824k + 0.5125 bits per key.",
      "citationIds": [
        "xor-paper"
      ]
    }
  ],
  "limitations": [
    {
      "text": "The filter is immutable, so adding or removing a key means building a new filter from the complete key set.",
      "citationIds": [
        "xor-paper"
      ]
    },
    {
      "text": "At very low false-positive probabilities, around 5.6 x 10^-6, cuckoo filters at full capacity use less space.",
      "citationIds": [
        "xor-paper"
      ]
    },
    {
      "text": "For sets below about 20,000 keys the size advantage of binary fuse filters shrinks, and xor filters may even be slightly smaller.",
      "citationIds": [
        "fuse-paper"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-08",
  "citations": [
    {
      "id": "xor-paper",
      "title": "Graf and Lemire. Xor Filters: Faster and Smaller Than Bloom and Cuckoo Filters. ACM JEA 25 (2020). DOI: 10.1145/3376122.",
      "url": "https://arxiv.org/abs/1912.08258v3",
      "accessed": "2026-10-23"
    },
    {
      "id": "hesela-xor",
      "title": "Hesela. Static filters and reproducible fixed-equation examples.",
      "url": "https://hesela.com/analyses/bloom-filters-lsm-read-cost/#xor-static",
      "accessed": "2026-10-16"
    },
    {
      "id": "fuse-paper",
      "title": "Graf and Lemire. Binary Fuse Filters: Fast and Smaller Than Xor Filters. arXiv:2201.01174 (2022).",
      "url": "https://arxiv.org/abs/2201.01174",
      "accessed": "2026-10-23"
    }
  ],
  "provenance": [
    "xor-paper is arXiv version 3 of the 2020 ACM Journal of Experimental Algorithmics article, read in sections 3 and 4.",
    "fuse-paper is arXiv version 1 of the binary fuse filter article by authors at TELUQ, University of Quebec, read in the abstract, introduction, section 3 and the space results.",
    "The value 0.39% is 1/2^8 = 1/256 rounded, and e in the space formulas stands for the false-positive probability."
  ]
}
