Manuscript Offprint
arXiv:2611.05235Catalan Hashing: Efficient Linear Probing for Variable-Length Items
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
A defining feature of the linear-probing hash table is its spatial locality: at load factor , the hash table can be implemented so that each operation scans a single contiguous region of expected size (this is known as the scan cost). This guarantee, however, relies on all items having unit size. In this paper, we ask whether it is possible to achieve a similar guarantee, but in a hash table that stores items of arbitrary lengths .
The main result of the paper is a new hash table called Catalan hashing, which supports amortized expected scan cost for positive queries, for negative queries, and for insertions/deletions, for any constant . As a corollary, we obtain the same bounds in the cache-oblivious model, with a scan cost of translating to I/Os. Along the way, we introduce several high-level techniques that may be of independent interest; this includes a novel way of using erasure codes in order to perform write optimization within a hash table, and a connection to scheduling that allows us to place elements in a way which avoids clustering at high load factors.
1 Introduction
First introduced in the 1950s [48, 35], the linear-probing hash table has stood for more than half a century as one of the simplest and most widely used hash table designs. In its most basic form, the hash table works as follows. Elements live in an array of some size , and each element hashes to a uniformly random position in that array. To insert an item , we examine cells until we find a free cell where we place the item; and, likewise, to query an item , we scan the cells and until we either find , or until we encounter a free cell (meaning that is not present).
What makes linear probing special—both in practice and in theory—is its spatial locality [37, 44, 14, 16, 24, 50]: each operation accesses just one small contiguous region of the hash table. We refer to the size of this region as the scan cost of the operation. (This quantity has also been called the locality of the operation [57]).
At constant load factor , the expected scan cost per operation is . When the hash table is filled to a high load factor for a small parameter , naive linear probing suffers from a phenomenon known as primary clustering [35, 38, 37], which increases the worst-case expected scan cost to . Fortunately, this clustering effect can actually be eliminated with the help of additional algorithmic optimizations (the use of the Robin-Hood ordering to improve queries [3, 19] and the use of graveyard hashing [14] to improve insertions). With these optimizations in place, the expected scan cost per operation is .
The above results all operate under the assumption that items have a fixed size. In many applications, however, this is not the case: An item may occupy an arbitrary number of words (representing, for instance, a variable-length key together with a variable-length value). A common workaround is to use indirection: store a fixed-size pointer in the hash table and allocate the item itself elsewhere in memory. But indirection defeats the very spatial locality that makes linear probing so desirable—each operation must now access multiple separate regions of memory.
This raises a natural question: Can linear probing be adapted to store variable-length items inline, so that the expected scan cost per query is close to , where is the length of the item being queried? In other words, does there exist a data structure that behaves like linear probing, but that supports items of arbitrary sizes?
Such a data structure would also be of direct interest in the external-memory model [1], where memory is divided into blocks of size and the cost of an operation is the number of blocks it accesses (called ). In this model, a linear-probing operation with scan cost incurs I/Os in expectation, so bounds on scan cost translate directly into bounds on I/Os. Thus, another way to frame our question is simply: does there exist a cache-oblivious external-memory data structure in which querying an item costs I/Os in expectation?
This Paper: Catalan Hashing. In this paper, we introduce Catalan hashing, which successfully extends linear probing to support variable-length items. In the final version of the data structure (Theorem 1.4), we are able to support queries with an amortized expected scan cost of
and insertions and deletions with an amortized expected scan cost of
where is a positive constant of our choice. The query bound applies to both positive queries (for elements that are present) and negative ones (for elements that are absent). In fact, for negative
A data structure is cache-oblivious if it does not need to know the block size or cache size in advance.
queries, we are able to achieve an even stronger expected scan-cost bound of , independent of the item size .
We develop our results systematically in five parts. Parts 1–3 cover static and then dynamic constructions in the constant-load-factor regime (load factor ). Parts 4–5 then extend these constructions to the high-load-factor regime (load factor ). We state our results in terms of scan cost, which implies corresponding I/O bounds. We state these explicitly here for our final construction and following the theorems in the main text.
Part 1: Simple Catalan Hashing (Static, Low Load Factor). A naive way to store items inline in a linear-probing hash table would be to store each item as a contiguous block of words starting at or after its hash location . However, as observed by Thorup [54], this can blow up the cost of small items: a single large item of length occupies consecutive cells, so an item of length 1 that hashes into that interval is pushed cells away from its hash location.
In Part 1 (Sections 3 and 4), we introduce (Simple) Catalan hashing, a static linear probing hash table (designed for low load factors ) that resolves the problem described above. The basic idea is to store items non-contiguously, nesting smaller items inside larger ones. We then augment each cell of the table to store an -bit tag indicating where items begin and end. The items are laid out in such a way that, whenever a smaller item overlaps a larger one , is contained entirely within . If one thinks of each tag as encoding either an open parenthesis (starting a new item) or a closing parenthesis (ending the current item), then the tags form a balanced-parentheses sequence (i.e., a Catalan sequence [53]), hence the name of the data structure.
The main result of Part 1 is the following theorem:
Theorem 1.1 (Simple Catalan Hashing). Let be a static set of variable-length items stored in an -cell table at load factor load(. Simple Catalan hashing uses bits of metadata per cell, answers positive queries for any item with expected scan cost , and answers negative queries with expected scan cost .
Note that the bound for negative queries (queries to keys that are absent) does not even depend on the length of the item being queried. Negative queries make use of the following mechanism: If an item hashes to some cell , and is the last item in the table with that hash, then at the end of we store an -bit tag that indicates this. A negative query for a key with hash can therefore stop as soon as it reaches the tag at the end of . Of course, if is very long, then this could make the query very expensive! Critically, however, long items are necessarily rare (the sum of the lengths of all items is at most the size of the table), so a negative query is unlikely to share its hash with that of a long item. Summing over the items in the table, we show that the expected scan cost of a negative query is just .
Part 2: Write Optimization via Erasure Codes (Dynamic, Low Load Factor). Next, in Part 2, we turn to the question of how to support insertions (deletions are deferred to Part 5). Note that, here, we are still only focusing on hash tables that operate at low load factors—we consider higher load factors in Parts 4 and 5.
Note that naively dynamizing the simple Catalan hash table results in severe write amplification (insertions are very expensive). Suppose, for example, that the table stores a long item of length , and we insert an item of length 1 whose hash lands in the middle of . In the static layout, interrupts , so inserting requires shifting the remaining words of forward, giving the insertion a scan cost of . Worse, if is itself nested inside an even longer item , then shifting forces to shift as well, triggering a cascade of updates across items of increasing size.
In the external-memory literature, the classic way to resolve write amplification is to make the data structure write optimized [42, 4, 18, 9, 29, 10, 21]. However, existing write-optimized data structures (such as -trees [18], LSM-trees [42], cache-oblivious streaming B-trees [9], etc.) rely on hierarchical trees of buffers to batch small updates as they trickle down the tree. In a linear-probing hash table, however, there is no tree, and no natural way to add hierarchical buffers in a way that respects spatial locality. Thus, a priori, write optimization would seem to be off the table.
Our solution is a new mechanism for write optimization in linear-probing hash tables: using erasure codes so that large items can themselves act as “buffers” for small items. Instead of storing an item of length directly, we encode using an erasure code of length from which can be reconstructed using any surviving symbols. When a newly inserted short item needs a cell that is currently occupied by a longer element , does not move at all—it simply overwrites 's cell in place. As long as at least of the cells of survive, any query for can still decode in a single contiguous scan, just as before. Only when half of has been overwritten do we reinflate by reinserting it as a fresh length- codeword; critically, at that point, at least words of shorter items have been written on top of , which is enough to amortize the cost of reinflating .
To illustrate the high-level idea behind this technique, we begin in Section 5 with a warmup in which we analyze this erasure-coded Catalan hash table under the simplifying assumption that an erasure oracle notifies the algorithm whenever half of an item's codeword has been overwritten (and supplies the original item to be reinflated). Under this oracle assumption, we prove (Theorem 5.5) that positive queries and insertions both have amortized expected scan cost .
Part 3: Removing the Oracle (Dynamic, Low Load Factor). In Part 3 (Section 6), we show how to remove the oracle assumption from Part 2. What makes removing the oracle nontrivial is that, when a short insertion overwrites a cell belonging to a long item , the algorithm cannot, for example, afford to update any counter that is stored at the start of . Because may be very long, the start of may lie far before the cell being overwritten, so updating a per-item counter on every overwritten cell would destroy our bound on the scan cost of an insertion. This makes it difficult to identify when an item has had more than half of its codewords overwritten.
Our solution is to do nothing at all to when its cells are overwritten, and instead reinflate heavily overwritten items lazily during queries. Whenever an item is inserted, we also store a backup copy of in a secondary backup table that is interleaved into the same physical array. Most queries for an item simply find at least surviving symbols of in the primary table and decode with scan cost . If, however, more than half of has been overwritten, the query falls back to recovering from the backup table and reinflates in the primary table.
At first glance, introducing might appear to be circular, since must itself dynamically store variable-length items. The crucial difference is that a query for only accesses when at least cells of have been overwritten since was last inserted or reinflated. We can therefore amortize the cost of querying (and reinflating ) against the insertions that caused those overwrites. Critically, this means that we can get away with supporting slower queries than what we want in the full data structure—it just needs to support all operations with scan cost . The final contribution of Section 6 is to construct a backup table that does just that. Integrating this into the full data structure gives the following theorem:
Theorem 1.2 (Dynamic Catalan Hashing at Low Load Factor). Fix any constant . There is an insertion-only dynamic Catalan hash table that supports some constant load factor , and that answers positive queries for any item with amortized expected scan cost , answers negative queries with expected scan cost , and supports insertions of any item with amortized expected scan cost .
Part 4: Fair Catalan Hashing (Static, High Load Factors). In Part 4 (Section 7), we move from constant load factors to the high-load-factor regime (load factor for some small ). To tackle this regime, we begin by returning to the static setting.
At high load factors, simple Catalan hashing ends up encountering the same quadratic barrier as classical linear probing—the worst-case expected scan cost for an item becomes . The standard fix in the unit-size setting is to use the Robin Hood hashing [3, 19], which sorts elements in each run in increasing order of hash. But, for variable-length items, this approach fails, because a single long item can blow up the query time of many subsequent short items with larger hashes.
To overcome this obstacle, we establish a connection between variable-length linear probing and preemptive single-server scheduling [51, 33, 32, 6, 5, 26, 28]. If we view each item x as a job of size arriving at time , then we can reinterpret the task of placing the items into the table as a scheduling problem. Under this view, the scan cost of an item x divided by its size is the same as the stretch of the corresponding job.
What we want, then, is a scheduling policy that is fair across all job sizes, guaranteeing worst-case expected stretch . In queuing theory, the simplest such policy is last-in-first-out with preemption, in which newly-arrived jobs immediately preempt any existing jobs. In our hash-table setting, this policy can be viewed as giving priority to items with larger hashes. Note that this prioritization is the exact opposite of the classical Robin Hood ordering [3, 19]. We call the resulting data structure anti-Robin-Hood Catalan hashing (ARCH).
In Section 7, we give a simple, self-contained proof that the ARCH table does, indeed, guarantee an expected scan length of at most . Perhaps ironically, this means that the anti-Robin-Hood ordering is actually fairer than its Robin Hood counterpart, once we allow for variable-length items.
Theorem 1.3 (Anti-Robin-Hood Catalan Hashing). Let , and let be a static set of items stored in an -cell table with load factor load. Anti-Robin-Hood Catalan hashing (ARCH) uses bits of metadata per cell, answers positive queries for any item with expected scan cost at most , and answers negative queries with expected scan cost at most .
We remark that, although the anti-Robin-Hood ordering bounds the expected stretch of every item, which is what we need in Part 5, its expected maximum stretch can be quite large: if the table contains many items of length 2 and a single item of length , then with constant probability the long item preempts one of the short items, giving that item stretch . As an additional result, we show how to bound the expected maximum stretch as well. We adapt the fair-sojourn scheduling protocol of Friedman and Henderson [26] to design a variant of Catalan hashing with expected scan cost at most and expected maximum stretch at most (Theorem 7.5).
Part 5: Dynamic Catalan Hashing at High Load Factors. Finally, in Part 5 (Section 8), we combine our static ARCH construction from Part 4 with our dynamic low-load-factor construction from Parts 2 and 3 to obtain a fully dynamic Catalan hash table at load factor (supporting both insertions and deletions).
Note that the dynamic erasure-coded hash table from Parts 2 and 3 cannot be run directly at load factor : its write-optimization machinery inherently loses a constant factor in space. Conversely, the scheduling-based approach from Part 4 achieves load factor with only bits of metadata per cell, but is inherently static.
To get the best of both worlds, we use a structure inspired by graveyard hashing [14]. At a high level, we store almost all of the items in a static ARCH table at load factor , while routing new insertions into a much smaller dynamic erasure-coded table of size that operates at constant load factor. Because is only a fraction of the size of , its constant-factor space overhead consumes only cells in total. Moreover, so that an operation
It is worth noting that this bound holds not just asymptotically but exactly.
that accesses both tables still scans just one small region of memory, we interleave uniformly into within a single physical array—placing one slot of every slots of —and use a shared hash function for both tables. That way, any operation that probes both and still traverses a single contiguous region of memory around (stretching the physical scan cost of by a factor of ).
Insertions go directly into , and a query simply searches both tables. After every words of insertions, we perform a global rebuild that merges into using sequential passes over the table. Because the rebuild occurs only once every words of updates, its cost amortizes to per inserted word—or for an item . To support deletions without making negative queries depend on the key length, we keep constant-size fingerprints of deleted static keys in another interleaved table, checking for collisions during rebuilding. The details, together with the low-load deletion mechanism, appear in Section 8 and Appendix C. Putting these pieces together gives our main result:
Theorem 1.4 (Dynamic High-Load Catalan Hashing). Let and let be a constant. There is a dynamic Catalan hash table operating at load factor that supports positive queries for any item with amortized expected scan cost
supports negative queries with amortized expected scan cost , and supports insertions and deletions of any item with amortized expected scan cost
As an immediate corollary we also get the following result in the external memory model, establishing the existence of a linear-probing-like data structure for items of arbitrary sizes.
Corollary 1.5 (Dynamic High-Load Catalan Hashing in External Memory). Suppose for a sufficiently large constant , where is the maximum length of any item stored or inserted during the operation sequence. The hash table of Theorem 1.4 is cache-oblivious and, for every block size , supports positive queries for any item in amortized expected
, supports negative queries in amortized expected , and supports insertions and deletions of any item in amortized expected
.
Paper Outline. The rest of the introduction is spent discussing in more detail related work on linear probing and on external-memory data structures. Then, after preliminaries in Section 2, we introduce the basic machinery that all of our static constructions share in Section 3, and then we complete Parts 1–5 in Sections 4 to 8, respectively.
All of the data structures in this paper come with natural corollaries for the external-memory model [1] (see Section 2 for a more formal treatment of this model). In many settings, the algorithm may not know the block-size parameter in advance (or may even be interacting with multiple different types of caches, using different block sizes, simultaneously). Algorithms that get strong guarantees even in this setting (such as those in this paper) are known as cache oblivious [27]. These models underlie a large body of search structures and write-optimized dictionaries, including cache-oblivious B-trees [8], packed-memory arrays and their adaptive variants [13], -trees [18], log-structured merge (LSM) trees [42], and cache-oblivious streaming B-trees [9]. There has also been a great deal of work on designing hash tables and unordered dictionaries in this setting [23, 41, 40, 30, 45, 29, 21, 14, 7, 16], but with a focus on settings where all items have the same lengths.
Prior to this paper, most of the work on external-memory data structures for variable-length objects has focused on how to extend the B-tree and its variants to the variable-length setting [25, 17, 11]. In contrast, in the current paper, we study the question of how to best extend the guarantees of a hash table. Perhaps surprisingly (with the exception of [54] which we will discuss shortly), this question does not appear to have been considered in prior work.
The idea of placing variable-length strings into a linear-probing hash table appears to have been first discussed in Thorup’s paper on designing hash functions for hash tables storing strings [54, Section 6, Theorem 6.1]. For load factor , Thorup bounds the expected probe length for a positive query to a string by , where is the second-moment-to-first-moment ratio of the string lengths in the table . When the table contains even a few very long strings, can be much larger than , causing queries for short strings to pay for the lengths of unrelated long strings. One of the first insights in the current paper, is that by allowing shorter strings to nest within longer ones (via Catalan hashing), we can avoid this kind of cost blow-up for queries to short strings.
Throughout this paper, we assume access to fully random hash functions. There has also been a great deal of work on how to implement linear probing with explicit hash functions [44, 46, 54, 55,
47, 15], as well as, more generally, how to simulate random hash functions for essentially any hash table [52, 43, 22] (see, e.g., the discussion in [12]).
2 Preliminaries
Conventions. All logarithms are base 2. In asymptotic cost bounds, we use the convention for . For ease of exposition, we ignore divisibility and rounding issues whenever they do not affect the stated asymptotic bounds.
Items, Keys, and Lengths. All lengths in this paper are measured in words. As in the standard word-RAM model, we assume that a word has at least bits for some constant .
The elements stored in our hash table are variable-length items. Each item consists of a key and a value , both of which may have variable length (the value may also be empty). We store as a sequence of words, which we call the length (or size) of , encoded so that the key can be read off from a prefix of (for example, by storing the length of at the start of , or by ending with a terminator, as in a C string). Each key belongs to at most one item in the hash table, and we sometimes write for the key of and for the value of .
A query is given only a key ; it returns FOUND and the value , where is the item with key if there is one (a positive query), and NOT FOUND otherwise (a negative query). (If values are empty, a positive query simply returns FOUND). In particular, a query does not necessarily know the length of the item it is looking for. In our query bounds, for positive queries, denotes the item found. For negative queries, the bounds hold with , independently of the length of the query key. All hash functions are applied to keys, so the hash of an item depends only on its key, and we write where convenient.
Hashing, Load Factor, and Runs. In this paper, a hash table consists of cells, indexed cyclically as (or equivalently ). We assume access to a fully random hash function that maps each key independently and uniformly to the continuous circle . We treat hash values as real numbers, and assume that basic operations on them, such as arithmetic and comparisons, take time. We also assume that the sequence of operations is fixed in advance, independently of the hash functions, or equivalently, that the input sequence is chosen by an oblivious adversary. The canonical cell of an item is determined by its key , defined as . The fractional part of may be used to break ties between items hashing to the same canonical cell.
Given the set of items stored in an -cell table, the total volume of is , and the load factor (or fill) of the table is . When , we say that the table has load factor at most and . Any metadata used by the algorithm is not counted in the load factor, but the metadata used in the hash table in this paper only adds a constant factor overhead in the constant-load regimes and is a low-order term in the high-load regimes. In the low-load-factor sections of the paper (Sections 4 to 6), we assume , i.e., the load factor is bounded away from 1 by a positive constant. In the high-load-factor sections (Sections 7 and 8), we parameterize the performance directly in terms of .
A run (or cluster) is a maximal contiguous interval of occupied cells in . Whenever load, at least one cell of is empty, so every run is preceded immediately by an empty cell and has a well-defined left-to-right linear order obtained by unwrapping the circular array at that
We make this assumption for ease of exposition. To break ties with high probability, we only need bits of precision.
empty cell. For a query to the key of an item , the length is the number of contiguous cells inspected by the query starting from , and the stretch is .
Scan Cost. Nearly all of our algorithms access a contiguous cyclic interval of the hash table. Following classical linear-probing work [35, 37], we define the cost of an operation on the hash table as the size of the smallest cyclic interval that contains all of its accessed cells. Our primary analysis will report the scan cost of our algorithms, which then can be easily converted into external-memory cost (defined below).
The External-Memory and Cache-Oblivious Models. We use the standard cache-oblivious model of Frigo, Leiserson, Prokop, and Ramachandran [27], building on the external-memory (I/O) model of Aggarwal and Vitter [1]. In the external-memory model, memory consists of an internal cache of size words and an external memory partitioned into blocks of consecutive words. An transfers one block of words between cache and external memory. The cost of a sequence of operations is the number of I/Os that it incurs. An algorithm is -oblivious if its specification does not depend on the parameters and ; these appear only in the analysis.
We store the table using a uniformly random rotation (chosen at initialization, independently of the hash function). A forward scan of a contiguous interval of cells costs I/Os, and in expectation over the rotation. The same bounds hold for an operation making forward passes over the interval. We refer to this cost as the property.
For ease of exposition, we assume circularity of the array in the remainder of this paper and do not explicitly refer to circular order, cyclic intervals, etc., except where necessary. We will sometimes implicitly or explicitly refer to the hash or other functions as cyclically as follows. If a run starts at cell , wraps around the end of the array and ends at cell and , we consider 's hash to be , so that within the run, hashes are always monotonic.
We remark that one can also straightforwardly optimize the data structures in this paper to be efficient in the word-RAM model, so that the time per operation is the same as the scan cost (plus ). The only nontrivial optimization needed is to replace the erasure codes introduced in Section 5 with codes that supports linear-time operations [2].
Cache-Size Assumptions. We make what we call the assumption, which says that the cache has room for the query key, one other key, the parser state, and a sufficiently large constant number of blocks. This is the only cache-size assumption needed by the static constructions (Sections 4 and 7). The dynamic constructions will require moderate additional amounts of memory as stated in their respective sections.
3 Catalan Hashing
This section introduces the common infrastructure used by the hash tables in this paper, all of which we refer to as types of Catalan hashing. The static constructions in this paper (Sections 4 and 7) will make direct use of the framework described here, while the dynamic sections (Sections 5, 6 and 8) will need to white-box extend it in various ways.
The Nesting Property. In a Catalan hash table, we do not necessarily store each item contiguously. Instead, we allow some items to others. For example, if we have one very large item , say of length 100 with canonical cell , and one very small item , say of length 2 with , then we might place the first two words of in cells 1 and 2, then place the two words of in cells 3 and 4, and then resume placing the remaining 98 words of in cells 5 through 102. This allows the short item to avoid paying any kind of substantial query penalty for being placed near a large item .
Formally, our static constructions will satisfy the following nesting property. For each stored item in a run, let denote the interval of cells from the first word of () to the last word of ().
Definition 3.1 (Catalan Nesting Property). A placement of items into satisfies the Catalan nesting property if, within every run, for any two distinct items and :
(1) Either and are disjoint (), or one is strictly contained in the other ( or ); and
(2) Whenever , no cell in stores a word of (equivalently, the entire interval lies strictly between two consecutive cells assigned to ).
When describing a given static construction (in Sections 4 and 7), the key distinguishing feature will be the placement rule that we use within the table. This rule is responsible for deciding which items are nested within which other items, and where the nesting starts and ends. The simplest construction that we consider (simple Catalan hashing in Section 4) uses a placement rule in which smaller items always take priority over larger items. This, as we will see, leads to good results in hash tables that are not very full (load factor ), but not for hash tables that are much fuller (load factor ). To obtain hash tables that behave well even under high load, we will end up needing a more sophisticated placement rule (fair Catalan hashing in Section 7).
The Catalan Representation. The static constructions in Sections 4 and 7 use the following basic metadata scheme which we call the Catalan representation.
The Catalan representation augments each cell of with a 3-bit delimiter tag taking one of five values:
OPEN, MIDDLE, CLOSE, OPEN-CLOSE, EMPTY.
An unoccupied cell is marked EMPTY. If an item has length , the single cell holding its word is marked OPEN-CLOSE. If , the cell holding the first word of is marked OPEN, the cell holding the last word of is marked CLOSE, and the cells holding the interior words of are marked MIDDLE.
The name Catalan hashing comes from the combinatorial structure of these delimiters: in any run satisfying Definition 3.1, if we ignore MIDDLE tags and view OPEN as “(”, CLOSE as “)”, and OPEN-CLOSE as “()”, the sequence of delimiters in the run forms a balanced parenthesis string, known as a Catalan sequence [53].
Each cell additionally stores 2 bits called the home and stop bits. The home and stop bits indicate home and stop cells, which are used to limit the scan length of negative queries. A cell which is the canonical cell for some item in the table is called a home cell. Each home cell j has a corresponding stop cell, which is the last cell containing a word from an item whose canonical cell is j.
Parsing the Nested Structure. For a placement satisfying the Catalan nesting property, any occupied cell belongs to the innermost item interval that contains it. This makes it possible for a query starting at any cell t (including a cell in the middle of a run) to parse the stream of cells using a stack-based pushdown automaton which we will refer to as a Catalan parser. At a high level, the parser maintains a stack of the items that it has seen open (via their OPEN tags) but not yet close (via their CLOSE tags). By the nesting property, every MIDDLE or CLOSE cell that it reads belongs to the item on top of the stack, or, if the stack is empty, to an item that opened before t. For each item on the stack, the parser tracks how many of the item's words it has read and whether they agree with the query key so far, so that it can recognize a matching item as soon as that item's last word is read. The parser's behavior is described in more detail in Appendix A.
Query Procedure. With the help of this parser, queries work as follows. A query for a key runs the Catalan parser forward from the canonical cell , and stops as soon as one of the following occurs:
-
is not a home cell (its home bit is unset). Then no item in the table has canonical cell , so the query returns NOT FOUND without scanning further.
-
The parser finishes reading an item with . The query returns FOUND, together with the value of .
-
The parser finishes reading an item with and whose last cell is a stop cell (its stop bit is set). Every item with canonical cell ends at or before this cell, so the query returns NOT FOUND.
Negative versus Positive Queries. One risk for negative queries is that, if an item is not in the table, but has the same canonical cell as a very large item in the table, then the scan cost for will be very high (going at least to the end of ). On the other hand, large items are rare, since the sum of the sizes of all items can be at most . This is formalized by the following lemma, which shows that efficient positive queries immediately imply efficient negative queries, regardless of the placement rule used.
Lemma 3.2 (Negative Queries Versus Positive Queries). Consider a static implementation of Catalan hashing using an arbitrary placement rule. For each item , let be the scan cost for querying . Let be a parameter, and suppose that for each . Then, for any item not in the table, the expected scan cost of a negative query for is at most .
Proof. Let be the scan cost of the negative query for . We first observe that
Indeed, if is not a home cell for any , then the query stops immediately and ; otherwise, is simply . Either way, (3.1) holds.
We may therefore conclude that
Since is uniformly random, and independent of the randomness used to determine (or more generally, to place the items into the table), we have that . Therefore,
Since , the claimed bound of follows.
Priority Rules and Construction. All of the static placement rules in this paper are derived from different priority rules. A priority rule assigns a priority to each item , which can potentially depend on all the items in and their hash values. When multiple items contend for a given cell, a word from the item of highest priority is placed there. We write to denote . A priority rule uniquely determines the placement rule, which we realize with the following equivalent constructions.
Bottom-up: Place the items in decreasing priority order as follows. For each item , place the words of in the first empty cells at or after . Items are never moved, so the previous placement of higher priority items restricts the empty cells available to .
Left-to-right: Starting from beginning of the array, scan forward, maintaining a max-heap of items by priority order and processing cells one at a time. For each cell , insert all items with into the heap, then place the next word of the maximum-priority item into . When all the words of an item in the heap are placed, extract it. At the end of the table, if there are still words in the heap left to place, restart at the beginning. This second pass evicts the word in each cell if it has lower priority than the maximum-priority item in the heap, in which case the evicted word is inserted back into the heap. Because the load of is less than 1, the heap will empty before the end of the second pass.
Arbitrary order: Place the items in in an arbitrary order. Call a cell available for if it is empty or contains a lower-priority item. For each item , place the words of in the first available cells after . Whenever a word of a lower-priority item is evicted, reinsert that word and the remaining suffix of in logical word order. Starting at the evicted cell, use the first cells that are empty or contain words of or of a lower-priority item, so that the suffix shifts to the right while reusing cells already assigned to . Apply the same rule to any further evictions, continuing until all words are placed. This process must terminate, since the load of the table is less than 1.
A placement rule determined by a priority automatically satisfies the Catalan nesting property.
Lemma 3.3. If the placement of items in is determined by a priority rule, then it satisfies the Catalan nesting property.
Proof. Let . In the bottom-up construction, all the words of are placed first in the first free cells. Therefore, there are no free cells in , and so when is placed, no words of will be placed in .
Note that for a static construction for a Catalan hash table, all we need to specify is the priority rule used. This is captured formally via the following definition, which we invoke in Sections 4 and 7.
Definition 3.4. Given a priority rule , the static Catalan hash table is the hash table with placement rule and construction determined by , using the Catalan representation, parser and query procedure.
4 Simple Catalan Hashing (Static, Low Load)
We now present and analyze simple Catalan hashing, a static implementation of Catalan hashing designed to operate at low load factors.
Prioritizing Smaller Items. Simple Catalan hashing prioritizes items according to their length: shorter items have strictly higher priority than longer items. Ties between items of the same length are broken in favor of the item with the smaller hash value. Formally, if , or if and .
Given with load, we define the simple Catalan hash table to be as in Definition 3.4. Following Section 3, this defines a placement rule and construction, and uses the Catalan representation and query algorithm.
Analysis. A key property of simple Catalan hashing is that, to analyze the cost of a positive query for an item of length , we can ignore all items in of length greater than .
Formally, let be the subset of items of length at most , and imagine forming a Simple Catalan hash table containing only the items in . In , every cell that is empty corresponds in the full table to either to an empty cell or to a cell occupied by some item of length .
Lemma 4.1. The cost to query x in is the same as the cost to query x in .
Proof. In the bottom-up construction, the items of are placed before every item of , so each item of occupies exactly the same cells in as in . Since , the lemma follows.
We now bound the length of the run containing in . We also prove a bound on the second moment of the run length, which we will use later in the paper.
Lemma 4.2. Let be the length of the run in containing . Then
Proof. Condition on , and partition the table into blocks of cells. Let be the set of blocks that intersect the run containing , and let . Every word in the run belongs to an item hashing into the run. All of the blocks in except for the two end blocks are entirely covered by the run, and itself accounts for only words, so the items of hashing into have total length at least
For a fixed interval of blocks, let be the total length of the items of hashing into . Then is a sum of independent random variables, one per item of , each taking values in , and
Since is fixed, applying a Chernoff bound to (a sum of independent random variables in with mean at most ) gives, for all sufficiently large ,
If , then is one of the at most intervals of blocks that contain the block of , and . Taking a union bound over these intervals,
and therefore both and . Finally, , so and .
Theorem 1.1 (Simple Catalan Hashing). Let be a static set of variable-length items stored in an -cell table at load factor load. Simple Catalan hashing uses bits of metadata per cell, answers positive queries for any item with expected scan cost , and answers negative queries with expected scan cost .
Proof. Each cell stores a 3-bit tag, a home bit, and a stop bit. Consider a positive query for an item , and define and as above. By Lemma 4.1, the query has the same scan cost in as in . In , the query scans from through the last word of , all of which lies in the run containing , so its scan cost is at most . Thus, by Lemma 4.2, there is a constant (depending only on the load factor) such that a positive query for any item has expected scan cost at most . By Lemma 3.2, it follows that any negative query also has expected scan cost at most .
Corollary 4.3 (Simple Catalan Hashing in External Memory). Under the working-set assumption of Section 2, the hash table of Theorem 1.1 is cache-oblivious and answers positive queries for any item in expected I/Os and negative queries in expected I/Os.
It is worth remarking on why the analysis in this section does not extend to get an bound at high load factors . Recall that, in a standard linear probing hash table (with unit-sized items), the expected length of the run containing a given cell is . Now, consider a table in which all but one item has size 1, and one item has size 2. The item has lower priority than any other item, and will therefore go at the end of the run formed by elements of size 1. But this forces a scan length of , which has a quadratic dependence on the load factor. We will see in Section 7 that this can be avoided by using a more sophisticated placement rule.
5 Write Optimization via Erasure Codes (Dynamic, Low Load)
Next we turn to the question of how to support insertions in the Catalan hash table. In this section and the next we focus on the insertion-only regime and defer deletions to Section 8 and Appendix C. Additionally, for this section only, we streamline our presentation by considering only positive queries (not negative ones).
Why Naive Dynamization Fails. At first glance, it might seem simple to dynamize simple Catalan hashing: whenever a new item x is inserted, we could simply update the table so that its layout matches the static simple Catalan table on the current set of items.
The most straightforward way to do so would be when inserting an item , to insert it and evict all cells with words from lower priority items that block its placement. These evicted words are then shifted and placed, possibly triggering further evictions of even lower priority items, and so on. However, this naive dynamization incurs substantial overhead. To see why, suppose the table currently stores a long item of length in cells . Now suppose we insert a tiny item of length with hash . Because , has higher priority than and must be placed in cell 1. This forces all words of to shift, incurring a scan cost of and an I/O cost of .
One could try to improve this cost by allowing the words of y to be stored out of order. Then in the prior example, the first word of y could be evicted to the next available cell, while the other words of y stay in place. However, this doesn't change the scan cost, since the evicted word of y has to be placed after the other L words. Similarly, in the external-memory model this incurs a random access, which in general adds an I/O.
In the external-memory literature, this phenomenon in which a small logical update triggers a much larger physical reorganization of memory is known as write amplification. The standard way to combat write amplification in external-memory search trees (such as -trees [18], LSM-trees [42], and cache-oblivious streaming B-trees [9]) is to introduce buffers at the nodes of a tree, which collect small updates until enough have accumulated to amortize the cost of moving them down a level.
In a linear-probing hash table, however, there is no tree hierarchy, and we cannot redirect insertions to an external buffer without breaking the core guarantee that queries execute in a single contiguous scan of I/Os. How, then, can we perform write optimization inside a flat, inline array?
5.1 Using Large Items as Write Buffers With Erasure Coding
Our key insight is that we can use erasure codes to turn the large items themselves into in-place write buffers for smaller items.
Specifically, we use a standard maximum distance separable (MDS) erasure code (such as a Reed-Solomon code) as a black-box primitive [49]. The MDS code generates, for each item , codewords with the property that we can decode from any of the . We then store as the representation of in the table, and allow items of higher priority to simply overwrite the codewords. The MDS property ensures that as long as at most words are overwritten, queries can still decode . The basic idea is that, until words are overwritten, the item does not need to be moved at all; and once words have been overwritten, we can afford the cost of “reinflating” , that is, of reinserting from scratch to once again have a codeword of length .
One issue that proves (surprisingly!) challenging is how to detect when more than words have been overwritten. A natural approach would be to keep a counter (perhaps at the start of ) keeping track of how many codewords have been rewritten. But if a small item overwrites a few codewords in the middle of , it cannot afford to update such a counter, as that would dramatically increase the current operation’s scan cost. To separate this issue (determining when more than words have been overwritten) from the other algorithmic issues involved, we assume in this section that we have an oracle that simply tells us when more than half of the codewords for a given element have been overwritten (we will describe this oracle in more detail shortly). We then devote Section 6 to removing the oracle assumption.
Note that the erasure-coding approach fundamentally requires operating at a low load factor, since we are effectively doubling the size of every item. Moreover, the metadata scheme we use will add an additional words to each cell to enable parsers to distinguish words of different items. Additionally, in Section 6, we will further add an additional constant-factor in space overhead due to the backup-table technique that we introduce. Thus, the constructions in this section and the next are fundamentally limited to low constant load factors. We will, however, be able to get analogous results at high load factors using the additional techniques introduced in Sections 7 and 8.
5.2 Warmup: Using an Erasure Oracle
The rest of this section will be a warmup that uses an erasure oracle to sidestep the challenge of dealing with too many overwritten codewords. The erasure oracle notifies the algorithm when the number of surviving codewords of a stored item drops to and provides a copy of the original item. The algorithm incurs no cost from the oracle. Section 6 removes the oracle assumption. As noted earlier, we focus here on insertions and positive queries only (no deletions or negative queries).
Metadata. Overwriting cells in place can break the parser for the static Catalan representation
(Section 3). A higher-priority insertion can overwrite any cell of a lower-priority item , including 's first (OPEN) or last (CLOSE) cell, which would orphan 's remaining MIDDLE cells. Moreover, MDS erasure decoding requires knowing which codeword each surviving cell holds.
We therefore use a different metadata scheme that encodes for each cell containing a codeword of :
-
's item length ,
-
the codeword index , and
-
a unique owner identifier, ID().
For this warmup, we take ID() to simply be the number of insertions performed before , which is less than . Thus the metadata for each cell is words. The ID is used to distinguish the items corresponding to different cells, so we cannot simply use the canonical cell (or a truncated hash) because then collisions would make the resulting cells indistinguishable. We also change the tie-breaking mechanism for items of the same length to use the ID rather than the hash (as in Section 4). This is because we want to be able to determine the relative priority of items directly from the metadata.
Insertions and queries use a simple parser that separates words of items using their IDs and tracks them with a stack.
Insertions and Reinflations. To perform INSERT(), first encode the item into . Let denote the set of cells holding codewords of items . We say a cell is available to if it is not in , that is, if it is empty or holds a codeword of or of a lower-priority item. Starting at , scan forward and write into the first cells available to . Whenever a cell containing a word of a lower-priority item is overwritten, the algorithm asks the oracle if only codewords of are still present. If so, this triggers an immediate reinflation of .
To perform REINFLATE(), we simply run INSERT() again using the copy of obtained from the erasure oracle, keeping the same identifier ID() (so 's priority does not change). Since cells holding codewords of are available to , we will see in Lemma 5.2 that this overwrites all remaining codewords of from before the reinflation.
Queries. As noted earlier, in this section, we only describe positive queries. The function QUERY() starts scanning at , parsing cells and collecting codewords for the items that it reads. Whenever it obtains codewords for an item , it decodes it and compares with until it finds a matching item.
5.3 Analysis
In this section we prove results in the slightly more general case that operates as above, but may decide to perform REINFLATE() at any time when there are at most surviving codewords (this will be helpful for extending the analysis in later sections). We will also slightly abuse notation and define the query cost of to be the scan cost of reading to the cell that contained the last codeword of when was most recently inserted or reinflated. Using the erasure oracle guarantees that REINFLATE() is performed any time there are exactly surviving codewords, and positive queries always terminate at or before the above cell.
Recall that a cell is said to be available to if it is not in (i.e., it does not contain a codeword of an item with higher priority than ). Furthermore, define the priority of a cell to be the priority of the item whose word it holds, and 0 if the cell is empty. The following two lemmas state basic structural invariants in terms of these definitions.
When interpreting the following lemma, note that the algorithm never clears a cell; it only writes codewords. We will see in Lemma 5.2 that a reinflation of overwrites all remaining codewords of anyway, but by convention, any old codeword that a reinflation did not overwrite would simply remain in place.
Lemma 5.1. The priority of each cell never decreases over time.
Proof. Since cells are never cleared, a cell changes only when an item writes to it. The cell is then available to , so its priority was no higher than that of . (Equality occurs when a reinflation of overwrites an old codeword of .)
Lemma 5.2. At a fixed point in time, if there are surviving codewords of in , then they occupy the first cells available to at or after . In particular, a reinflation of overwrites all remaining codewords of , so the table never holds stale codewords.
Proof. Consider the most recent insertion or reinflation of , and let be the cell where it writes . By construction, it writes the codewords of into the first cells available to at or after , so afterward every cell in is either in or holds a codeword of .
Now consider what has happened to the cells in since was last inserted or reinflated. A cell containing a codeword for can only be overwritten by an item to which it is available. Thus an item of lower priority than cannot overwrite any of 's codewords, and an item of higher priority than that overwrites a codeword of moves that cell into . Once a cell enters , it stays there by Lemma 5.1. Thus, at the current time, the cells in are exactly those containing surviving codewords for .
Finally, we must argue that when the next reinflation occurs, all of 's surviving codewords get overwritten (no stale codewords are left behind). We have already shown, however, that 's surviving codewords from last time it was inserted or reinflated are among the first cells available to ; since the reinflation overwrites all of those cells, it must overwrite all of 's surviving codewords.
Next we turn to analyzing queries. We argue that we can directly bound the scan cost for a query by what the scan cost would be in a static table if every item was resized to have size . To formalize, this, we introduce the following notation. Let be the set of items present at the end of the operation sequence; since there are no deletions, every item that is ever inserted is in . For an item , let , which includes and every item of higher priority than . Let , where we view as an item of length with hash . Let be a static Catalan hash table on , and let be the length of the run in containing . Since load() load(), if load() then Lemma 4.2 (applied to ) gives and .
Lemma 5.3. Let . The query scan cost of , and the scan cost of an insertion or reinflation of (excluding the reinflations that it triggers), are at most .
Proof. Consider an insertion or reinflation of , and let be the cell where it writes its last codeword. To prove the lemma, it suffices to show that lies within the run of containing .
At the moment the insertion or reinflation finishes, every cell of is either in or holds a codeword of . For each item , let be the item formed from the surviving codewords of at that moment, with hash , and let be the set of these items together with . By Lemma 5.2, each item of occupies the first cells at or after its canonical cell that are not occupied by items of higher priority. So the cells of , together with the cells of , are exactly the occupied cells of the bottom-up placement of (as in Section 4) in the priority order .
In any such placement, a cell is empty if and only if, for every , the items hashing into have total length at most ; in particular, the set of occupied cells does not depend on the priority order. Each item of is no longer than the corresponding item of and has the same hash, since every item satisfies . So every cell occupied in the placement of is also occupied in . In particular, every cell of is occupied in , so lies within the run containing .
Amortizing Reinflations. Finally, we now give a simple argument that bounds the total cost of all reinflations of a given item . We also prove a second-moment bound on the number of reinflations that we will be helpful later in the paper (in the proof of Theorem 1.2).
Lemma 5.4. Suppose load. For an element , let denote the number of times is reinflated over the entire input sequence of and be the query scan cost in immediately after the last reinflation of .
Then
Proof. Let denote the query scan cost of after the -th reinflation. Since cells belonging to must be overwritten between reinflations, Lemmas 5.1 and 5.2 imply for all . Therefore .
By Lemma 5.3, . Therefore, by Lemma 4.2,
and
Since in the lemma above is a bound on the total scan cost of all reinflations of x, we can now complete the analysis of the data structure:
Theorem 5.5 (Dynamic Catalan Hashing in the Erasure Oracle Model). In the erasure oracle model at load factor , there is an insertion-only dynamic Catalan hash table in which a positive query for an item has expected scan cost , and an insertion of has amortized expected scan cost .
Proof. By Lemma 5.3 and the bound , a positive query for scans cells in expectation. We now bound the expected amortized cost of reinflations. Let , , and be as in the preceding lemma. The algorithm performs reinflations, each of which has scan cost at most . Therefore the expected amortized cost of reinflations of is by Lemma 5.4. We charge the cost of these reinflations to the initial insertion of . Ignoring the cost of reinflations that an insertion triggers, insertions have expected scan cost by Lemma 5.3. Thus the overall amortized expected scan cost of an insertion (including the costs of reinflations) is .
6 Removing the Oracle via Lazy Reinflation from a Backup Table
In Section 5, we constructed a dynamic Catalan hash table that used an erasure oracle to prevent items from being overwritten too much. In this section, we show how to remove the oracle. Rather than trying to simulate the oracle directly (which is difficult to do without increasing scan cost, as explained in Section 5.1), we remove the oracle by taking a different approach.
When we insert items, we insert them both into the actual table, and into a second backup table that is interleaved with the actual table. The backup table is less efficient than the full table (incurring roughly factor overhead on all operations), and is used by queries only when query cannot recover enough codewords in the main table to reconstruct the element x it is looking for. When this happens, we recover x from the backup table, and reinflate x. We call this a lazy reinflation, since the reinflation is only performed when necessary when a query actually fails to be able to reconstruct x. Critically, we show that we can charge the cost of lazy reinflations to the original insertion of x; this allows us to charge the inefficient-ness of the backup table (which is inefficient for both insertions and queries) to insertions only, without affecting the amortized cost of queries.
To make the above construction work with negative queries we also introduce another interleaved table that stores fingerprints of present items. This enables queries to determine membership (whether the element queried is present) efficiently, and therefore allows negative queries to (most likely) avoid having to go into the backup table at all.
6.1 High-Level Construction: How to use the Membership and Backup Tables
We now formalize the high-level construction described above. For now, we treat the backup table as a black box, and focus on how to use it within the larger data structure.
Our starting point is the dynamic Catalan hash table from Section 5 with the same priority order, metadata, and insertion and reinflation procedures as defined in that section. (Below we do change the unique IDs used to index items, but they function in the same way.)
We add two secondary tables interleaved evenly with : a backup table , which stores full items (that cannot be overwritten), and a membership table , which stores compact fingerprints for keys that are present. All three tables store items using the same hash function , so that for each key , refers to the three adjacent cells with one cell from each table. We abuse notation and refer to this triple of cells as .
Interleaving the three tables is key to maintaining the property that all data is stored in a shared physical array, thus avoiding a blowup in scan costs or I/Os from the addition of these auxiliary tables. Operations will scan forward starting from , parsing cells from each table, which we think of as running concurrent operations on all three tables (some of which may be no-ops).
We will assume throughout this section that the load factor is at most a small positive constant of our choice. We refer to the combined interleaved table as ; we will frequently write simply when the component tables are clear from context.
The Membership Table and Negative Queries. The membership table is a standard unordered fixed-length linear-probing hash table. For each item , stores a triple , where is a fingerprint, and is the index of the last cell occupied by a codeword of at the time of its insertion or last reinflation. The fingerprints are computed with an independent hash function and are bits in length, for a sufficiently large constant .
A query for a key begins by scanning from to the first empty cell of , collecting the entries whose fingerprint is . If there are none, the query returns NOT FOUND. Otherwise, it runs the positive-query procedure described below for each matching entry. Since the tables are interleaved, scanning cells of has scan cost in . The stored length tells the query how many codeword symbols suffice to decode a candidate; we will also use it to support deletions in
Appendix C.
We also redefine in this section the unique ID of each item to be the index of its position in . Unordered (and insertion-only) linear-probing hash tables are stable (items do not move after insertion), so the IDs do not change over time. As we will discuss shortly, this re-definition of ID is helpful to positive queries for determining which codewords in the main table correspond to the item being queried.
The following lemma shows that negative queries are efficient in this construction.
Lemma 6.1. A negative query to has expected scan cost .
Proof. Let be a key not in the table. Since holds one entry per item of , it is a unit-size linear-probing table at load factor at most load() < 1 - . So the run of containing , and hence the scan of from to the first empty cell, has expected length by Lemma 4.2 (applied with unit-length items, with added as one of them). The query returns NOT FOUND at the end of this scan unless some item has . Each item collides with with probability , so by a union bound a collision occurs with probability at most . Every operation has scan cost at most polynomial in , so for a sufficiently large constant , collisions contribute to the expected scan cost.
The Backup Table and Lazy Reinflation. The backup table stores a second copy of each item that cannot be overwritten, together with its ID. It will have potentially worse performance guarantees, incurring expected scan cost for some function for both insertions and queries. However, in , we will only pay this cost on insertions. For now, we'll treat as a black box and defer its construction to Section 6.3.
When an item is inserted, we insert into , into , and into . When a subsequent insertion overwrites cells of , we do nothing. We then lazily reinflate during queries as follows. A query for finds and in , and computes ID(). If the query finds codewords in while scanning from to , then it can decode and return FOUND together with . Otherwise, this means that more than codewords have been overwritten, so requires reinflation. The query finds in , then performs REINFLATE() in . Then it updates in .
Handling False Positives in . For a matching membership entry at position , the query only collects codewords from the primary table with owner identifier . If too few survive, it searches the backup table for the item with identifier . In either case, it compares the recovered key with before returning the item or reinflating it; a mismatch rejects this entry. A backup search stops once it has read the complete candidate item, allowing at most two laps of the table so that a chunk crossing the starting point can be read in full. For the true candidate, the search starts at its canonical cell and has the usual positive-query scan bound. A false candidate may require a full-table scan, but this occurs only on a fingerprint collision. This happens rarely enough that it does not affect the expected scan bounds (as in the proof of Lemma 6.1, we can even afford to scan the entire table in the event of a fingerprint collision, which happens with probability ).
6.2 Amortizing Reinflations Against Insertions
When a query for triggers a reinflation, the query must retrieve from the backup table incurring a scan cost of , then execute REINFLATE() in . At first glance, this appears to make queries as expensive as backup-table queries.
The key observation is that we can amortize the cost of these reinflations against the insertions. Then in this amortized sense, a query for still incurs a scan cost of while 's initial insertion pays for the backup-table queries and reinflations. The reason this works is that once has been reinflated, subsequent queries for will be answered from the main table rather than requiring the expensive reinflation. Only when sufficiently many higher priority items again over-overwritten 's codewords in will a query for need to reinflate again.
Lemma 6.2 (Backup-Table Reduction). Let be a positive constant, and suppose that load, where the load factor is measured relative to the cells of . Let be a dynamic hash table with cells that supports insertions and positive queries (queries for keys in ). For , let be the random variable of the maximum scan cost of any insertion or query of in over the entire operation sequence. Suppose and for all .
Let . Then
-
If , in has amortized expected scan cost ;
-
If , in has expected scan cost ; and
-
INSERT has amortized expected scan cost .
Proof. The negative-query bound is Lemma 6.1. Since load, Lemma 5.3 and the bound from Section 5 apply to . Therefore, the scan cost of a positive query that doesn't trigger a reinflation is .
Let be the number of reinflations and be the query cost of in after the last reinflation. The total amortized cost of reinflation is at most . Taking expectations and applying Cauchy-Schwarz, we have
satisfies the hypotheses of Lemma 5.4, so and . Therefore also using the hypothesis on , the RHS of Equation (6.1) is . We charge this cost to the insertion of , which itself has expected scan cost in , in , and in .
6.3 Constructing the Density-Regulated Backup Table
With Lemma 6.2 in place, the only remaining piece of Theorem 1.2 is the backup table itself. The goal of this subsection is to construct a backup table , which we call the density-regulated backup table, that satisfies the hypotheses of Lemma 6.2 with . That is, needs to support only insertions and positive queries, and for each item of length , the insertion of and every query for should incur scan cost roughly , in the sense that the maximum of these scan costs satisfies . (Throughout this subsection, denotes .)
What makes this task easier than the one we faced in the primary table is that is allowed to lose a factor on both insertions and queries. This, it turns out, allows for a completely different (and somewhat simpler) construction than those in previous sections, one in which items never overwrite or move one another.
The Basic Idea. The basic idea is to separate items by size, and to divide among the resulting size classes in proportion to their volumes. We partition the items into size classes , and we give each class a few strided regions of , which we call subarrays: a subarray of density consists of every -th cell of . When a class receives its first item, it is given a subarray of density roughly , and whenever the class fills half of its newest subarray, it is given a new subarray of twice the density. Since converges, the first subarrays of all of the classes together take up only a small constant fraction of . Since additional subarrays are allocated on a per-demand basis (only when a size class has already received a large volume of elements), we will be able to ensure that the total density of all subarrays ever allocated is less than 1. This will be the critical point that makes the algorithm possible.
Within each subarray, a class stores its items using standard unit-size linear probing. Since the items of have the same length up to a factor of 2, we can divide the subarray into fixed-size chunks of consecutive subarray cells, each of which holds at most one item. Note that, even though the item is stored contiguously within the subarray, it is not stored physically contiguously: a chunk in a subarray of density is physically spread across cells, which inflates the scan cost by a factor of . This is the main thing we need to be careful about when bounding scan cost.
For the first subarray of class , the stride (i.e., the physical distance between consecutive cells of the subarray) is roughly , and the later subarrays of the class are only denser, so this ends up being the source of the factor when analyzing the scan costs of both insertions and queries.
In the rest of the subsection, we fill in the details for the data structure described above.
Allocating Subarrays. We begin by defining the strided subarrays in which classes store their items, and by defining the simple allocator that we use to hand these strided subarrays out to different classes.
Let denote the number of cells of ; with the interleaving above, . Throughout this subsection, we assume that , that is, .
For and , we define subarray to consist of the cells of , in this order. Its density is . The subarrays form a complete binary tree: the two children and of partition it, so two subarrays are either disjoint or nested.
We allocate subarrays with the following simple allocator (essentially a buddy allocator [34, 36]). To allocate a subarray of density , let be the largest depth at which some free subarray exists, and let Q be any free subarray at depth j. We allocate one of the depth-k subarrays contained in Q, and the rest of Q, which consists of one subarray at each depth , remains free. The next lemma shows that this allocator succeeds so long as the total allocated density stays at most 1.
Lemma 6.3. An allocation of density succeeds whenever the total density of all allocated subarrays, including the new one, is at most 1.
Proof. The key invariant is that, at any moment, there is at most one free subarray at each depth. To see that allocations preserve this, consider an allocation of density that splits a free subarray at depth j. The allocation creates one new free subarray at each depth , and there were no free subarrays at these depths beforehand, since otherwise the allocator would have chosen a larger j.
Now suppose that an allocation of density fails, meaning that no free subarray has depth at most k. By the invariant, there is at most one free subarray at each depth , so the free subarrays have total density less than . Since the free subarrays cover all of the unallocated cells, the allocated density is more than , so the allocated density plus exceeds 1.
Levels and Chunks. We now describe how each class stores its items. The class is stored in a sequence of subarrays, which we call , whose densities double from each level to the next. Within each level, the class is simply a unit-size linear-probing table whose entries are chunks of cells of . Within a given size class , new items are only ever inserted into the newest level, which is never more than half full. (The doubling of densities is not needed to bound scan costs; it just keeps the number of levels of each class at .)
Fix a constant such that , and let be the largest power of two that is at most . Level of class is a subarray of density , where (the second term just ensures that every level has at least two chunks). It is divided into chunks of consecutive cells, and an item stored in a chunk occupies a prefix of it. This prefix starts with a two-word header containing the item's identifier and length. The header and item fit in the chunk, since for . Queries can therefore recognize items by identifier as well as by key, without changing their placement or scan bounds.
Let be the cell of that hashes to, namely the cell of in , which is uniformly random and independent across items. In each level, the home chunk of is the first chunk (cyclically) whose first cell is at or after . Since the first cells of the chunks are evenly spaced, home chunks are uniformly random and independent across items, and 's home chunk in level begins fewer than cells after .
With these definitions in place, the operations are implemented as follows.
-
Insert, for : if has no levels, or its newest level already holds items, allocate a new level. Then write into the first empty chunk of the newest level at or after 's home chunk.
-
Query, for : scan forward from , parsing the items in the chunks that the scan passes through, until finding .
The bookkeeping for the allocator and the levels takes words of working space, as used in the I/O analysis below.
Analysis. It remains to show that the allocator never runs out of space, and to bound the scan costs of insertions and queries. We begin with space. The key observation is that, beyond level 0, the levels of a class are paid for by the volume of the class: a class only receives level once level is half full, at which point the volume of the class is proportional to the volume of the level being allocated.
Lemma 6.4 (Density Never Exceeds 7/8). At all times, the total density of the allocated subarrays is at most 7/8. Hence, by Lemma 6.3, every allocation succeeds.
Proof. We bound the density used by the classes in two groups, depending on whether or not a class has advanced beyond level 0.
First consider the classes whose newest level is level 0. Such a class uses density . Since every item has , every class satisfies . Summing over all such classes, the total density is therefore at most
Next consider a class whose newest level is . At the moment when level was allocated, level held items, each of length at least . Thus the class has volume
On the other hand, since the densities of the levels double from each level to the next, the total density of the levels of is , which by the above is at most . Summing over all such classes, the total density is at most .
Adding together the two groups, the total density is at most .
Finally, we bound the scan costs. A key observation is that querying costs no more than inserting did: never moves, and a query for scans forward from only until it reaches , which is exactly where the insertion of stopped. So it suffices to bound insertions. An insertion scans its level, which is a unit-size linear-probing table with load factor at most , from 's home chunk to the first empty chunk. This is chunks in expectation, each spanning at most cells of , for a total of .
Lemma 6.5 (Performance of the Density-Regulated Backup Table). Let have length . There is a random variable with such that the insertion of , and every query for over the entire operation sequence, scans a contiguous interval of starting at of length at most . In particular, satisfies the hypotheses of Lemma 6.2 with and .
Proof. Let be the level into which is inserted, and let be the number of chunks from 's home chunk through the first empty chunk of level at the time of the insertion; is written into that empty chunk. The home chunk begins fewer than cells after , and each chunk spans at most cells of , so the insertion of scans at most
cells starting at . Since is never moved, and a query for stops once it has read , every query for also scans at most cells.
It remains to show that . View level as a unit-size linear-probing table whose cells are its chunks, in which each item hashes to its home chunk. Which items are placed in level (including whether is) depends only on the operation sequence, and not on the hashes, since the level that receives an insertion is determined by the number of earlier insertions into . The level holds fewer than items before is inserted, so its load factor is at most . If is the length of the run of occupied chunks containing 's home chunk at the time of the insertion (with if that chunk is empty), then . Applying Lemma 4.2 with all items having length 1 gives . (The proof of that lemma uses only two properties, both of which hold here: that every word of a run belongs to an item whose canonical cell lies in the run, and that the items other than have independent hashes.) Hence , and so .
Finally, and , so . This establishes the bound on , and by Jensen's inequality, as well. Thus the hypotheses of Lemma 6.2 hold.
Finally, plugging Lemma 6.5 into Lemma 6.2 proves Theorem 1.2, which we restate here for convenience:
Theorem 1.2 (Dynamic Catalan Hashing at Low Load Factor). Fix any constant . There is an insertion-only dynamic Catalan hash table that supports some constant load factor , and that answers positive queries for any item x with amortized expected scan cost , answers negative queries with expected scan cost , and supports insertions of any item x with amortized expected scan cost .
Proof. Choose so that load, and apply Lemma 6.2 with and instantiated as the density-regulated backup table on cells. Then , so by Lemma 6.5, the hypotheses of Lemma 6.2 hold with , which gives the claimed bounds. The three interleaved tables use cells in total, so the load factor is a positive constant.
Corollary 6.6 (Dynamic Low-Load Catalan Hashing in External Memory). Suppose for a sufficiently large constant . The hash table of Theorem 1.2 is cache-oblivious and answers positive queries for any item in amortized expected I/Os, answers negative queries in expected I/Os, and supports insertions of any item in amortized expected
I/Os.
Proof. We use the working-set assumption of Section 2, together with the stated cache-size bound. The additional working space is words: we collect the codeword symbols read during a scan to encode or decode the item there, and retain the allocator's words of global bookkeeping. Thus encoding and decoding incur no I/Os beyond those of the scan. Each operation makes forward passes over its scan interval, so the scan property converts the scan bounds of Theorem 1.2 into the stated I/O bounds, with the same amortization. The algorithms do not use or .
7 Fair Catalan Hashing (Static, High Load)
Up to this point, we have focused on the low-load-factor regime, where the load factor is . We now turn to the high-load-factor regime, where the table is filled to load factor
for a small parameter , and prove Theorem 1.3.
In classical unit-size linear probing, standard (unordered) placement suffers from primary clustering (where runs of items merge together), resulting in an expected query cost of [37]. By contrast, ordered linear probing [3] (more popularly known as Robin Hood hashing [19]), which gives priority to items with smaller hash values, reduces the worst-case expected query cost for any item to .
When items have variable lengths, however, simple Catalan hashing gets stuck at . To see this, consider an -cell table containing items of length 1 and a single item of length 2. Because simple Catalan hashing prioritizes shorter items over longer ones, every unit-length item has higher priority than . Consequently, when is placed, it must skip over all unit-length items in its run and place its words into the first two empty cells left behind by the unit-length items. By the standard analysis of unit-length linear probing at load factor [37], the expected distance from a random cell to the first empty cell is , so querying requires scanning cells in expectation.
At the same time, we cannot simply switch to Robin Hood priority (giving priority to items with smaller hash values), because in the variable-length setting, a single long item of length would have higher priority than all items hashing after , forcing short items of length 1 to scan past all words of . Thus, neither prioritizing by length (simple Catalan hashing) nor prioritizing by hash value (Robin Hood hashing) can achieve a linear dependence on the inverse slack.
7.1 Hash-Table Queues: Variable-Length Linear Probing as Preemptive Queuing
The reason that simple Catalan hashing and Robin Hood hashing don’t achieve the query bounds we would like in the high-load case is that they are unfair: some jobs unfairly take priority over others. Robin Hood hashing gives too much priority to large jobs, so small jobs have high expected query cost. On the other hand, simple Catalan hashing gives too much priority to small jobs, so large jobs have high expected query cost. This is analogous to fairness problems in queuing theory, where a long job can block short jobs, while strict priority for short jobs can penalize long ones. We show that there is a surprisingly direct connection from variable-length linear probing to fair queuing and develop fair Catalan hash tables based on fair queuing policies.
We can reinterpret variable-length linear probing as a preemptive single-server scheduling problem, where we view the hash table as a continuous time axis. We define the following:
Jobs: Each job is an item .
Arrival times: A job x's arrival time is .
Service requirements: A job x's service requirement (or size) is .
Schedule: A job x's schedule is its placement in the table. The words of x correspond to units of time x is serviced (with preemption allowed).
Departure times: A job x's departure time is the position of its last cell.
Sojourn times: A job x's sojourn time (or response time) is the query scan cost . Its stretch (or slowdown) is .
We call the resulting queuing model the hash-table queue. In this model, the set of jobs and their sizes are fixed, and the arrival times are independent and uniform on a circle of circumference . Service in a hash-table queue is interpreted cyclically: since the total service requirement is , the schedule has idle time at which we can unwrap the circle.
For comparison, the classical queue has a Poisson stream of arrivals and independent, identically distributed service requirements, independent of the arrival process [32, 28]. The notation refers to memoryless (exponentially distributed) interarrival times , a general distribution of service requirements , and a single server (1). The server supplies one unit of service per unit of time, and a scheduling policy specifies how that service is allocated among the jobs present. The load is the arrival rate times the mean service requirement; the stable regime is analogous to for hash-table queues.
Interpreting linear probing as a hash-table queue, different linear-probing priority rules correspond directly to different scheduling policies:
• Ordered linear probing (Robin Hood) is First-Come-First-Served (FCFS): Jobs are served in order of arrival time , without preemption. FCFS is unfair to small jobs that arrive behind a large job.
- Simple Catalan hashing is Preemptive Static-Size Priority: Jobs with smaller original size have strict preemptive priority over jobs with larger original size. This is unfair to large jobs, which get starved until the very end of the busy period (run), incurring stretch.
What we want is a scheduling policy that is fair across all job sizes—guaranteeing expected stretch for every item , regardless of —while still producing a table that satisfies the Catalan nesting property (Definition 3.1).
For this we look to fair queues. We first consider a policy that gives the desired bound for each item's expected stretch, and then a policy based on processor sharing that also bounds the expected maximum stretch over the table.
7.2 Anti-Robin-Hood Catalan Hashing (ARCH)
In queuing theory, the simplest policy whose expected slowdown is independent of job size is Last-In-First-Out with Preemption (LIFO-PR), where newly arriving jobs immediately preempt whatever job is currently in service. In our hash-table setting, LIFO-PR corresponds to what we call anti-Robin-Hood Catalan hashing (ARCH), so named because its priority order is the exact opposite of that of Robin Hood hashing. Formally, the ARCH hash table is the static Catalan hash table of Definition 3.4 in which an item has priority over an item if , where hashes are compared cyclically.
We remark that, in the context of Catalan hashing, it may seem counterintuitive that the anti-Robin-Hood order is in some sense “fairer” than the Robin Hood order. After all, Robin Hood hashing is named for “giving back to the poor”: it prioritizes items that are already farther from their hashes. One might expect ARCH to give a small item very large expected stretch, since a very large item with can preempt and blow up its stretch. However, the smaller is, the less likely it is that any other item hashes into the region where it would preempt . As we will see in the proof of Theorem 1.3, this is why ARCH achieves worst-case expected stretch .
Analysis. We now give a simple, self-contained proof that the ARCH table achieves worst-case expected stretch . The result mirrors the standard results in queuing theory for LIFO-PR schedules on M/G/1 queues [32, 56]. We remark, however, that the proof itself is necessarily different, because the standard approaches rely heavily on the Poisson arrivals of the M/G/1 model in order to perform an optional-stopping-time argument; to get the same result in the hash-table setting, we use an alternative approach in which we reason about 's query cost by considering the impact for each item of deleting and reinserting into the table.
Theorem 1.3 (Anti-Robin-Hood Catalan Hashing). Let , and let be a static set of items stored in an -cell table with load factor load() . Anti-Robin-Hood Catalan hashing (ARCH) uses bits of metadata per cell, answers positive queries for any item with expected scan cost at most , and answers negative queries with expected scan cost at most .
Proof. Fix . For containing , let denote the scan cost of in the ARCH table on , let be the last cell of in that table, and let . We say that an item preempts in if . Then equals plus the total length of the other items that preempt in .
We prove the positive-query bound by induction on . If , then . In general, for , consider removing and then reinserting it. Then preempts in exactly when . The interval has length at most and depends only on the hashes of . Independence of hashes therefore gives
Each set has load at most , so by the induction hypothesis, .
Therefore,
For negative queries, since for every , Lemma 3.2 with bounds the expected scan cost by .
Corollary 7.1 (Anti-Robin-Hood Catalan Hashing in External Memory). Under the working-set assumption (see Section 2), the hash table of Theorem 1.3 is cache-oblivious and answers positive queries for any item in expected I/Os and negative queries in expected I/Os.
The ARCH hash table is already good enough for the guarantees required by the dynamic version in Section 8. In particular, we bound the expected query cost of any item in terms of its size, or equivalently, the maximum expected query stretch, where the maximum is taken over all items. Theorem 1.3 shows that the maximum expected query stretch in an ARCH table is at most .
In the static case, we can also consider the expected maximum stretch. It turns out that this quantity can be quite large in ARCH tables. If the table contains items of length 2 and one large item of size , then with constant probability, is the cell holding the second word of some length-2 item (a constant fraction of all cells are such cells), so preempts after its first word and has query stretch at least .
To bound both per-item expected query cost and expected maximum stretch across the entire table, we turn to a different fair queuing protocol, the fair-sojourn protocol, based on processor sharing.
7.3 Fair-Sojourn Catalan Hashing (FSCH)
Processor Sharing (PS) [33] is a service schedule which can be thought of as an idealized version of round-robin scheduling. In processor sharing, if j jobs are present in the system, they all share the server equally, each receiving service at instantaneous rate 1/j. Processor sharing is the canonical fair scheduling policy in queuing theory, avoiding both the starvation of large jobs (as in simple Catalan hashing) and the preemption of small jobs by newly arriving large jobs (as in ARCH) [56].
Processor sharing cannot be used directly in practice, because jobs cannot truly share a server. Similarly, we cannot write fractions of words from multiple different items in a single hash-table cell. In practice, processor sharing is approximated in a number of different ways, the simplest of which is round-robin scheduling, which converges to PS as the size of the time quantum tends to 0 [33]. However, in our case, if we alternated words round-robin among active items, the resulting interleaved words would violate the Catalan nesting property (Definition 3.1) and could not be processed using our parser.
We will instead use the Fair-Sojourn Protocol (FSP) [26], which is a schedule that realizes the benefits of PS while running a single job on the server at each point in time. FSP runs a virtual simulation of PS and assigns the processor to the remaining job that would finish first in this simulation. We use the following discrete-time version, which we show approximates FSP, which in turn dominates PS.
The virtual PS schedule. Let be a set of items with arrivals and service requirements , such that . We run a continuous processor sharing schedule: every item arrives at and departs at a well-defined PS departure time , satisfying
where the integral is interpreted cyclically and denotes the number of jobs of alive in the virtual PS schedule at time . Equation (7.1) expresses that between and , receives service at rate at time , which is the defining property of PS. Given and its hashes, we can compute these departure times by sorting the arrivals and simulating the schedule from an idle point. Between consecutive arrivals and departures, is constant, so every active item's remaining service decreases linearly at rate .
FSCH Hash Tables. We define the FSCH priority by giving higher priority to items with earlier departure times in the virtual PS schedule, interpreted cyclically. We define the FSCH table to be , as in Definition 3.4.
The FSCH table defines a hash-table-queue schedule which resembles a discrete-time version of FSP. Continuous FSP uses the arrival times and may preempt a job at a nonintegral time. FSCH instead makes x available at and assigns each occupied cell entirely to one item, so preemptions occur only between words (i.e. at integral times). Both continuous FSP and FSCH priorities are computed from the virtual PS schedule with the original, unrounded arrivals. As shown in Lemma 7.2, this increases sojourn time by at most one unit.
7.4 FSCH Analysis
We first show that the FSCH sojourn time exceeds the continuous FSP sojourn time by at most one unit.
Lemma 7.2. In a hash-table queue for , let and be the departure times of an item under continuous FSP and FSCH, respectively, with cell representing service during . Then
where times are interpreted cyclically.
Proof. Fix , write , and let consist of and all higher-priority items arriving before . FSP has completed every item of by , since otherwise a higher-priority item would prevent from finishing.
Rounding the arrivals of down preserves this deadline. A schedule serving whenever any of its work is pending therefore also finishes by . Its arrivals and service requirements are integers, so it finishes by . In the full FSCH schedule, lower-priority items never delay , and every higher-priority item outside has rounded arrival at least . Thus , and hence
Next, a classical theorem of Friedman and Henderson [26] shows that FSP completes each item no later than PS.
Theorem 7.3 ([26]). For any fixed arrival times and service requirements, continuous FSP and processor sharing satisfy
where times are interpreted cyclically.
Using Lemma 7.2 and Theorem 7.3, any result on continuous PS for hash-table queues that bounds the sojourn time of an item x produces the same bound on the query scan cost of x in the FSCH table (up to rounding). We want to bound both the expected stretch of each item and the expected maximum stretch. Our results are analogues of similar results in the M/G/1 setting. There, each item's expected stretch is , where is the load; see e.g. Kleinrock [32] or Harchol-Balter [28, Section 30.1]. Cheung, van den Berg, and Boucherie [20] give bounds on all moments of the conditional sojourn time that are insensitive to the job-size distribution, yielding exponential tail bounds for stretch. These techniques do not immediately transfer to hash-table queues: an M/G/1 queue has Poisson arrivals and independently sampled service requirements, whereas hash-table queues have fixed finite sets of jobs with arbitrary sizes and independent uniform arrival times. In particular, the numbers of arrivals in disjoint intervals are dependent, so we cannot directly apply results that assume Poisson arrivals.
Our analysis instead establishes analogous arrival and deletion properties for hash-table queues. An arriving job sees the system with that job deleted at a uniformly random time, since its hash is independent of the other hashes. We show that PS departure times are also independent and uniform: reversing time gives a valid PS schedule, and the map from arrivals to departures preserves measure. Now consider the instant at which a job has received a fixed amount of service. Truncating to size makes this instant its departure time, allowing us to show that the number of other jobs present has the same distribution as the population of the system without at a uniformly random time. Integrating over gives the service-deletion identity (Lemma B.5).
This identity lets us bound the queue population recursively, by deleting one job at a time. By doing so, we obtain a geometric tail bound on the number of jobs present at a random time : (Lemma B.6). The service-deletion identity also expresses 's expected stretch as one plus the expected population of the system without , giving a bound of . Finally, every item's stretch is at most the maximum queue population, since a job receives service at rate whenever jobs are present. The population increases only at arrivals, so a union bound over the arrivals gives the logarithmic factor in the expected maximum stretch. We defer the full analysis to Appendix B, whose main result we state here.
Theorem 7.4. Let be a nonempty set of items with load. In the PS schedule for in the hash-table queue, each item has expected stretch at most , and the expected maximum stretch is at most .
We now combine Theorems 7.3 and 7.4 and Lemmas 3.2 and 7.2 to establish the bounds for FSCH:
Theorem 7.5 (Fair-Sojourn Catalan Hashing). Let , and let be a static set of items stored in an -cell table with load factor load. Fair-sojourn Catalan hashing (FSCH) uses bits of metadata per cell, answers positive queries for any item with expected scan cost at most , and answers negative queries with expected scan cost at most . Moreover, if denotes the scan cost for , the expected maximum stretch across the entire table satisfies
Proof. Each cell uses the bits of the Catalan representation. By Lemma 7.2 and Theorem 7.3, the positive query scan cost satisfies , where is 's PS sojourn time. Thus Theorem 7.4 gives , since . Applying Lemma 3.2 with gives expected scan cost at most for negative queries. Since , the expected maximum query stretch is at most
8 Graveyard Catalan Hashing (Dynamic, High Load)
In this section, we combine the two constructions developed in the preceding sections. The hash tables in Section 7 achieve load factor and expected query scan cost , but are static. The dynamic table of Section 6 supports efficient updates, but its erasure codes and backup copies require a constant factor of extra space. In the following, we will construct a fully dynamic Catalan hash table at high load factor , proving Theorem 1.4.
The basic idea is to keep almost all items in a static table, and reserve interleaved cells for a dynamic table that receives new insertions. After words of updates, we rebuild the static table on the current live set. The dynamic table's constant-factor space overhead then uses only cells, and a rebuild with scan cost has amortized cost only per word of updates.
Our construction takes inspiration from graveyard hashing [14], which achieves dynamic high-load operations in unit-size linear probing by maintaining tombstones from deletions (and inserting artificial tombstones during periodic rebuilds) so that new insertions quickly find tombstones without scanning to the end of a long cluster. In our variable-length external-memory setting, graveyard hashing would be subject to the same write amplification issue we described in Section 5. Moreover, both the ARCH and FSCH schemes in Section 7 use an inherently static scheduling-based approach.
Instead, we implement the graveyard hashing framework in a more heavy-handed structural manner: we explicitly decompose the hash table into interleaved tables that share the same physical array. Into a large static table, we sparsely interleave a small dynamic table that serves the same function as the tombstones in graveyard hashing: it efficiently accepts new insertions. Also as in graveyard hashing, periodically we rebuild to refresh the dynamic table.
In the next sections, we describe the construction and its operation bounds; we later show how to rebuild in a constant number of sequential passes (Appendix D).
8.1 A Static Table with a Small Dynamic Buffer
We divide the operation sequence into rebuild windows. At the start of a window, all live items are stored in a static table with cells. During the window, insertions go into a small dynamic table , and deletions from merely set a flag. Thus the static layout remains fixed until the next rebuild.
The Three Tables. Let , where is a sufficiently large constant, and set
Let be the smallest power of two at least , so that the auxiliary tables satisfy the size convention of Section 6.3. The construction consists of the following tables.
(1) The static table . This is an -cell ARCH table built on the live set at the start of the window. We keep fixed throughout the window, including items subsequently marked as deleted. (We fix the use of ARCH for ease of exposition. Since FSCH guarantees the same expected query scan bounds, all of the claimed bounds in this section would hold with a FSCH-based static table as well.) We add two additional metadata bits to each cell: a deletion bit, which marks the first cell of an item to indicate it's deleted, and a collision bit, defined below, which enables queries for deleted items to resolve fingerprint collisions. Deleted items' words remain in place. The static table's placement rule and remaining metadata are unchanged.
(2) The insertion table . This is the dynamic low-load structure
of Section 6, extended to support deletions by Lemma 8.1 below. Each of its three constituent tables has cells. It starts empty and stores the items inserted during the window that are still live. As in Section 6, we sometimes abuse notation and refer to a triple as a cell, for example, the canonical cell of an item .
(3) The deletion table . This is an ordinary insertion-only unordered linear-probing table with cells. It starts empty. Whenever an item of is deleted, we insert a 1-word descriptor into , starting at . consists of 's canonical cell together with a -bit fingerprint from an independent hash function. During rebuilding, we set the collision bit at a static cell exactly when two distinct keys in with canonical cell have the same fingerprint. These bits remain fixed throughout the window. Thus, when the collision bit at is clear, at most one key in has descriptor . We always insert one record per deleted static item, even in the above case where two descriptors are the same, allowing equal descriptors to occupy separate cells. Records stay in until the next rebuild, even if their keys are subsequently reinserted into .
At all times, each live item occurs either as an unflagged item of or as a live item of , and contains one descriptor for each flagged item of .
The deletion table is structured using descriptors with fingerprints to handle a complication that can arise with deletions. A negative query for a deleted key could still scan the entire old item, which may be much longer than the key itself. The static negative-query bound does not apply, because this key's hash is correlated with the contents of the static table. Storing the deleted key in a second table would reduce this cost only to one proportional to the key's length, but we reduce this further to in expectation by using constant-size descriptors. We check for collisions among resident keys during rebuilding, so that a fingerprint match can certify absence without reading the deleted key.
Interleaving and Space. As in Section 6.1, we interleave all constituent tables in a single physical array. When interleaving the cell (technically three cells) of , we follow it with cell from . We refer to this collection of cells as a single small cell . For , place small cell immediately after cell of . Thus consecutive small cells are separated by at most static cells and four component cells of the small cell.
Assume for now that . Since , we have and , so
Choosing ensures that a live volume of at most is at most . In particular, each rebuilt static table has slack at least . Consecutive cells of any component of the small table are at most physical cells apart.
All tables use the same hash, rescaled to their lengths. A key has canonical cell in the static table and
in the small table. lies within physical cells after . Consequently, scans in all three structures start near the same physical location, which preserves the I/O bounds.
The Update Budget. We keep two counters: the total volume inserted into , including items subsequently deleted, and the total length of keys deleted from . The latter also bounds the number of records inserted into . We ensure that neither counter ever exceeds . Before an operation would exceed either budget, we rebuild and then perform the operation in the new window. An insertion of length at least , or a deletion from whose key has length at least , is instead incorporated directly into a rebuild. We call these long updates. This rule keeps the insertion table at the low load required by Section 6, and keeps at load at most . It also ensures that a budget-triggered rebuild follows at least words charged to one of the counters.
If , we use just the static table and rebuild after every update. Then , so a rebuild has scan cost ; under the cache-size assumption in Section 8.3, the whole table fits in cache. The bounds below therefore also cover this case.
8.2 Operations Within a Rebuild Window
We use the low-load dynamic table from Theorem 1.2 as a black box, except we extend it to support deletions.
Lemma 8.1 (Low-Load Deletions). The structure of Section 6, with cells in each constituent table and initially empty, supports any operation sequence whose insertions have total volume at most . Its scan costs are:
(1) in amortized expectation for a positive query for an item ;
(2) in expectation for a negative query; and
(3) in amortized expectation for an insertion or deletion of an item .
Each operation on a key makes forward passes over a contiguous physical interval starting at . Under the cache assumptions of Section 6, the corresponding I/O bounds are , where is the stated scan bound.
The proof is given in Appendix C. The main issue is repeated deletion and reinsertion of one key: its successive values share a hash, so they cannot be treated as independent items. The construction reuses a deleted copy when that key is reinserted into the same size class. We use the budget so that the density bound for the backup table continues to apply.
Lemma 8.2 (Interleaving Preserves Scan Bounds). An operation in or with logical scan bound has physical scan bound . Its accesses make forward passes over an interval beginning within cells after in . The same statement holds for expected and amortized expected bounds.
Proof. An interval of cells in any auxiliary constituent table spans at most physical cells. All constituent scans start at their canonical cells. For , the boundary lies in . Rounding this boundary changes its position by less than one static cell, and . Thus these starting points lie within physical cells after . The encoding, decoding, and allocator bookkeeping use the same scratch region as before, so interleaving changes only the lengths of the scans.
Deletion-Table Scans. A search in starts at and scans to a matching descriptor or the first empty cell. An insertion scans to the first empty cell and writes its record there. Each static item is deleted at most once per window. Moreover, the window boundaries and the sequence of deleted static keys are determined by the operation sequence, independently of the hashes. Thus the records have independent uniform home small cells, even if their descriptors coincide. Since the load is at most 1/64, ordinary unit-size linear probing gives expected logical scan cost for either operation, whether or not the query key has a record. By Lemma 8.2, the physical scan cost is in expectation.
Queries. A query for k reads the collision bit at and scans forward from that cell, running the following searches together:
• Search for a live item with key k.
• If the collision bit is clear, search for .
- Search with the Catalan parser, treating flagged items as absent. Abandon this search as soon as the deletion-table search finds .
Return the live item if one is found, and otherwise return NOT FOUND once the insertion-table search and either the static-table search or the deletion-table search establish absence. The searches advance together through the interleaved array; any backup lookup or reinflation uses the forward passes of the low-load construction.
To see why a deletion-table match certifies absence from the live static set, let be the deleted item that supplied the matching descriptor. If were also the key of a live static item , then . Since the collision bit at is clear, , a contradiction. A collision with a key outside is harmless: that key is absent from the static table anyway. The query must still search the insertion table, since a deleted static key may have been reinserted there.
Lemma 8.3 (Query Bounds Within a Window). A positive query for an item has amortized expected scan cost . Every negative query has expected scan cost , independently of the key length. Each query makes forward passes over a contiguous physical interval starting at .
Proof. If the live item is in the insertion table, its search finishes with amortized expected scan cost by Lemmas 8.1 and 8.2; the concurrent searches stop no later. If is an unflagged static item, the static search has expected scan cost , while the insertion-table search is negative and costs in expectation.
Now consider a negative query for . The insertion-table search has expected scan cost . If is not a key of , its hash is independent of the static contents, so the static search has expected scan cost by Theorem 1.3; an early stop from can only shorten it.
Otherwise, belongs to a flagged static item. Let be the event that two distinct keys of have equal fingerprints. Since ,
Outside , the collision bit at is clear and the query stops the static search upon finding in . Let be the physical distance from through this record, with by the deletion-table scan bound. The static and deletion-table searches together cost at most
Taking expectations gives , without conditioning the deletion-table bound on the collision bits. This estimate applies separately to every query, including repeated queries for the same deleted key; no query cost is charged to its deletion.
Insertions. To insert an item whose key is absent, first apply the budget rule. A long insertion is incorporated directly into a rebuild; otherwise, rebuild first if necessary, and then insert into . Its key may already have a dead copy there; Lemma 8.1 handles this case. Apart from rebuilding, Lemmas 8.1 and 8.2 give amortized expected scan cost .
Deletions. To delete a present key , first locate its item with a query. If is in , delete it using Lemma 8.1. Otherwise, check the budget rule before changing the table. A long deletion is incorporated directly into a rebuild. If the deletion is short but the key budget would be exceeded, rebuild first and locate in the rebuilt static table. Then set the deleted flag at its opening cell and insert into . The static table's delimiters, home bits, stop marks, and collision bits remain unchanged, so its parser continues to operate on exactly the layout built at the start of the window. The auxiliary update has expected scan cost , which is within the claimed update bound.
Thus both insertions and deletions have the desired update bound within a window. It remains to pay for rebuilding; we defer the analysis of the amortized expected cost of rebuilds to Appendix D.
8.3 Putting the Bounds Together
Cache Size for I/O Bounds. Our I/O bounds use the working-set assumption of Section 2, together with for a sufficiently large constant . This accommodates the encoding, decoding, and bookkeeping space of Section 6, as well as words of workspace for rebuilding one run at a time in cache (Appendix D). We remark that our assumption on is quite mild in the sense that it only requires memory to be slightly larger than what is required to fit the largest string.
The following proposition collects the guarantees established by the construction, proving Theorem 1.4 and Corollary 1.5.
Proposition 8.4 (Dynamic High-Load Bounds). For and fixed , the construction operates at load factor and has the following amortized expected scan costs:
(1) for a positive query for an item ;
(2) for a negative query, independently of the key length; and
(3) for an insertion or deletion of an item .
Under the cache-size assumption above, the construction is cache-oblivious and the corresponding amortized expected I/O bounds are
Proof. The space calculation in Section 8.1 leaves slack at least in the static table. The update budgets keep the insertion table within the hypotheses of Lemma 8.1 and keep the deletion table at load at most 1/64. Thus Lemma 8.3 and the update analysis give all within-window scan bounds.
Each budget-triggered rebuild follows words of insertions or deleted keys. Charge its expected scan cost to those words. A long update has length and pays for its own rebuild. Since a deleted key is no longer than its item, rebuilding adds only to each update's amortized expected scan cost.
For I/Os, all within-window accesses make forward passes over a contiguous interval starting at . The cache-size assumption above converts a scan bound to expected I/Os, with a single leading 1 shared by the interleaved searches. By Lemma D.4, rebuilding adds amortized expected I/Os per update. None of the algorithms uses or .
Acknowledgments
This work is partially supported by NSF grants 2504470, 2504471, 2551615, and 2542165, as well as by a CMU / Jane Street collaboration grant.
AI Disclosure
All of the main technical ideas in this paper were generated by the authors over the duration of around a year; during that time, the authors used AI tools (all models of GPT, Claude, and Gemini during that time span) to aid in literature review and to explore different ways of structuring the proofs. AI tools were also used in the writing process to help write the starting draft for the paper, which was then almost entirely rewritten by the authors. Finally, AI tools were used to polish text throughout, and to perform edits to the paper.
We reviewed and revised the AI-assisted material and take full responsibility for the content, correctness, and originality of the paper.
References
[1] Alok Aggarwal and Jeffrey Scott Vitter. "The Input/Output Complexity of Sorting and Related Problems". In: Communications of the ACM 31.9 (1988), pp. 1116–1127. DOI: 10.1145/48529.48535.
[2] Noga Alon and Michael Luby. "A linear time erasure-resilient code with nearly optimal recovery". In: IEEE Transactions on Information Theory 42.6 (1996), pp. 1732–1736. DOI: 10.1109/18.556669.
[3] O. Amble and Donald E. Knuth. "Ordered Hash Tables". In: The Computer Journal 17.2 (1974), pp. 135–142. DOI: 10.1093/comjnl/17.2.135.
[4] Lars Arge. "The Buffer Tree: A Technique for Designing Batched External Data Structures". In: Algorithmica 37.1 (2003), pp. 1–24. DOI: 10.1007/s00453-003-1021-x.
[5] Nikhil Bansal and Mor Harchol-Balter. "Analysis of SRPT Scheduling: Investigating Unfairness". In: Proceedings of the 2001 ACM SIGMETRICS International Conference on Measurement and Modeling of Computer Systems. 2001, pp. 279–290. DOI: 10.1145/378420.378792.
[6] Michael A. Bender, Soumen Chakrabarti, and S. Muthukrishnan. "Flow and Stretch Metrics for Scheduling Continuous Job Streams". In: Proceedings of the 9th Annual ACM-SIAM Symposium on Discrete Algorithms. 1998, pp. 270–279.
[7] Michael A. Bender, Alex Conway, Martín Farach-Colton, William Kuszmaul, and Guido Tagliavini. "Iceberg Hashing: Optimizing Many Hash-Table Criteria at Once". In: Journal of the ACM 70.6 (2023), 40:1–40:51. DOI: 10.1145/3625817.
[8] Michael A. Bender, Erik D. Demaine, and Martin Farach-Colton. "Cache-Oblivious B-Trees". In: SIAM Journal on Computing 35.2 (2005), pp. 341–358. DOI: 10.1137/S0097539701389956.
[9] Michael A. Bender, Martin Farach-Colton, Jeremy T. Fineman, Yonatan R. Fogel, Bradley C. Kuszmaul, and Jelani Nelson. "Cache-Oblivious Streaming B-Trees". In: Proceedings of the 19th Annual ACM Symposium on Parallelism in Algorithms and Architectures. 2007, pp. 81–92. DOI: 10.1145/1248377.1248393.
[10] Michael A. Bender, Martin Farach-Colton, William Jannen, Rob Johnson, Bradley C. Kuszmaul, Donald E. Porter, Jun Yuan, and Yang Zhan. "An Introduction to B-trees and Write-Optimization". In: ;login: The USENIX Magazine 40.5 (2015), pp. 22–28. URL: https://www.usenix.org/system/files/login/articles/login_oct15_05_bender.pdf.
[11] Michael A. Bender, Martin Farach-Colton, and Bradley C. Kuszmaul. "Cache-Oblivious String B-Trees". In: Proceedings of the 25th ACM SIGMOD-SIGACT-SIGART Symposium on Principles of Database Systems. 2006, pp. 233–242. DOI: 10.1145/1142351.1142385.
[12] Michael A. Bender, Martín Farach-Colton, John Kuszmaul, William Kuszmaul, and Mingmou Liu. "On the Optimal Time/Space Tradeoff for Hash Tables". In: Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing. 2022, pp. 1284–1297. DOI: 10.1145/3519935.3519969.
[13] Michael A. Bender and Haodong Hu. "An Adaptive Packed-Memory Array". In: ACM Transactions on Database Systems 32.4, 26 (2007). DOI: 10.1145/1292609.1292616.
[14] Michael A. Bender, Bradley C. Kuszmaul, and William Kuszmaul. "Linear Probing Revisited: Tombstones Mark the Demise of Primary Clustering". In: Proceedings of the 2021 IEEE 62nd Annual Symposium on Foundations of Computer Science. 2022, pp. 1171–1182. DOI: 10.1109/FOCS52979.2021.00115.
[15] Ioana O. Bercea, Lorenzo Beretta, Jonas Klausen, Jakob Bæk Tejs Houen, and Mikkel Thorup. "Locally Uniform Hashing". In: Proceedings of the 64th IEEE Annual Symposium on Foundations of Computer Science. 2023, pp. 1440–1470. DOI: 10.1109/FOCS57990.2023.00089.
[16] Mark Braverman and William Kuszmaul. "Tight Analyses of Ordered and Unordered Linear Probing". In: Proceedings of the 65th IEEE Annual Symposium on Foundations of Computer Science. 2024, pp. 606–635. DOI: 10.1109/FOCS61266.2024.00046. arXiv: 2501.11582 [cs.DS].
[17] Gerth Stølting Brodal and Rolf Fagerberg. "Cache-Oblivious String Dictionaries". In: Proceedings of the 17th Annual ACM-SIAM Symposium on Discrete Algorithms. 2006, pp. 581–590. DOI: 10.1145/1109557.1109621.
[18] Gerth Stølting Brodal and Rolf Fagerberg. "Lower Bounds for External Memory Dictionaries". In: Proceedings of the 14th Annual ACM-SIAM Symposium on Discrete Algorithms. 2003, pp. 546–554.
[19] Pedro Celis, Per-Åke Larson, and J. Ian Munro. "Robin Hood Hashing (Preliminary Report)". In: Proceedings of the 26th Annual Symposium on Foundations of Computer Science. 1985, pp. 281–288. DOI: 10.1109/SFCS.1985.48.
[20] Sing-Kong Cheung, Hans van den Berg, and Richard J. Boucherie. "Insensitive Bounds for the Moments of the Sojourn Time Distribution in the M/G/1 Processor-Sharing Queue". In: Queueing Systems 53.1–2 (2006), pp. 7–18. DOI: 10.1007/s11134-006-7583-y.
[21] Alex Conway, Martín Farach-Colton, and Philip Shilane. "Optimal Hashing in External Memory". In: 45th International Colloquium on Automata, Languages, and Programming. Vol. 107. Leibniz International Proceedings in Informatics. 2018, 39:1–39:14. DOI: 10.4230/LIPIcs.ICALP.2018.39.
[22] Martin Dietzfelbinger and Michael Rink. "Applications of a Splitting Trick". In: Proceedings of the 36th International Colloquium on Automata, Languages and Programming. Vol. 5555. Lecture Notes in Computer Science. 2009, pp. 354–365. DOI: 10.1007/978-3-642-02927-1_30.
[23] Ronald Fagin, Jürg Nievergelt, Nicholas Pippenger, and H. Raymond Strong. "Extendible Hashing—A Fast Access Method for Dynamic Files". In: ACM Transactions on Database Systems 4.3 (1979), pp. 315–344. DOI: 10.1145/320083.320092.
[24] Martín Farach-Colton, Andrew Krapivin, and William Kuszmaul. "Optimal Bounds for Open Addressing Without Reordering". In: Proceedings of the 65th IEEE Annual Symposium on Foundations of Computer Science. 2024, pp. 594–605. DOI: 10.1109/F0CS61266.2024.00045. arXiv: 2501.02305 [cs.DS].
[25] Paolo Ferragina and Roberto Grossi. "The String B-Tree: A New Data Structure for String Search in External Memory and Its Applications". In: Journal of the ACM 46.2 (1999), pp. 236–280. DOI: 10.1145/301970.301973.
[26] Eric J. Friedman and Shane G. Henderson. "Fairness and Efficiency in Web Server Protocols". In: Proceedings of the 2003 ACM SIGMETRICS International Conference on Measurement and Modeling of Computer Systems. 2003, pp. 229–237. DOI: 10.1145/781027.781056.
[27] Matteo Frigo, Charles E. Leiserson, Harald Prokop, and Sridhar Ramachandran. "Cache-Oblivious Algorithms". In: ACM Transactions on Algorithms 8.1 (2012), 4:1–4:22. DOI: 10.1145/2071379.2071383. URL: https://dblp.org/rec/journals/talg/FrigoLPR12.
[28] Mor Harchol-Balter. Performance Modeling and Design of Computer Systems: Queueing Theory in Action. Cambridge University Press, 2013. DOI: 10.1017/CB09781139226424.
[29] John Iacono and Mihai Pătrascu. "Using Hashing to Solve the Dictionary Problem (in External Memory)". In: Proceedings of the 23rd Annual ACM-SIAM Symposium on Discrete Algorithms. 2012, pp. 570–582. DOI: 10.1137/1.9781611973099.48.
[30] Morten Skaarup Jensen and Rasmus Pagh. "Optimality in External Memory Hashing". In: Algorithmica 52.3 (2008), pp. 403–411. DOI: 10.1007/s00453-007-9155-x.
[31] Frank P. Kelly. Reversibility and Stochastic Networks. John Wiley & Sons, 1979.
[32] Leonard Kleinrock. Queueing Systems, Volume 2: Computer Applications. Wiley-Interscience, 1976.
[33] Leonard Kleinrock. "Time-shared Systems: A Theoretical Treatment". In: Journal of the ACM 14.2 (1967), pp. 242–261. DOI: 10.1145/321386.321388. URL: https://dblp.org/rec/journals/jacm/Kleinrock67.
[34] Kenneth C. Knowlton. "A Fast Storage Allocator". In: Communications of the ACM 8.10 (1965), pp. 623–624. DOI: 10.1145/365628.365655.
[35] Donald E. Knuth. Notes on “Open” Addressing. Unpublished memorandum. July 1963. URL: https://jeffe.cs.illinois.edu/teaching/datastructures/2011/notes/knuth-0ALP.pdf.
[36] Donald E. Knuth. The Art of Computer Programming, Volume 1: Fundamental Algorithms. 3rd ed. Addison-Wesley, 1997.
[37] Donald E. Knuth. The Art of Computer Programming, Volume 3: Sorting and Searching. 2nd ed. Addison-Wesley, 1998.
[38] Alan G. Konheim and Benjamin Weiss. “An Occupancy Discipline and Applications”. In: SIAM Journal on Applied Mathematics 14.6 (1966), pp. 1266–1274. DOI: 10.1137/0114101.
[39] Andrew Krapivin, William Kuszmaul, and Yixuan Wang. Linear Probing with Non-Greedy Insertions. 2026. DOI: 10.48550/arXiv.2607.17494. arXiv: 2607.17494 [cs.DS].
[40] Per-Åke Larson. “Dynamic Hash Tables”. In: Communications of the ACM 31.4 (1988), pp. 446–457. DOI: 10.1145/42404.42410.
[41] Witold Litwin. “Linear Hashing: A New Tool for File and Table Addressing”. In: Proceedings of the Sixth International Conference on Very Large Data Bases. 1980, pp. 212–223.
[42] Patrick O’Neil, Edward Cheng, Dieter Gawlick, and Elizabeth O’Neil. “The Log-Structured Merge-Tree (LSM-Tree)”. In: Acta Informatica 33.4 (1996), pp. 351–385. DOI: 10.1007/s002360050048.
[43] Anna Pagh and Rasmus Pagh. “Uniform Hashing in Constant Time and Optimal Space”. In: SIAM Journal on Computing 38.1 (2008), pp. 85–96. DOI: 10.1137/060658400.
[44] Anna Pagh, Rasmus Pagh, and Milan Ružić. “Linear Probing with Constant Independence”. In: SIAM Journal on Computing 39.3 (2009), pp. 1107–1120. DOI: 10.1137/070702278. URL: https://dblp.org/rec/journals/siamcomp/PaghPR09.
[45] Rasmus Pagh, Zhewei Wei, Ke Yi, and Qin Zhang. “Cache-Oblivious Hashing”. In: Algorithmica 69.4 (2014), pp. 864–883. DOI: 10.1007/s00453-013-9763-6.
[46] Mihai Pătrașcu and Mikkel Thorup. “On the k-Independence Required by Linear Probing and Minwise Independence”. In: ACM Transactions on Algorithms 12.1 (2016), 8:1–8:27. DOI: 10.1145/2716317.
[47] Mihai Pătrașcu and Mikkel Thorup. “The Power of Simple Tabulation Hashing”. In: Journal of the ACM 59.3 (2012), 14:1–14:50. DOI: 10.1145/2220357.2220361.
[48] W. W. Peterson. “Addressing for Random-Access Storage”. In: IBM Journal of Research and Development 1.2 (1957), pp. 130–146. DOI: 10.1147/rd.12.0130.
[49] Irving S. Reed and Gustave Solomon. “Polynomial Codes over Certain Finite Fields”. In: Journal of the Society for Industrial and Applied Mathematics 8.2 (1960), pp. 300–304. DOI: 10.1137/0108018.
[50] Stefan Richter, Victor Alvarez, and Jens Dittrich. “A Seven-Dimensional Analysis of Hashing Methods and its Implications on Query Processing”. In: Proceedings of the VLDB Endowment 9.3 (2015), pp. 96–107. DOI: 10.14778/2850583.2850585.
[51] Linus Schrage. “Letter to the Editor—A Proof of the Optimality of the Shortest Remaining Processing Time Discipline”. In: Operations Research 16.3 (1968), pp. 687–690. DOI: 10.1287/opre.16.3.687.
[52] Alan Siegel. "On Universal Classes of Extremely Random Constant-Time Hash Functions". In: SIAM Journal on Computing 33.3 (2004), pp. 505–543. DOI: 10.1137/S0097539701386216.
[53] Richard P. Stanley. Catalan Numbers. Cambridge University Press, 2015. DOI: 10.1017/CB09781139871495.
[54] Mikkel Thorup. "String Hashing for Linear Probing". In: Proceedings of the 20th Annual ACM-SIAM Symposium on Discrete Algorithms. 2009, pp. 655–664. DOI: 10.1137/1.9781611973068.72.
[55] Mikkel Thorup and Yin Zhang. "Tabulation-Based 5-Independent Hashing with Applications to Linear Probing and Second Moment Estimation". In: SIAM Journal on Computing 41.2 (2012), pp. 293–331. DOI: 10.1137/100800774.
[56] Adam Wierman and Mor Harchol-Balter. "Classifying Scheduling Policies with Respect to Unfairness in an M/GI/1". In: ACM SIGMETRICS Performance Evaluation Review 31.1 (2003), pp. 238–249. DOI: 10.1145/885651.781057.
[57] Or Zamir. Locality in Open Addressing Hash Tables. To appear in SODA 2027. 2026. DOI: 10.48550/arXiv.2607.16390. arXiv: 2607.16390 [cs.DS].
A The Static Catalan Parser
State. The parser maintains a stack of active item frames for items whose OPEN tag has been seen at or after cell , along with a single integer counter (initially 0) that counts observed words belonging to an "unmatched suffix" of an item whose OPEN tag occurred before cell . Each frame on buffers the key, maintaining a word counter (the number of words of that item seen so far) and a boolean match flag indicating whether the key words seen so far match the corresponding prefix of the queried key . When the buffer reaches the end of the key, it computes and retains its canonical cell before discarding the buffer. The match flag tests equality of the complete keys, including their lengths. If the key matches , the frame buffers the subsequent value in order to return it. These key and value buffers are part of the parser state assumed to reside in cache in Section 2.
Transitions on Reading a Cell .
(i) OPEN: Push a new frame onto with , and compare the cell's word with the first word of .
(ii) OPEN-CLOSE: This cell is a complete 1-word item; if its key is , return FOUND (we assume a 1-word item has no value). Otherwise, compute its canonical cell and apply the stop-cell rule of Section 3. The stack and counter are unchanged.
(iii) MIDDLE with non-empty: Increment of the top frame of , and, if the -th word of the item is part of its key, compare it with the -th word of .
(iv) CLOSE with non-empty: Increment of the top frame of , compare the cell's word with as in (iii), and pop the frame. If the completed item's key is , return FOUND, together with its buffered value. Otherwise, use its retained canonical cell and the stop bit of cell to apply the stop-cell rule of Section 3.
(v) MIDDLE with empty: Increment the unmatched-suffix counter .
(vi) CLOSE with empty: Increment (completing the unmatched suffix of some item that opened before ), and reset . No stop-cell test is needed for this item: when , an item that opened before cannot have canonical cell .
(vii) EMPTY: Terminate the scan and return NOT FOUND.
Lemma A.1 (Correctness of the Catalan Parser). Suppose a table satisfies the Catalan nesting property (Definition 3.1), and a scan starts at cell . Then the Catalan parser correctly assembles, in logical word order, every item whose entire interval lies at or after . Furthermore, at every step of the scan:
(1) Each frame on the stack tracks a single item that opened at or after , and its counter cnt equals the number of words of seen so far (so cnt ).
(2) Whenever , the unmatched-suffix counter counts words belonging to a single item that opened before (namely, the innermost such item that has not yet closed), and never combines words from two different items (so ).
Proof. By Definition 3.1, whenever an item is nested inside another item (), lies strictly between two consecutive cells of . If opened at or after , then 's frame is on the stack when 's OPEN is encountered; 's frame is pushed above , absorbs all words of (and any items nested inside ), and is popped on 's CLOSE before the next word of is encountered. Thus 's frame receives precisely the words of in order. Similarly, when is empty, any MIDDLE or CLOSE cell belongs to the innermost enclosing item that opened before . Any item nested between two words of after pushes a frame onto and pops it before the next word of , leaving untouched during ; when 's CLOSE is reached with empty, is reset to 0 before any outer enclosing item's words can be seen. Thus never conflates words from two different items.
B Analysis of Processor Sharing for Hash-Table Queues
In this appendix, we prove Theorem 7.4, which bounds the expected stretch of each item and the expected maximum stretch in the virtual processor-sharing (PS) schedule used by FSCH. Recall the hash-table-queue model of Section 7.1: the set of items and their sizes are fixed, while the arrival times are independent and uniform on a circle of circumference . The load is . We write for the PS departure time of and for the number of jobs present at time . Each active job receives service at rate , and its stretch is its sojourn time divided by its size. All times and intervals below are interpreted cyclically.
Our main tool is the service-deletion identity (Lemma B.5), which relates the population seen by a job during its service to the population of the system with that job removed. We first establish the arrival and departure properties needed to prove this identity, using time reversal and a measure-preserving map from arrivals to departures. The identity then yields a geometric tail bound on the queue population and the expected stretch bound for each item. Finally, a union bound over arrivals controls the maximum population, giving the bound on the expected maximum stretch.
We begin by considering what an arriving job sees. In the M/G/1 setting, PASTA (“Poisson Arrivals See Time Averages”) equates the distribution seen by arrivals with the stationary time-average distribution [28, Section 13.3]. Here is uniform and independent of the hashes of , so the corresponding comparison is with the system in which is absent.
Observation B.1. In a hash-table queue, the state of the system immediately before an item arrives has the same distribution as the state of the system without at a uniformly random time.
We would like a similar deletion property at departures, so that it can later be applied at intermediate stages of a job's service. Our first ingredient is time reversal, which is classical in queuing theory [31]. We observe that this holds immediately for processor sharing in hash-table queues.
Observation B.2. In a hash-table queue, given a PS schedule with arrivals and departures , the reverse schedule defined by and is a valid PS schedule.
To invoke Observation B.1 in the reversed schedule, we also need its arrivals (departures in the forward schedule) to be independent and uniform. This is the analogue of the Poisson-output property of stationary M/G/1-PS queues: in both models, departures retain the distributional form of arrivals [28, Chapter 22].
Lemma B.3. In a hash-table queue, the departures in a PS schedule are uniformly and independently distributed.
Proof. Each arrival and departure lives in . Therefore the collection of all arrivals (resp. all departures) lives on . The proof will analyze the map . We will show that is bijective and measure-preserving.
By Observation B.2, the reverse schedule is a valid PS schedule. Thus departures determine arrivals uniquely by reversing time and running PS again, so is a bijection.
Now, outside the measure-zero set where two or more arrivals or departures coincide, the number of jobs is locally constant except at the points . We differentiate the service equations (Equation (7.1))
yielding , where and are locally constant matrices (except at ). Starting at an idle point, we order the jobs by arrival time. Then, for , an infinitesimal perturbation of only affects the integral in Equation (B.1) if is in the interval (interpreted cyclically). Therefore is upper triangular with diagonal entries . Similarly, ordering the rows and columns by departure time makes lower triangular with diagonal entries . This reordering does not change its determinant. Therefore, the Jacobian determinant of is
Every arrival where is an upcrossing from to , and every departure where is a downcrossing from to . The number of upcrossings must equal the number of downcrossings, so the factors of the numerator and denominator are the same. Hence, almost everywhere, and so is measure-preserving. Because the arrivals are u.i.d. and this is preserved by , the departures are as well.
Combining time reversal with Lemma B.3 now turns the arrival observation into a departure observation.
Corollary B.4. In a PS schedule for a hash-table queue, the number of other jobs present immediately before a job departs has the same distribution as the number of jobs in the system without at a uniformly random time.
Proof. This follows immediately from Lemma B.3 and Observations B.1 and B.2.
To bound sojourn times, we need to relate the population throughout a job's service to the population of the system without that job. For PS, truncating a job x to size v leaves its service history unchanged until it has received v units of service, turning that instant into a departure. Applying Corollary B.4 to this truncated job and integrating over v gives the following identity.
Lemma B.5 (Service-Deletion Identity). Let be a tagged job in a hash-table queue with a PS schedule. Let be the indicator that is in service at time and be the number of jobs present other than . For every function we have
We use Lemma B.5 in two ways. Taking makes the left-hand side of Equation (B.2) equal to the expected sojourn time of . Taking makes it the expected amount of service that receives while at least other jobs are present. Summing this second identity over will give a tail bound on the number of jobs in the system.
Proof. We will change variables in the integral so that we integrate against the service time attained by x. Define the service time
For , define to be the unique time at which . We make the change of variables , for which . Then we have
Now fix any and consider a new system where is replaced with the truncated job of size . The systems are identical up until , when departs from . Therefore,
Now, applying Corollary B.4 to in shows that has the same distribution as where is a uniformly random time. Taking expectations and integrating gives
We now can prove bounds on probability there are at least a given number of jobs present at a random time with a recursion derived from summing the service-deletion identity over jobs. The resulting upper bound mirrors the geometric stationary population law of M/G/1-PS queues, whose tail at load is , independently of the service-size distribution [28, Chapter 22].
Lemma B.6. Consider a PS schedule for hash-table queue for a set with load. For a uniformly random time , let . Then, for every integer ,
Proof. For each subset , write . We prove simultaneously for all by induction on . The base case holds since . Whenever , each active job contributes to the indicator of this event. Thus
where a summand is taken to be zero when is inactive. Integrating, applying Lemma B.5 with , and using the induction hypothesis gives
This completes the induction. Finally,
Next, we translate the bounds of the number of jobs present into stretch bounds. The service-deletion identity makes the expected stretch of a tagged item equal to one plus the expected population without that item, yielding the same dependence on load as in M/G/1-PS [28, Section 30.1]. For the maximum stretch, every job's service rate is at least the reciprocal of the maximum population. The population can increase only at arrivals, so a union bound over the n arrivals supplies the additional logarithmic factor.
Theorem 7.4. Let be a nonempty set of items with load. In the PS schedule for in the hash-table queue, each item has expected stretch at most , and the expected maximum stretch is at most .
Proof. Write for the sojourn time of . Applying Lemma B.5 with and then Lemma B.6, we obtain
Let . Since every active item receives service at rate at least , we have for every . The population increases only at arrivals. By Observation B.1 and Lemma B.6, for every integer ,
Since is nonincreasing, integration over the intervals gives
Consequently,
C Supporting Deletions in the Low-Load Structure
In this appendix, we prove Lemma 8.1, extending the low-load structure of Section 6 to support deletions. The goal is to preserve its scan bounds: for positive queries, for negative queries, and for insertions and deletions, with positive queries and updates analyzed in amortized expectation. As in the main text, the primary table , membership table , and backup table each have cells and are interleaved in a single physical array. They are initially empty, and the total volume of insertions is at most , including items subsequently deleted.
Why Deletion Marks Alone Do Not Suffice. The simplest approach would be to mark an item as deleted and otherwise leave it in place. This preserves the placement machinery, but repeated deletions and reinsertions of one key would create many items with the same hash. For example, repeatedly inserting key with values of slightly increasing lengths could leave many copies near , even within a single size class. The analyses of Sections 5 and 6 rely on independence across keys and cannot treat these copies as independent items.
Instead, we keep at most one copy of each key in each size class, and reuse that copy whenever the key is reinserted into the same class. As we describe below, the insertion algorithm will enforce this property by searching all levels of the relevant size class for an existing copy before creating a new one. To make this possible, we also replace the exact-length priority order by an order on size classes. A copy's stored length may then increase within its class without changing its priority.
Copies, Size Classes, and Metadata. The class of a length is . Each has a key and a length , and holds an item of that key padded to length . We assume that the original item length can be read from its encoding, so padding can be removed after decoding. A copy is either or ; the live copies represent exactly the current set .
Each key ever inserted has one permanent membership record, created on its first insertion. Its position in is the identifier shared by all copies of . We write and use the priority order
Since there is at most one copy per key and size class, this is a strict total order on copies. Identifiers and size classes never change, so neither do priorities.
Primary-cell metadata is as in Section 5: the stored length, codeword index, and owner identifier. A cell's identifier and stored length together identify its copy and determine its priority. As in Section 6.3, the backup table stores items in chunks. Deleting a copy does not free its chunk, allowing the chunk to be reused if the copy is later resurrected. Each occupied chunk also records its copy's identifier, stored length, and a live/dead bit, using words of metadata. A membership record stores , as in Section 6.1, together with a live/dead bit. Here is the stored length of the most recently live copy of , and is the endpoint of its most recent placement in . Deletion does not clear cells or free chunks. Dead copies continue to participate in the placement rules, but are never reinflated.
Searching the Backup Table. Unlike the insertion-only structure, we sometimes need to search for a copy that does not exist. To search class for key , search each level of that class from the home chunk of until finding the desired copy or an empty chunk. These searches proceed together in a single forward pass from , the cell of in . Dead chunks count as occupied. Within a class, keys are distinct and chunks never move, so the usual linear-probing stopping rule remains valid. We use this search both to locate live copies and to find dead copies for reuse. We fix the buddy allocator's choices independently of the hashes; since requests depend only on the numbers of new copies in each class, the allocated subarrays do also.
Operations.
-
Query(k): Scan from to its first empty cell, collecting live records with fingerprint . For a candidate at position , scan from through , collecting only symbols whose headers have identifier and stored length . If at least symbols survive, decode the padded item and compare its key with . Otherwise, search the backup levels of class for the copy with identifier . Reject the candidate if no such copy is found or its key differs from . If the backup search finds the matching item, reinflate it in , keeping its identifier and stored length, and update in its membership record. Return the matching item with its padding removed, or NOT FOUND if no candidate matches. In particular, a negative query whose only matching record is dead stops after the membership scan; it never decodes a dead copy of .
-
Delete(k): Run QUERY(k) to find the live copy and its membership record. Mark the record as dead, then find the copy in the backup levels of its class and mark its chunk as dead. The primary table is unchanged.
• Insert(x), for an item of key k, length , and class :
(1) Scan from to its first empty cell. For each matching fingerprint record at position , search the backup levels of class for the copy with identifier , whether live or dead. A found copy whose key is identifies the permanent record of ; otherwise reject the candidate. Let be the record's position, or the first empty membership cell if has no record. Set .
(2) Search the backup levels of class i for key k. Any copy found is dead, since k is absent.
(3) If a copy is found, it: set , pad to length , and overwrite its chunk with the padded item, marking the chunk live. The item fits in the same chunk, since and a class- chunk has cells. In , write its fresh codeword into the first cells available to at or after , as in Section 5. Its identifier and class, and hence its priority, are unchanged. If no copy is found, set and insert a new copy into and the newest backup level of class , using identifier .
(4) Write the live record at position in , where is the endpoint of the placement in step (3). If a record already existed, overwrite it in place.
For completeness, if more than one membership record matches the fingerprint, we may instead scan all chunks to identify the key and its record exactly, and then perform the requested operation. Chunk keys can be compared with k as they are read, keeping one partial comparison per allocated level. This uses bookkeeping words and a constant number of full forward passes. This exceptional scan will have negligible expected cost, as in Lemma 6.1.
All scans start at and proceed forward. Returning to a membership record to update it, or to for a reinflation, requires only another forward pass over the same interval. Thus each operation makes forward passes over one contiguous physical interval starting at . Since the three tables are interleaved at constant stride, it suffices to bound the lengths scanned in the constituent tables.
Lemma C.1 (Basic Invariants). At all times:
(1) Each key has at most one copy in each size class and at most one membership record. At most one of its copies is live.
(2) Stored lengths never decrease. A copy of class i has stored length in , and hence less than twice the length of every item inserted into that copy.
(3) The sum of the stored lengths of all copies, including dead copies, is at most the total insertion volume, and hence at most m/64.
(4) The copies, their stored lengths and live/dead states, and the keys with membership records are determined by the operation sequence independently of the hashes.
Proof. An insertion creates a copy only if its class contains none of that key, and creates a membership record only if the key has never had one. Existing records are always found: they never move or disappear, and lie before the first empty cell after their canonical cell. Since only absent keys are inserted, the new or resurrected copy is the key's only live copy. A resurrection takes the maximum of the old and new lengths, both in the same size class, proving (2). Each copy's stored length is the maximum of the lengths inserted into it, and different copies receive disjoint sets of insertions, proving (3). Finally, whether an insertion creates or resurrects a copy depends only on the key and size class of earlier insertions; deletions determine which copy becomes dead. This proves (4).
Lemma C.2 (Prefix Occupancy with Resurrections). Lemmas 5.1 and 5.2 continue to hold, with item lengths replaced by current stored lengths. After a resurrection of y, every primary cell naming y holds a symbol of its current codeword.
Proof. The priority order is fixed, cells are never cleared, and every placement writes into the first available cells from the copy's canonical cell. Thus a cell's owner can only increase in priority, and available sets only shrink. The inductive proof of prefix occupancy applies as before. The only additional case is a resurrection increasing a copy's stored length from to . Its surviving symbols form a prefix of at most available cells, so all are among the first available cells overwritten by the new placement. No symbols of the previous contents remain, and the new symbols again occupy a prefix of the available cells.
Lemma C.3 (Scan Lengths in the Primary Table). Let be a copy of class . There is a random variable bounding the primary-table scan of every query, insertion, resurrection, or reinflation of over the entire sequence, with
Proof. Let be the final stored length of , and let contain all copies of class at most at the end of the sequence, giving each copy weight . Place this weight by scanning left to right, occupying a cell whenever some copy that has arrived has unplaced weight. The occupied set depends only on the total weight hashing to each cell. Define as the number of cells from through the 2s-th empty cell of this placement.
At every earlier time, every copy of higher priority than x belongs to Y and has at most its final weight. By prefix occupancy and the occupancy domination argument of Lemma 5.3, its occupied cells are contained in the occupied set of Y. Thus every placement of x finishes by the 2s-th empty cell of that set. A query stops no later than the endpoint of x's most recent placement, so the same bound applies to queries.
Copies of one key share a hash. To recover independence, merge all copies of Y with a given key into one weighted item at that key's canonical cell. By Lemma C.1(1), its weight is less than
Merging preserves the arrival weight at every cell, hence the occupied set. The merged items have distinct keys and independent hashes, and their weights are fixed independently of those hashes by Lemma C.1(4). Their total weight is at most m/32.
Now add 2s to the merged item with key . The additional words fill the first 2s previously empty cells at or after , so the resulting run containing has length at least . Every merged item still has weight , and the total weight is at most . The run-length argument of Lemma 4.2, using blocks of cells and conditioning on , therefore gives a second moment of . It uses only the bounded item weights, independence of the other keys' hashes, and the fact that every word of a run hashes into that run. This bounds ; the expectation bound follows by Jensen's inequality.
Lemma C.4 (Membership and Backup Scan Bounds). (1) For each key k, all membership scans from through the first empty cell are bounded by one random variable with expectation and second moment.
(2) The backup density bound of Lemma 6.4 continues to hold. For each key k and class i, all searches of that class and all writes of a copy of k in that class have scan length at most from , where
Proof. For (1), membership records form a unit-size linear-probing table with one permanent record per key ever inserted. There are at most m/64 such keys, and their set is independent of the hashes. The final table dominates every earlier membership scan, since records are never moved or removed. Applying the run-length argument of Lemma 4.2 with unit weights gives both moment bounds, whether or not k has a record.
For (2), each chunk of class holds a copy of stored length at least . The total stored length, including dead copies, is at most . Thus the proof of Lemma 6.4 applies with copies in place of items. Resurrections use existing chunks and do not allocate levels.
For the scan bound, let be the number of chunks from the home chunk of k through the first empty chunk in the final state of level of class i. The level contains copies with distinct keys and independent home chunks. Which copies enter the level depends only on the operation sequence: allocation and insertion into a new level depend on the number of new copies, while resurrections rewrite chunks in place. The level is at most half full. Hence the unit-weight argument of Lemma 6.5 gives , including when k itself has a copy in the level.
Chunks are never freed, so dominates the corresponding search length at every earlier time. A search reads at most chunks of level , all within distance of . The same bound covers writing a new chunk or rewriting a resurrected one. Consequently, we may take
where the sum is over the final levels of class . Since , Minkowski's inequality yields
This proves the claimed bound uniformly over the operation sequence, including searches for absent copies.
Proof of Lemma 8.1. We first bound scan costs. An item held in a class- copy has , and that copy's stored length is less than . Thus bounds in terms of give the desired bounds in terms of the item length. Fingerprint collisions contribute only expected scan cost per operation, by the same argument as Lemma 6.1: fingerprints are independent of the placement hash, a collision with any record has probability at most , and even scanning the entire array costs only . We omit this contribution below.
Queries. A negative query scans only , with expected scan cost by Lemma C.4(1). A positive query for a class- copy scans expected membership cells and at most primary cells, for expected scan cost . As in Lemma 6.2, we charge any backup lookup and lazy reinflation to the insertion that first created this copy.
To justify this charge across deletions and resurrections, let be the total number of lazy reinflations of . A fallback occurs only when more than the current stored length, and hence at least , of its symbols have been overwritten since its most recent placement. By prefix occupancy, the next placement extends its endpoint by at least cells. Resurrections cannot move the endpoint to the left: the available set only shrinks, and the number of symbols to be placed never decreases. Every endpoint is bounded by , so
After accounting for the initial membership scan, each fallback and reinflation contributes at most additional scan cost. Updating the membership record accesses only the interval already scanned. By Cauchy–Schwarz and Lemmas C.3 and C.4, the total expected scan cost charged to this copy is at most
The insertion that created the copy had length at least , so it pays this charge once, including all later resurrections. Dead copies are never reinflated. This leaves positive queries with amortized expected scan cost .
Insertions. Consider an insertion of length in class . Step (1) scans expected membership cells. If the key already has a record of stored length in class , verifying that record costs at most in the backup table. We charge this verification to the preceding insertion of , whose length was at least . That insertion receives at most one such charge, since the next insertion overwrites the record; intervening queries change only its endpoint field. Step (2) costs at most . Step (3) scans at most primary cells for the new or resurrected copy , and at most backup cells. Step (4) updates the record within the membership interval already scanned. These bounds and the charges from lazy reinflations give amortized expected scan cost per insertion.
Deletions. Deleting an item consists of a query and one additional backup search in its size class, followed by updates to the two live/dead bits. The bit updates lie in the intervals already scanned. The additional expected scan cost is , so the amortized expected deletion cost is .
Finally, all accesses make forward passes over a contiguous interval starting at . Under the cache assumptions of Corollary 6.6, the scan property converts these scan bounds to the corresponding I/O bounds stated in Lemma 8.1.
D Rebuilding in Graveyard Catalan Hashing
In this section, we prove bounds on the amortized cost of rebuilds in graveyard Catalan hashing from Section 8. We do this by arguing that rebuilds can be accomplished locally and with passes over the data structure.
D.1 Why Rebuilding Is Local
A rebuild removes the flagged items, integrates the live items of into , and empties both auxiliary structures. Rebuilding by sorting all live items in external memory would be too expensive. Instead, we will rebuild independent intervals of the table inside the cache.
Let be the set of items in the old static table, including flagged items, and let be the live set of the insertion table. For this argument, keep both copies when a key occurs in both sets, and write . The new live set is , obtained by removing the flagged items. The budget and space bounds imply
Let be any placement of that scans from left to right, placing one word whenever an arrived item still has unplaced words. The occupied cells depend only on the total volume hashing to each cell, not on which pending item is chosen. Call its maximal occupied intervals the -runs.
Claim D.1 (Rebuild Locality). For each -run , the old static items stored in are exactly the items of whose canonical cells lie in . The new static items hashing into occupy only cells of , and their layout and metadata can be computed from those items alone.
Proof. Adding arrival work can only increase the occupied set. Since , every run of either the old or the new static table lies within a -run. An item and its canonical cell lie in the same run, proving the placement statements.
The ARCH priorities within each new run are determined by the hashes in that run. Consequently, the priorities, placement, home bits, and stop marks within depend only on the items of hashing into .
We next show that every such interval fits in the rebuild scratch region with high probability. Only a simple large-deviation bound is needed: a long run requires an interval to receive at least its own length in arrival work, even though the expected volume is smaller by a factor .
Lemma D.2 (A Tail Bound for the Longest Run). Let be a fixed set of items with independent uniform hashes, maximum length at most , and volume at most , where . Place its words whenever arrival work is pending, as above. For every integer ,
for an absolute constant .
Proof. For a fixed interval , let be the total length of the items with canonical cells in . It is a sum of independent variables in with expectation at most . A Chernoff bound gives
Every word of a run belongs to an item whose canonical cell lies in that run. Thus, if is a run, . There are at most intervals, so a union bound over those of length at least proves the result.
Claim D.3 (All Rebuild Intervals Fit in Cache). For a sufficiently large constant , with probability at least , every U-run has length at most
Proof. There are at most two items of with a given key: one in and one in . Merge them into a single item of length at most . This preserves the arrival work, hence the occupied cells of . The merged items have distinct keys and independent hashes, and their lengths and membership are fixed by the operation sequence, independently of the hashes. Apply Lemma D.2 with , , and .
Only the per-item query bounds of the static table enter the operation analysis. Its expected maximum stretch is not needed.
D.2 Rebuilding with Sequential Passes
Locality reduces the rebuild to two tasks: enumerate the live insertion-table items in hash order, and identify the U-runs. Once these are available, each new static run can be computed in cache and written over the old table.
Lemma D.4 (Streaming Rebuild). A rebuild has expected scan cost . Under the cache-size assumption of Section 8, , it takes expected I/Os. With probability , it uses a constant number of sequential passes and words of temporary space outside the table; otherwise it uses temporary words.
Proof. We may assume , since proving the update bound for a smaller suffices. First consider a long update. Its length, or the length of its deleted key, is at least . Hence , and for sufficiently large the cache assumption puts the entire physical array in cache. We read it, apply the update, rebuild, and write it back in I/Os. We now consider budget-triggered rebuilds.
Pass 1: Extract the Insertions in Hash Order. Every live item of has a live chunk in (Appendix C). Scan the physical array, reading these chunks and ignoring the primary codewords. The allocator state identifies the level, chunk, and offset of each backup cell. A scan reads at most one partial chunk per allocated subarray at a time. There are levels per class, and a class-i chunk has cells. Summing over classes, the partial chunks occupy cached words.
When a live chunk is complete, remove its padding, compute its hash, and keep its item in a buffer ordered by hash. Release an item y to a sequential temporary stream when the scan has advanced
physical cells past , for a sufficiently large constant . The placement argument of Lemmas C.4 and 6.5 bounds the distance to the end of a class-i chunk in level by
where has an exponential tail: the level is a unit-size linear-probing table at load at most . A union bound over the at most live items shows that, with probability , every item is complete before its release point. When , unwrap canonical positions into the interval . Use each chunk's first complete occurrence after its represented canonical position, ignoring earlier occurrences and later duplicates. The first lap initializes the cyclic buffer; the second emits one lap of releases, processing equal-cell releases in hash order. This produces a stream of in cyclic hash order. When , instead collect all of in at most two laps, sort it in cache, and write the stream directly.
On this event, buffered items have canonical cells in an interval of at most physical cells behind the scan. The set has independent hashes and volume . A Chernoff bound and a union bound over scan positions show that, with probability , the buffer uses at most
words. If exceeds the array length, the same bound follows by buffering all of .
Pass 2: Find a Boundary and Check Run Lengths. Start at any empty cell of the old static table and read one old run at a time. Parse each run in cache, reconstruct its items, and sort them by hash. An oversized old run triggers the fallback described below. Otherwise, merge its arrivals with the stream from pass 1 to obtain, in cyclic cell order,
If the starting cell is indexed 0, one lap computes a minimizer of
Every cyclic interval ending at receives at most its length in work, since is minimal and . Thus no work is pending after cell . Continuing from there with zero pending work, the recursion
identifies the occupied cells of : cell is occupied exactly when . In one additional lap, find an empty cell and check that every -run has length at most . If a run crosses the starting point of this lap, combine its initial and final occupied segments when checking its length. All size checks take place before any table cells are overwritten.
Pass 3: Rebuild Each Interval in Cache. Starting just after , read the table for one lap, using the same arrival-work recursion. For each -run , collect the old items stored in and the items of hashing into . Their total volume is . Discard flagged items and compute the new ARCH layout in cache: priorities in decreasing cyclic hash order, delimiters, home bits, and stop marks. By Claim D.1, this is exactly the restriction of the new static table to .
Also compute the collision bits for the new static set: initialize them to zero, sort the retained items by descriptor in cache, and mark each canonical cell whose descriptors include a duplicate. All keys with a given canonical cell lie in the same -run, so this detects every relevant collision. The descriptors use cached words and require no additional I/Os. Clear all deletion bits.
Write the new contents over the old run. The write pointer trails the read pointer, so each run is read completely before it is overwritten. Clear all cells outside the -runs, both auxiliary structures, their allocator state, and the budget counters. The backup chunks have already been extracted in pass 1.
Space, Failure Events, and Cost. The cached working space is
and the temporary stream contains words. Each pass scans at most two laps of the array and a constant number of sequential streams, using blocks outside the scratch region. Thus the passes cost I/Os and scan cells.
The failure events are a late chunk, an oversized extraction buffer, or an oversized run. A chunk's cyclic displacement from its canonical position is checked when it is read, so a late chunk is detected even if its chosen occurrence falls beyond the second lap. Their total probability is , and they are detected in the first two passes, while the old table is intact. In that case, extract the items into external working space and build the new table directly, using temporary words and RAM operations and I/Os. This fallback contributes only expected I/Os for . For , the whole array fits in cache under our assumptions. Charge the first access to the triggering update; once that block is cached, random rotation gives expected additional I/Os to load the array and rebuild it there. The same estimates give expected scan cost , including the fallback.