NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Fast Arrays: Atomic Arrays with Constant Time Initialization

Siddhartha Jayanti, Julian ShunDisc 2021

TL;DR

This paper presents a novel data structure for "fillable arrays" that allows for constant-time reads and fills, and amortized constant-time writes, using only a single extra bit of memory. This is a significant improvement over previous methods that required more memory or had slower operations.

What Problem Does This Paper Address?

The paper tackles the classic "fillable array" problem. Imagine an array where you can read any element, write to any element, and crucially, "fill" the entire array with a single value. This is a common operation in programming, often implemented by functions like memset in C or Arrays.fill in Java. The challenge is to do this efficiently. The standard approach uses n w bits of memory (where n is the array size and w is the number of bits per element) and can perform reads and writes in constant time, but filling the array takes linear time (O(n)). While this is optimal for n w bits, the authors investigate a fundamental question: can we achieve constant-time operations with just a tiny bit of extra memory? Specifically, they aim for n w + 1 bits.

Methods

The core innovation lies in a two-mode data structure: "naive mode" and "linked list mode," controlled by a single redundant bit.

  • Naive Mode: In this mode, the array behaves like a standard array, with direct access for reads and writes.
  • Linked List Mode: This is where the cleverness happens. Instead of storing every element directly, this mode uses a linked list structure to track only the active elements (those written since the last fill). A small portion of memory is dedicated to pointers and metadata, while the actual data for active elements is stored in a linked list. This allows for efficient updates because only modified elements need to be tracked.

The key challenge is transitioning between these modes and managing memory. When the number of active elements in linked list mode becomes too large, the structure converts back to naive mode. This conversion process is the main bottleneck.

To address the linear time conversion, the paper proposes two solutions:

  1. Amortized Solution: This deterministic approach achieves constant-time reads and fills, and amortized constant-time writes. The linear-time conversion cost is "paid for" over many write operations.
  2. Randomized Solution: This approach uses a randomized permutation to achieve expected constant-time writes, while still maintaining constant-time reads and fills. This involves a more complex conversion process that gradually shifts elements to naive mode, leveraging a probabilistic argument to bound the expected cost. This solution requires an additional O(log n) bits for the permutation.

Datasets

Not discussed in the paper.

Key Insights and Ideas

  • The Power of a Single Bit: The most striking insight is that a single extra bit of memory is sufficient to dramatically improve the performance of fill operations, moving from linear to constant (amortized or expected) time.
  • Active Elements Tracking: The linked list approach for tracking only "active" elements is a clever way to reduce memory overhead and update costs when the array is sparsely modified after a fill.
  • Mode Switching as a Trade-off: The paper elegantly uses mode switching (naive vs. linked list) as a mechanism to balance memory usage and operation speed. The cost of switching is amortized or randomized away.
  • Randomization for Expected Performance: The randomized solution demonstrates how probabilistic techniques can be used to achieve strong performance guarantees (expected constant time) even when deterministic solutions face inherent bottlenecks.

Key Results

  • Deterministic Solution: Achieves constant worst-case time for read/fill and amortized constant time for write, using nw + 1 bits of memory.
  • Randomized Solution: Achieves constant worst-case time for read/fill and expected constant time for write, using nw + 1 bits of memory plus O(log n) bits for a permutation.

Limitations and Future Work

  • Amortized Write Time: The deterministic solution offers amortized constant time for writes, not worst-case.
  • Randomized Solution Dependencies: The randomized solution relies on an oracle for a specific type of permutation (1/n²-almost pairwise independent), though the paper provides a construction for this.
  • Constant Factors: While the asymptotic complexities are excellent, the practical performance will depend on the constant factors involved in the mode switching and linked list operations, especially for smaller array sizes.

The paper implicitly suggests that further exploration into achieving worst-case constant-time writes with minimal redundancy might be an interesting avenue.

Summary updated

BibTeX
@inproceedings{jayanti2021fast,
  author = {Siddhartha Jayanti and Julian Shun},
  title = {{Fast Arrays: Atomic Arrays with Constant Time Initialization}},
  booktitle = {Disc},
  year = {2021},
  doi = {10.4230/lipics.disc.2021.25},
}
Figure