Seqlock Variable-Length Data Protection

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional Sequence Lock (seqlock) techniques are unable to store data structures that include pointers, limiting the capacity to fixed-size data and causing potential resource starvation due to writer starvation and pointer invalidation issues.

Innovation Solution

Implementing a seqlock mechanism with write-once pointers and an always valid end iterator to ensure that pointers accessed by reader threads are never invalidated by writer threads, allowing for the storage of variable-length data structures and linked lists while maintaining lockless read performance.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If conventional seqlock is used to protect data structures with pointers, then writer starvation is avoided and read performance is improved, but pointer invalidation occurs and variable-length data storage becomes impossible

Engineering Contradiction:
Improveread performanceVSAvoidpointer validity
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The data structure is segmented into a fixed-size header portion (protected by seqlock) and a variable-length data portion (unprotected). The header contains the sequence number and a pointer to the data portion. This segmentation allows the seqlock to protect only the critical synchronization metadata while allowing the data portion to be freely allocated and accessed without locking, thus maintaining pointer validity and enabling variable-length storage.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

An intermediary pointer structure is introduced between the seqlock-protected header and the actual data. The header contains a pointer to the data portion, and readers access data through this intermediary pointer without needing to hold the lock. This intermediary mechanism decouples the locking mechanism from the data access, preventing pointer invalidation while maintaining read performance.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If seqlock is used to protect shared data, then writer starvation is avoided, but storage capacity is limited to fixed-size data

Engineering Contradiction:
Improveconcurrent write performanceVSAvoiddata structure flexibility
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The data structure is divided into a fixed-size protected header and a variable-length data section. The header contains sequence number and allocation metadata, while the data section can dynamically expand. This segmentation enables the system to maintain seqlock's concurrent write performance for the header while achieving variable-length data storage through the unlocked data section.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The data structure transitions from a static fixed-size arrangement to a dynamic variable-length structure. The data portion can be dynamically allocated and expanded as needed, while the header remains fixed and protected by seqlock. This dynamic capability allows the system to adapt to different data sizes while maintaining the performance benefits of seqlock for the critical header metadata.

Inventive Principle:
Principle #15Dynamics

3Reliability

If traditional read-write lock is used, then data access is synchronized, but writer starvation occurs and readers must wait for writers

Engineering Contradiction:
Improvedata access synchronizationVSAvoidwrite throughput
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The seqlock mechanism extracts the essential synchronization function from traditional read-write locks. Instead of using a single lock that blocks both readers and writers, the seqlock uses a sequence number and read-side locking to allow readers to proceed without blocking writers. This extraction of the synchronization mechanism enables writers to make progress without waiting for readers, eliminating writer starvation while maintaining data consistency.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS8495309B2Variable length data protected by seqlock
Publication Date: 2013.07.23 SAP IRELAND LTD
  • US8495309B2 patent drawing
  • US8495309B2 patent drawing
  • US8495309B2 patent drawing

AI summary

Various embodiments of systems and methods for variable length data protected by Seqlock are described herein. Seqlock is a special locking mechanism used in data structures for multithreaded applications that can be read very quickly, when there are no changes being made, at the cost of needing to repeat a read operation when writing has occurred. A Seqlock, in normal use, can only protect a fixed-size data structure with no pointers. This is because the writing thread may invalidate a pointer after a reading thread has followed it. The embodiments specify an algorithm where a Seqlock-protected pointer, once written, is never invalidated. This removes the “no pointers” restriction, allowing the Seqlock to protect a simple singly-linked list, which can be safely increased in size while being read by other threads. The innovation includes the use of the write-once head and next pointers, and the always valid end iterator.