Progressive Chunked Queue Scalable Concurrent Producer Consumer

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Concurrent unbounded queues based on compare-and-swap instructions do not scale with the number of producer threads, leading to poor system performance and wasted work due to CAS failures, which result in increased latencies and reduced throughput.

Innovation Solution

The progressive chunked queue system uses fetch-and-add instructions and a doubly linked list of memory chunks, allowing any producer to make progress and allocate new chunks, reducing coordination efforts and enabling higher throughput and lower latencies by reusing or appending memory chunks as needed.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If compare-and-swap instructions are used in concurrent unbounded queues, then coordination between producer threads is achieved, but system performance deteriorates and throughput reduces due to CAS failures and increased latencies

Engineering Contradiction:
Improvecoordination reliabilityVSAvoidsystem throughput
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent extracts the coordination mechanism from the critical path of item insertion. Instead of using CAS instructions that block producers during coordination, the invention uses a separate coordination structure (the chunk pointer array) that allows producers to insert items without contending for the same memory locations. This removes the harmful coordination overhead from the main execution path.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent introduces an intermediary structure - the chunk pointer array - that mediates between multiple producer threads and the queue data structure. Each producer can independently update chunk pointers for their assigned chunks, and the intermediary handles the mapping between sequence numbers and chunk locations, eliminating direct contention between producers.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If compare-and-swap instructions are used in concurrent unbounded queues, then thread synchronization is maintained, but system performance worsens due to CAS failures and increased latencies

Engineering Contradiction:
Improvethread synchronizationVSAvoidoperation latency
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The patent performs preliminary actions by pre-allocating and organizing memory into fixed-size chunks with predetermined identifiers. The chunk pointer array is pre-initialized to map sequence number ranges to specific chunks. This preliminary organization eliminates the need for runtime CAS operations and chunk allocation decisions, reducing latency significantly.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent segments the queue into fixed-size chunks, where each chunk can be independently managed. This segmentation allows multiple producers to work on different chunks simultaneously without interfering with each other, maintaining synchronization while eliminating contention. Each chunk becomes an independent unit that can be processed in parallel.

Inventive Principle:
Principle #1Segmentation

3Device complexity

If traditional CAS-based queues are used, then simple insertion logic is maintained, but productivity decreases due to failed CAS operations and wasted work

Engineering Contradiction:
Improveinsertion logic simplicityVSAvoidoperations per microsecond
Core Design Contradiction:
Device complexityVSProductivity

Solution Approach 1:

The insertion logic is segmented into two independent parts: (1) determining which chunk to insert into based on the sequence number and chunk pointer array, and (2) inserting the item into the identified chunk. This segmentation simplifies the logic by eliminating the need for CAS retry loops and complex contention handling, while improving productivity through predictable, non-blocking operations.

Inventive Principle:
Principle #1Segmentation

Data Source

PatentUS10782970B1Scalable multi-producer and single-consumer progressive chunked queue
Publication Date: 2020.09.22 RED HAT INC
  • US10782970B1 patent drawing
  • US10782970B1 patent drawing
  • US10782970B1 patent drawing

AI summary

A method includes receiving, by a producer thread, an offer request associated with an item. Additionally, the method includes increasing, by the producer thread, a producer sequence. The producer thread determines (i) a chunk identifier, associated with the producer sequence, of a memory chunk from a doubly linked list of memory chunks and (ii) a slot position, from the producer sequence, in the memory chunk to offer the item. Additionally, the producer thread writes the item into the memory chunk at the slot position. A consumer thread determines the slot position of the item, consumes the item at the slot position, and determines the status of the slot position as an intermediate slot or the end slot. Responsive to determining the slot position as the end slot, the consumer thread detaches the memory chunk to remove the memory chunk from the doubly linked list of memory chunks.