Adaptive Multi-Threaded Buffer Resizing
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In producer/consumer systems, when producers generate data faster than consumers can access it, the queue can become filled, leading to blocking of additional producers and potential data loss, as existing solutions rely on locking mechanisms that do not effectively manage data availability and resizing.
Innovation Solution
A buffer system that uses a circular buffer structure with adaptive resizing, allowing multiple writers and readers to access data without locking, by incrementing writer and reader indices atomically and resizing when the buffer is full, ensuring data is not lost and preventing race conditions between readers and writers.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Quantity of substance
If the queue is filled to capacity to store more data, then the data storage capacity is improved, but additional producers are blocked and cannot insert more data
Solution Approach 1:
The buffer dynamically resizes itself when full by allocating a new larger buffer and migrating data, transforming the static fixed-capacity queue into a dynamic adaptive structure that can grow to accommodate more data without blocking producers
Solution Approach 2:
The buffer changes its capacity parameter by allocating a new buffer with larger size (e.g., double the original capacity) when the current buffer is full, allowing the system to adapt to varying data generation rates and prevent producer blocking
2Reliability
If locking mechanisms are used to share data between producers and consumers, then data integrity is improved, but the system complexity and access overhead increase
Solution Approach 1:
The buffer is segmented into individual slots with each slot independently trackable through indices, allowing multiple producers and consumers to access different slots simultaneously without requiring global locking, thus reducing system complexity while maintaining data integrity
Solution Approach 2:
The patent introduces an intermediary empty value object that mediates between writers and readers, allowing them to determine data availability without direct interaction or locking, simplifying the synchronization mechanism while ensuring data integrity
3Productivity
If the buffer size is increased to prevent blocking, then the producer productivity is improved, but the memory consumption increases
Solution Approach 1:
The buffer size is made dynamic rather than static, starting with a smaller initial capacity and only expanding when necessary, thus optimizing memory consumption by allocating additional memory only when the workload requires it, rather than pre-allocating excessive memory
Data Source
AI summary
An adaptive multi-thread buffer supports multiple writer process and reader processes simultaneously without blocking. Writer processes are assigned a reserved write slot using a writer index that is incremented for each write request. When a reserved write slot is not null, the buffer is resized to make room for new data. Reader processes are assigned a reserved read slot using a reader index that is incremented for each read request. When data is read out to the reader process, the read slot content is set to null. When a writer process attempts to write null data to a write slot, the buffer replaces the null write data with an empty value object so that content of the buffer is null only for empty slots. When an empty value object is read from a slot, the buffer replaces the content with null data to send to the reader process.


