Progressive Chunked Queue for Scalable Multi-Producer Systems

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Multi-producer concurrent queues based on compare-and-swap instructions do not scale with the number of producer threads, leading to poor system performance due to CAS failures and increased latency.

Innovation Solution

Implementing a progressive chunked queue that uses fetch-and-add instructions, allowing multiple producers to make progress independently and reuse memory chunks, while consumers coordinate through epoch sequences to mark slots and recycle memory chunks.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If multi-producer concurrent queues use compare-and-swap instructions, then thread synchronization is achieved, but system performance deteriorates due to CAS failures and increased latency

Engineering Contradiction:
Improvethread synchronizationVSAvoidsystem performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The queue is divided into multiple independent memory chunks, each with its own sequence counter. Producer threads operate on different chunks independently, eliminating CAS contention. Each chunk can be processed by any producer thread without coordinating with others, segmenting the critical section and improving parallelism.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

A memory chunk pool acts as an intermediary between producers and consumers. Producers allocate chunks from the pool and write items, while consumers retrieve chunks and consume items. This intermediary structure decouples producers and consumers, allowing independent operation without direct CAS-based synchronization between them.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If multiple producer threads operate on the same queue, then throughput increases, but latency increases due to CAS failures

Engineering Contradiction:
ImprovethroughputVSAvoidlatency
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The queue is divided into multiple independent memory chunks, each with its own sequence counter. Producer threads operate on different chunks independently, eliminating CAS contention. Each chunk can be processed by any producer thread without coordinating with others, segmenting the critical section and improving parallelism.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Memory chunks are pre-allocated and initialized with sequence counters before being placed in the pool. This preliminary preparation eliminates the need for runtime allocation and initialization operations that would require synchronization, allowing producers to immediately write items without CAS failures.

Inventive Principle:
Principle #10Preliminary action

3Quantity of substance

If memory chunks are reused by consumers, then memory footprint is reduced, but coordination complexity increases

Engineering Contradiction:
Improvememory footprintVSAvoidcoordination complexity
Core Design Contradiction:
Quantity of substanceVSDevice complexity

Solution Approach 1:

A memory chunk pool acts as an intermediary between producers and consumers. Producers allocate chunks from the pool and write items, while consumers retrieve chunks and consume items. This intermediary structure decouples producers and consumers, allowing independent operation without direct CAS-based synchronization between them.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

Each memory chunk contains its own sequence counter and item data, making it a self-contained unit that can be independently allocated, processed, and recycled. Consumers can determine chunk validity by checking the sequence counter without needing complex coordination with producers, enabling self-service operation.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS11960933B2Versioned progressive chunked queue for a scalable multi-producer and multi-consumer queue
Publication Date: 2024.04.16 RED HAT INC
  • US11960933B2 patent drawing
  • US11960933B2 patent drawing
  • US11960933B2 patent drawing

AI summary

A method includes receiving, by a producer thread of a plurality of producer threads, an offer request associated with an item. The producer thread increases a sequence and determines (i) a chunk identifier of a memory chunk from a pool of memory chunks and (ii) a first slot position in the memory chunk to offer the item. The producer thread also writes the item into the memory chunk at the first slot position. Then, a first consumer thread of a plurality of consumer threads determines the first slot position of the item and consumes the item at the first slot position. A second consumer thread consumes another item at a second slot position in the memory chunk and recycles the memory chunk.