Dynamic Ring Buffer for Concurrent Data Queuing

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Concurrent computing environments face performance constraints due to process and thread contention, latency, and inefficient memory usage, particularly in multicore and multi-CPU platforms with multiple producers and consumers, which existing locking mechanisms and lock-free mechanisms struggle to address effectively.

Innovation Solution

The implementation of a ring buffer data structure with dynamic size adjustment using atomic non-blocking operations, such as atomic_fetch_and_add, atomic_fetch_and_subtract, and compare_and_swap, to minimize contention and allow parallel operations without cache line invalidation, by using separate cache lines for reader and writer portions and dynamically allocating new rings when overflow conditions are detected.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If locking mechanisms are used to address contention, then data integrity is maintained, but wait times and thread stalls increase significantly

Engineering Contradiction:
Improvedata integrityVSAvoidwait times and thread stalls
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The cache line is segmented into multiple fields (owner field, state field, and data field) that can be independently manipulated. This allows the system to track ownership and state without requiring full cache line locks, reducing contention while maintaining data integrity through field-level control.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

An intermediary atomic compare-and-swap operation is introduced to mediate between readers and writers. This operation provides a lock-free mechanism that ensures data integrity by atomically verifying and updating cache line state, eliminating the need for traditional locking while preventing race conditions.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If lock-free mechanisms are used to reduce wait times, then scalability improves, but the A-B-A problem arises where state appears identical but secret modifications occur

Engineering Contradiction:
Improvescalability and reduced wait timesVSAvoiddata integrity
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The owner field and state field are preliminarily set and tracked before data modifications occur. By establishing ownership and state information in advance, the system can detect A-B-A problems through atomic compare-and-swap operations that verify the cache line hasn't been secretly modified, even if the final state appears identical.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The atomic compare-and-swap operation provides feedback about the current cache line state before allowing modifications. This feedback mechanism detects A-B-A conditions by verifying that no intermediate modifications have occurred, ensuring data integrity while maintaining lock-free scalability.

Inventive Principle:
Principle #23Feedback

3Productivity

If multiple producers and consumers operate simultaneously on shared memory, then processing throughput increases, but process and thread contention rises

Engineering Contradiction:
Improveprocessing throughputVSAvoidprocess and thread contention
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The cache line is segmented into owner field, state field, and data field, allowing multiple threads to safely read and write different fields simultaneously. This segmentation reduces contention by enabling fine-grained access control without requiring full cache line locks, thus maintaining high throughput while reducing complexity.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Each thread services itself by atomically acquiring ownership through compare-and-swap operations on the owner field. This self-service mechanism eliminates the need for centralized locking logic, reducing thread contention and complexity while allowing multiple producers and consumers to operate simultaneously with improved throughput.

Inventive Principle:
Principle #25Self-service

Data Source

PatentUS10013235B2Method and system for queuing data for multiple readers and writers
Publication Date: 2018.07.03 TRAVELPORT TECH LLC
  • US10013235B2 patent drawing
  • US10013235B2 patent drawing
  • US10013235B2 patent drawing

AI summary

Systems and methods of queuing data for multiple readers and writers are provided. Enqueuing operations are disclosed that can process write functionality and can determine whether ring buffers have potentially filled, and dynamically declare a new ring buffer at a multiple of capacity of the current ring. Dequeuing operations are disclosed that can process read functionality for advancing control and determining whether and when to free ring buffers from memory.