Dynamic Array Representation Conversion for Runtime Type Optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Dynamically-typed languages face challenges in efficiently representing and manipulating double-precision floating-point values due to unknown types at runtime, leading to suboptimal memory usage and performance when using 'raw' storage formats.

Innovation Solution

The method involves tracking the representation format and packing status of arrays in dynamically-typed programming languages, allowing for conversion between different formats (small integer, double value, or tagged) based on element types and operations, thereby optimizing memory usage and performance by auto-unboxing double arrays.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Quantity of substance

If dynamically-typed languages use raw storage format for double values, then memory usage is reduced, but performance deteriorates due to unknown types at runtime

Engineering Contradiction:
Improvememory usageVSAvoidperformance
Core Design Contradiction:
Quantity of substanceVSProductivity

Solution Approach 1:

The patent implements dynamic type representation where the storage format of array elements is not fixed but adapts at runtime based on the actual element types. The system tracks element kinds (small integer, double value, or tagged) and converts storage formats dynamically, allowing the same array structure to optimize for both memory efficiency and performance based on runtime type information.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The patent changes the representation parameter of array elements from a static format to a dynamic format that can switch between different representations (boxed vs unboxed, different element kinds). This parameter change allows the system to select the most efficient storage format based on runtime type analysis, resolving the contradiction between memory efficiency and performance.

Inventive Principle:
Principle #35Parameter changes

2Reliability

If dynamically-typed languages use boxed representation for all values, then type safety is maintained, but memory consumption increases

Engineering Contradiction:
Improvetype safetyVSAvoidmemory consumption
Core Design Contradiction:
ReliabilityVSQuantity of substance

Solution Approach 1:

The patent applies different storage representations to different parts of the array based on local type characteristics. Instead of uniformly boxing all values, the system identifies regions with homogeneous element kinds and applies specialized unboxed representations (small integer, double value) to those specific regions while maintaining boxed representation only where necessary for type safety.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

The patent segments the array into different element kind regions (small integer elements, double value elements, tagged elements) and applies different storage formats to each segment. This segmentation allows the system to maintain type safety through proper representation tracking while reducing overall memory consumption by using efficient unboxed formats for homogeneous segments.

Inventive Principle:
Principle #1Segmentation

3Productivity

If the compiler generates efficient code for raw storage, then performance is improved, but adaptability to different types at runtime is reduced

Engineering Contradiction:
ImproveperformanceVSAvoidadaptability to types
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The patent makes the code generation process dynamic by incorporating runtime type information into compilation decisions. The compiler generates code that can adapt its storage format and access patterns based on the actual element kinds discovered at runtime, allowing efficient unboxed code generation for specific types while maintaining the ability to handle type variations through dynamic conversion mechanisms.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentEP2856312B1Representation and conversion of dynamically-typed arrays
Publication Date: 2019.11.13 GOOGLE LLC
  • EP2856312B1 patent drawingFigure 1
  • EP2856312B1 patent drawingFigure 2
  • EP2856312B1 patent drawingFigure 3

AI summary

Representation of an array in dynamically-typed program code at runtime is provided. Program code is accessed at runtime. An instruction for adding, updating or deleting one or more elements for an array is detected within the code. The array is associated with a first kind of element comprising a first representation and packing format. A second kind of element is determined based on at least one of the instruction or the one or more elements, the second kind of element comprising at least one of a second representation or packing format. A determination is made that the first and second kind of elements are not consistent, based on an inconsistency between the first and second representation formats or packing formats. The array is converted so that the first and second kind of elements are consistent. One or more array elements are added, updated or deleted based on the instruction.