Stub-Based Algorithm Switching for Zero Overhead Performance

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Dynamic switching between different implementations of functions in performance-critical regions of code incurs significant overhead due to indirect calls and conditional branching, leading to performance degradation in applications like operating systems and disk drivers.

Innovation Solution

A stub of code is placed at the entry-point of time-critical functions to determine the appropriate implementation and patch the application to make direct calls, eliminating the need for dynamic switching and reducing overhead by removing additional layers of indirection.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If dynamic switching between different algorithm implementations is implemented, then adaptability is improved, but execution time increases due to overhead

Engineering Contradiction:
Improveability to switch between algorithmsVSAvoidexecution time
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

The system performs the algorithm selection decision in advance during the first call, patches the caller's code to store the selected implementation address, and eliminates the need for repeated dynamic switching. This preliminary action converts a repeated time-consuming operation into a one-time operation, resolving the contradiction between adaptability and execution time.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The invention creates a stub function that copies the selected implementation address into the caller's code structure (import table or direct call location). This copying mechanism allows the system to retain the ability to switch algorithms while eliminating the overhead of repeated indirect calls, as the caller directly invokes the selected implementation without going through the stub again.

Inventive Principle:
Principle #26Copying

2Adaptability or versatility

If indirect calls through modular code are used, then code reusability is improved, but performance deteriorates due to additional overhead

Engineering Contradiction:
Improvecode reusabilityVSAvoidperformance
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The stub function serves as an intermediary that performs the algorithm selection and stores the result in the caller's code. After the first call through the stub, the caller's code is patched to call the selected implementation directly, eliminating subsequent indirect calls. This intermediary approach maintains code reusability while removing performance penalties.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The invention separates the algorithm selection logic (in the stub) from the algorithm implementations (in modular code). The stub handles the adaptability requirement by selecting between different algorithm modules, while the patched caller code directly invokes the selected implementation, avoiding repeated segmentation overhead from indirect calls.

Inventive Principle:
Principle #1Segmentation

3Adaptability or versatility

If conditional branches for dynamic switching are implemented, then flexibility is improved, but processor efficiency worsens due to branch mispredictions

Engineering Contradiction:
Improvedynamic switching capabilityVSAvoidprocessor efficiency
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The conditional branch for algorithm selection is executed only once during the first call through the stub. The result is stored in the caller's code structure, eliminating the need for repeated conditional branches. This preliminary evaluation removes the source of branch mispredictions from subsequent executions, resolving the contradiction between flexibility and processor efficiency.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS7415702B1Method for zero overhead switching of alternate algorithms in a computer program
Publication Date: 2008.08.19 UNISYS CORP
  • US7415702B1 patent drawing
  • US7415702B1 patent drawing
  • US7415702B1 patent drawing

AI summary

A system wherein a Caller Application is enabled to reduce latency after a First Call to a Data Link Library after which a stub function provides direct access to a selected algorithm's work function for execution by a processor. A Hardware Abstraction Layer receives information from multiple CPU's to determine the appropriately compatible algorithm for the processor that is to be utilized.