Multithreaded Lossy Queue Protocol for Ring Buffer Overflow
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In multithreaded applications, traditional queue structures become inefficient when a consumer stalls, causing the queue to fill and preventing further data storage, as the producer must wait for the lagging consumer to finish processing, leading to potential stalling of other consumer threads.
Innovation Solution
A circular queue and queueing protocol where consumers can independently assess if their data access location has been overrun by the producer, allowing them to discard data and resume from a safe point, thereby preventing queue overflow and enabling continuous operation without stalling the producer or other consumers.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the queue is sized to ensure adequate storage time for consumer processing, then data availability for consumers is improved, but storage space utilization efficiency deteriorates when the queue never approaches capacity
Solution Approach 1:
The patent implements dynamic queue management where the queue size and behavior adapt based on consumer processing speed. When consumers are slow, the queue maintains larger capacity to ensure data availability. When consumers are fast, the queue automatically shrinks or allows overwriting, optimizing storage utilization. This is achieved through mechanisms like the tail pointer that can wrap around and overwrite old data, and the ability to dynamically adjust queue parameters based on usage patterns.
2Reliability
If the producer waits for the lagging consumer to finish processing, then data integrity for that consumer is maintained, but overall system throughput deteriorates due to stalling of the producer and other consumers
Solution Approach 1:
The patent segments the queue into multiple independent regions or slots that can be processed independently. Each consumer can work on different segments simultaneously, and the producer can continue writing to new segments while consumers process older ones. This segmentation allows the system to maintain data integrity for each consumer's assigned data while enabling parallel processing and preventing system-wide stalling. The circular buffer structure with multiple producers and consumers operating independently is a key manifestation of this principle.
Solution Approach 2:
The patent ensures continuous productive action by allowing the producer to write data continuously without waiting for consumers to finish processing. The circular queue structure with wrap-around capability enables the producer to overwrite old data that has been consumed or is being consumed by other consumers. This continuity is maintained through mechanisms like the head and tail pointers that track production and consumption positions, allowing overlapping production and consumption operations without data corruption.
3Reliability
If additional resources are obtained when queue usage approaches capacity, then data loss is prevented, but system complexity and resource overhead increase
Solution Approach 1:
The patent changes the fundamental parameter of queue capacity from a fixed static value to a dynamic value that can change during operation. The queue implements a circular buffer structure where the effective capacity can be adjusted by modifying the tail pointer position, wrap-around behavior, or allowing overwriting of consumed data. This parameter change enables the queue to adapt to varying load conditions without requiring additional resource allocation, maintaining data loss prevention while avoiding the complexity of dynamic resource management.
Data Source
AI summary
Methods and systems for managing a circular queue, or ring buffer, are disclosed. One method includes storing data from a producer into the ring buffer, and receiving a data read request from a consumer from among a plurality of consumers subscribed to read data from the ring buffer. After obtaining data from a location in the ring buffer in response to the data read request, it is determined if the location has been overrun by the producer. If it is determined that the location has been overrun by the producer, the data is discarded by the consumer. Otherwise, the data is consumed. Depending on the outcome, a miss counter or a read counter may be incremented.


