Concurrent Cache Replacement Algorithm Using Fine-Grained Locking

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

As CPU clock speed remains constant and the number of CPU cores increases, existing cache replacement algorithms face challenges in concurrency due to high CPU overhead and contention from locking mechanisms, which can lead to inefficiencies in handling cache hits and misses across multiple threads.

Innovation Solution

A cache management data structure utilizing three queues (hot, cold, and ghost) with fine-grained locking and atomic variables allows for concurrent access, ensuring that each thread locks at most one cache element and hash bucket, preventing deadlocks and enabling lockless search operations for allocation candidates.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If the entire cache is locked to handle cache hits and only released for cache misses, then cache data consistency is ensured, but concurrency performance deteriorates due to high CPU overhead and thread waiting

Engineering Contradiction:
Improvecache data consistencyVSAvoidconcurrency performance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The cache is divided into multiple independent shards, each with its own lock. This segmentation allows different threads to access different shards simultaneously without contention, while still maintaining data consistency within each shard. The hash table is also segmented into multiple buckets that can be locked independently.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Instead of applying a uniform locking strategy across the entire cache, the patent applies locking only at the local shard and bucket level where actual data access occurs. This local quality approach ensures that locks are acquired only for the specific portions of the cache being accessed, not the entire structure, thereby maintaining consistency where needed while allowing parallel access elsewhere.

Inventive Principle:
Principle #3Local quality

2Productivity

If simple sharding is applied to improve concurrency, then parallel access is enabled, but contention and waiting overhead increase due to locking each shard from different cores

Engineering Contradiction:
Improveparallel access capabilityVSAvoidcontention and waiting overhead
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The cache is divided into multiple fine-grained shards with independent locks, allowing maximum parallelism. Each shard can be accessed by different threads simultaneously without interfering with other shards, minimizing contention and waiting overhead while maintaining parallel access capability.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The hash table structure provides self-service by automatically distributing cache entries across different buckets based on hash functions. This eliminates the need for manual shard management and reduces the overhead of coordinating locks across shards, as the hash-based distribution naturally balances the load and minimizes lock contention.

Inventive Principle:
Principle #25Self-service

3Productivity

If fine-grained locking is applied to reduce contention, then concurrency is improved, but device complexity increases due to multiple locks and atomic variables

Engineering Contradiction:
Improveconcurrency efficiencyVSAvoidlocking mechanism complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The locking mechanism is segmented into hierarchical levels: shard-level locks for coarse-grained parallelism and bucket-level locks for fine-grained control. This segmentation allows the system to achieve high concurrency while managing complexity through a structured, multi-level approach rather than requiring complex global synchronization mechanisms.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent merges the hash table structure with the locking mechanism, where each hash bucket inherently contains its associated lock. This integration eliminates the need for separate lock management structures and simplifies the overall system by combining data organization and synchronization into a unified framework.

Inventive Principle:
Principle #5Merging (Combining)

Data Source

PatentUS11086779B2System and method of a highly concurrent cache replacement algorithm
Publication Date: 2021.08.10 VMWARE INC
  • US11086779B2 patent drawing
  • US11086779B2 patent drawing
  • US11086779B2 patent drawing

AI summary

Disclosed are a method and system for managing multi-threaded concurrent access to a cache data structure. The cache data structure includes a hash table and three queues. The hash table includes a list of elements for each hash bucket with each hash bucket containing a mutex object and elements in each of the queues containing lock objects. Multiple threads can each lock a different hash bucket to have access to the list, and multiple threads can each lock a different element in the queues. The locks permit highly concurrent access to the cache data structure without conflict. Also, atomic operations are used to obtain pointers to elements in the queues so that a thread can safely advance each pointer. Race conditions that are encountered with locking an element in the queues or entering an element into the hash table are detected, and the operation encountering the race condition is retried.