Non-Overwritable Variable for Thread Visibility

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Concurrent threads or processes may not have visibility to the latest value assigned to a shared field due to instruction reordering by compilers and CPUs adhering to the Java Language Specification, leading to penalties in garbage collection and memory latency when using 'final' or 'volatile' attributes.

Innovation Solution

Inserting a declaration of a non-overwritable variable pointing to a current object in the source code and storing a value referencing the current object to ensure visibility without creating new objects, thereby avoiding reordering issues and associated overhead.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a 'final' attribute is associated with a shared field to ensure visibility, then thread visibility is improved, but garbage collection overhead increases due to creation of new objects to replace the final field

Engineering Contradiction:
Improvethread visibilityVSAvoidgarbage collection overhead
Core Design Contradiction:
ReliabilityVSLoss of energy

Solution Approach 1:

The patent extracts the visibility guarantee mechanism from the object replacement approach. Instead of creating new objects to replace final fields, the invention uses a separate non-overwritable variable that holds a reference to the current object, allowing visibility without object creation overhead.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent introduces a non-overwritable variable as an intermediary between the shared field and the object reference. This intermediary variable ensures visibility of the current object reference to threads without requiring the actual object to be recreated, thus eliminating garbage collection overhead while maintaining reliability.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Reliability

If a 'volatile' attribute is associated with a shared field to ensure visibility, then thread visibility is improved, but memory latency increases due to required reading of the volatile field

Engineering Contradiction:
Improvethread visibilityVSAvoidmemory access speed
Core Design Contradiction:
ReliabilityVSSpeed

Solution Approach 1:

The patent extracts the visibility guarantee from the volatile field reading requirement. By using a non-overwritable variable to store the object reference, the invention eliminates the need for repeated volatile reads while maintaining thread visibility, thus improving memory access speed.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies preliminary action by storing the object reference in the non-overwritable variable during object creation. This preliminary storage ensures that the reference is available to threads without requiring subsequent volatile reads, reducing memory latency while maintaining visibility guarantees.

Inventive Principle:
Principle #10Preliminary action

3Speed

If instruction reordering is allowed by compiler and CPU to optimize performance, then execution speed is improved, but visibility of latest field values is compromised

Engineering Contradiction:
Improveexecution speedVSAvoidfield value visibility
Core Design Contradiction:
SpeedVSReliability

Solution Approach 1:

The patent uses the non-overwritable variable as an intermediary that prevents instruction reordering from compromising visibility. The special properties of this variable ensure that assignments to it maintain ordering guarantees, allowing the compiler and CPU to optimize other instructions while preserving visibility of the latest object reference.

Inventive Principle:
Principle #24Intermediary (Mediator)

Data Source

PatentUS8930893B2Initialization safety
Publication Date: 2015.01.06 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US8930893B2 patent drawing
  • US8930893B2 patent drawing
  • US8930893B2 patent drawing

AI summary

Embodiments of the disclosure are directed to inserting a declaration of a non-overwritable variable pointing to a current object in a source code, and inserting a code of storing a value referencing the current object to the non-overwritable variable. Embodiments of the disclosure are directed to converting a source code to generate a shared object in a lock-free mode by inserting a declaration of a non-overwritable variable pointing to a current object in the source code, and inserting a code of storing a value referencing the current object to the non-overwritable variable.