Compiler Hot Function Cloning for Multiversioned Dispatch

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing compiler technologies face inefficiencies due to the overhead of dispatch checks in function multiversioning, which limits optimization and increases runtime overhead, especially for frequently executed functions.

Innovation Solution

The method involves cloning hot functions and hoisting dispatch checks out of them, allowing for direct calls to alternative versions of multiversioned functions, thereby reducing runtime overhead and enabling optimizations across function call boundaries.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If function multiversioning is implemented with dispatch checks at runtime, then platform capability optimization is achieved, but runtime overhead increases

Engineering Contradiction:
Improveplatform capability optimizationVSAvoidruntime overhead
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The compiler performs preliminary analysis to identify hot functions (frequently executed functions) that call multiversioned functions. By pre-determining which functions are hot and need cloning, the system prepares optimized code paths in advance, avoiding the need for runtime dispatch checks in frequently executed code paths.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The invention segments the code by cloning hot functions into separate versions (first clone and second clone) that each directly call specific versions of the multiversioned function. This segmentation eliminates the need for a single unified dispatch mechanism, allowing each cloned function to have direct, platform-specific calls without runtime overhead.

Inventive Principle:
Principle #1Segmentation

2Reliability

If dispatch checks are performed at runtime for each function call, then correct version selection is ensured, but code optimization is limited

Engineering Contradiction:
Improveversion selection accuracyVSAvoidcode optimization efficiency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The compiler performs preliminary analysis to identify hot functions (frequently executed functions) that call multiversioned functions. By pre-determining which functions are hot and need cloning, the system prepares optimized code paths in advance, avoiding the need for runtime dispatch checks in frequently executed code paths.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The invention creates copies (clones) of hot functions that directly call specific versions of multiversioned functions. These clones are identical to the original function except for their direct call to a specific version, eliminating the need for runtime dispatch checks while maintaining correct version selection for each code path.

Inventive Principle:
Principle #26Copying

3Adaptability or versatility

If multiple versions of functions are generated for different platforms, then platform-specific optimization is achieved, but executable file size increases

Engineering Contradiction:
Improveplatform-specific optimizationVSAvoidexecutable file size
Core Design Contradiction:
Adaptability or versatilityVSWeight of stationary object

Solution Approach 1:

The invention applies local quality by selectively cloning only hot functions (those that are frequently executed and call multiversioned functions) rather than cloning all functions. This localized approach to multiversioning reduces the overall code size while still providing platform-specific optimization for the most critical code paths.

Inventive Principle:
Principle #3Local quality

Solution Approach 2:

Instead of generating complete multiversioned copies of all functions in the program, the system performs partial multiversioning by only cloning hot functions that require platform-specific optimization. This partial action reduces the executable file size while maintaining the benefits of platform-specific optimization for the most important functions.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS9081587B1Multiversioned functions
Publication Date: 2015.07.14 GOOGLE LLC
  • US9081587B1 patent drawing
  • US9081587B1 patent drawing
  • US9081587B1 patent drawing

AI summary

Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for receiving source code that contains a hot function that calls a multiversioned function, where a function definition of the multiversioned function specifies a first version and an alternative second version, and generating compiled code that includes a first and a second clone of the hot function, and a first and a second version of the multiversioned function. In the compiled code, the first clone of the hot function includes a direct call to the first version of the multiversioned function, and the second clone of the hot function includes a direct call to the second version of the multiversioned function.