Efficient Dynamic Weighted Set Sampling and Its Extension

Fangyuan Zhang, Mengxu Jiang, Sibo Wang

TL;DR

This paper introduces BUS and WIRS-BUS, novel algorithms for efficient dynamic weighted set sampling (WSS) and weighted independent range sampling (WIRS). These methods offer significant improvements in update times and sampling efficiency compared to existing solutions, making them practical for real-world applications with frequently changing data.

What Problem Does This Paper Address?

The paper tackles the challenge of efficiently performing weighted set sampling (WSS) and weighted independent range sampling (WIRS) in dynamic environments. WSS is crucial in various applications like query processing, social network analysis, and online advertising, where elements are sampled based on their assigned weights. Traditional methods like the alias method are efficient for static data but struggle with dynamic updates (insertions/deletions). While some dynamic WSS schemes exist, they are often impractical due to high update costs or complex implementations. WIRS, an extension of WSS, involves sampling from a subset of elements within a specified range, which becomes even more complex in dynamic settings. The core problem is to develop methods that support both fast sampling and efficient dynamic updates for these sampling tasks.

Methods

The paper proposes two main algorithmic contributions:

  • BUS (BUcket Sampling) for Dynamic WSS: This method uses a single-level bucketing strategy to divide elements based on their weights. It employs a hash table to manage non-empty buckets and dynamic arrays within buckets for efficient element storage and retrieval. Updates (insertions/deletions) are handled in amortized O(1) time by modifying bucket weights and element positions. Sampling is achieved in O(log n + t) expected time by strategically examining a subset of buckets and then performing rejection sampling.
  • WIRS-BUS for Dynamic WIRS: This approach extends BUS to handle WIRS. It builds a weight-balanced binary search tree (BST) where each internal node stores a BUS structure. This combination allows for efficient range queries and dynamic updates. To further optimize, a chunk-based approach is used, grouping elements into chunks to reduce space complexity and improve cache efficiency. WIRS-BUS achieves O(log² n + t) sampling time and O(log n) amortized update time. An alternative, WIRS-OPT, is also presented for theoretical comparison, achieving O(log n + t) sampling time but with higher space complexity.

Datasets

The paper evaluates its proposed methods using both real-world and synthetic datasets:

  • Real-world datasets:
    • USA: ~24 million road junctions with weights representing road segment lengths.
  • Deli: ~38 million items from Delicious with weights based on the number of tags.
  • Twitter: ~41 million users with weights representing follower counts.
  • Synthetic datasets:
    • Uniform: 10⁸ elements with weights uniformly sampled from [0, 10⁷].
  • Exponential: 10⁸ elements with weights sampled from an exponential distribution (λ = 1/1000).

Key Insights and Ideas

  • Single-level bucketing for WSS: The paper demonstrates that a simplified single-level bucket structure, combined with a clever sampling strategy, can achieve optimal theoretical performance for dynamic WSS, avoiding the complexity of multi-level bucketing or lookup tables.
  • Weight-balanced BST for dynamic WIRS: By using a weight-balanced BST (like BB[a]-tree) instead of a standard height-balanced BST, the authors effectively amortize the cost of tree rotations during updates, preventing O(n) changes and enabling efficient dynamic WIRS.
  • Chunk-based optimization: Grouping elements into chunks and storing them contiguously significantly reduces memory usage and improves cache locality, making sampling more efficient in practice without sacrificing update performance.
  • Trade-off between sampling and update efficiency: The research highlights that while some methods offer faster sampling, they come at the cost of slower updates. BUS and WIRS-BUS strike a good balance, making them suitable for scenarios with frequent updates.

Key Results

  • BUS for WSS: Achieves amortized O(1) update time and O(log n + t) expected sampling time with linear space. Experiments show up to 10x improvement in sampling and 7x-10x speed-up in updates compared to existing dynamic WSS solutions.
  • WIRS-BUS for WIRS: Achieves O(log² n + t) sampling time and O(log n) amortized update time. It demonstrates up to 5x improvement in sampling over WIRS-BST and matches the sampling performance of static WIRS algorithms while supporting efficient updates.
  • Scalability: Both BUS and WIRS-BUS show excellent scalability, outperforming BST-based solutions as dataset size increases.

Limitations and Future Work

  • WIRS-OPT impracticality: The paper notes that WIRS-OPT, while theoretically efficient for sampling (O(log n + t)), is impractical for large datasets due to high space complexity, similar to the OPT scheme for WSS.
  • Future Work: The authors suggest exploring dynamic WSS and WIRS problems in an external memory setting and designing more efficient dynamic WIRS schemes for spatial databases.

Summary updated

BibTeX
@article{zhang2023efficient,
  author = {Fangyuan Zhang and Mengxu Jiang and Sibo Wang},
  title = {{Efficient Dynamic Weighted Set Sampling and Its Extension}},
  journal = {Proc. VLDB Endow.},
  year = {2023},
  url = {https://openreview.net/forum?id=fsei0VvWneU},
}
Figure