Critical Section Prediction for Lock Elision

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Critical sections in multi-threaded applications lead to performance reduction due to lock contention and the cost of acquiring and releasing locks, with existing speculative locking mechanisms being ineffective for large critical sections and prone to misspeculation.

Innovation Solution

A method for predicting critical sections using a Critical Section Predictor (CSP) and Active Critical Section Table (ACST) to dynamically identify and elide locks, updating the CSP based on historical analysis of atomic/store instruction pairs and using short section indicators to avoid lock elision in long critical sections.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If speculative locking is used to elide locks in critical sections, then lock contention is reduced and performance is improved, but misspeculation occurs leading to incorrect execution and requiring re-execution

Engineering Contradiction:
ImproveperformanceVSAvoidspeculation accuracy
Core Design Contradiction:
ProductivityVSReliability

Solution Approach 1:

The patent applies preliminary action by performing historical analysis of atomic/store instruction pairs before executing speculative lock elision. The Critical Section Predictor (CSP) and Active Critical Section Table (ACST) pre-characterize critical sections during runtime, storing historical data about lock usage patterns. This preliminary characterization allows the system to make informed speculation decisions, reducing misspeculation while maintaining performance benefits.

Inventive Principle:
Principle #10Preliminary action

2Loss of time

If lock elision is applied to all critical sections, then lock acquisition overhead is eliminated, but long critical sections cause buffer overflow and execution errors

Engineering Contradiction:
Improvelock acquisition timeVSAvoidexecution correctness
Core Design Contradiction:
Loss of timeVSReliability

Solution Approach 1:

The patent applies local quality by differentiating between short and long critical sections using the short section indicator (SSI). The SSI tracks the length of critical sections during runtime, and the system applies lock elision selectively based on this local characteristic. Short critical sections that fit within buffer constraints are eligible for elision, while long critical sections are excluded, preventing buffer overflow errors.

Inventive Principle:
Principle #3Local quality

3Ease of manufacture

If coarse-grain locking is used to protect larger amounts of data, then the amount of locking required is reduced and code correctness is easier to maintain, but lock contention increases

Engineering Contradiction:
Improvecode correctnessVSAvoidlock contention
Core Design Contradiction:
Ease of manufactureVSProductivity

Solution Approach 1:

The patent applies dynamics by transitioning from static coarse-grain locking to dynamic speculative lock elision. The system dynamically determines at runtime whether to apply lock elision based on historical characteristics stored in the CSP and ACST. This dynamic approach allows the system to maintain coarse-grain locking where it provides correctness benefits while eliminating locks in sections where speculation is safe, thereby reducing lock contention.

Inventive Principle:
Principle #15Dynamics

4Speed

If spin waiting is used to continuously check lock availability, then the thread can quickly acquire the lock when available, but valuable processing cycles are wasted

Engineering Contradiction:
Improvelock acquisition speedVSAvoidprocessing cycle utilization
Core Design Contradiction:
SpeedVSUse of energy by moving object

Solution Approach 1:

The patent applies the taking out principle by removing the lock acquisition check from the critical path through speculative lock elision. Instead of continuously checking lock availability through spin waiting, the system extracts the lock acquisition operation entirely for eligible critical sections. The CSP and ACST enable the system to identify sections where locks can be safely elided, eliminating spin waiting and freeing processing cycles for useful work.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS7930694B2Method and apparatus for critical section prediction for intelligent lock elision
Publication Date: 2011.04.19 ORACLE AMERICAN INC
  • US7930694B2 patent drawing
  • US7930694B2 patent drawing
  • US7930694B2 patent drawing

AI summary

Intelligent prediction of critical sections is implemented using a method comprising updating a critical section estimator based on historical analysis of atomic/store instruction pairs during runtime and performing lock elision when the critical section estimator indicates that the atomic/store instruction pairs define a critical section.