Random Branch Instrumentation via Performance Counter Interrupts

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing methods for collecting dynamic behavior information of software applications are inefficient, leading to significant overhead and increased execution time due to the need for extensive instrumentation code, which can take days or weeks to run, and sampling methods consume time and resources.

Innovation Solution

A computing system that uses a performance counter to generate interrupts when a threshold is reached, allowing for the execution of instrumentation code only at specific 'random branch' instructions, thereby reducing unnecessary code execution and optimizing instrumentation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If instrumentation code is added to collect dynamic behavior information, then measurement precision is improved, but execution time increases significantly

Engineering Contradiction:
Improvedynamic behavior information collectionVSAvoidexecution time
Core Design Contradiction:
Measurement precisionVSLoss of time

Solution Approach 1:

The patent applies partial action by selectively executing instrumentation code only at specific branch instructions rather than at every instruction. The system inserts instrumentation code at branch instructions and uses sampling logic to determine whether to execute the instrumentation based on a random value comparison, thereby collecting sufficient dynamic behavior information while avoiding the overhead of universal instrumentation execution.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The patent implements periodic sampling by using a random value stored in a performance counter that is periodically compared against a threshold. The sampling decision is made periodically at branch instructions rather than continuously, allowing the system to collect dynamic behavior information at representative intervals without constantly executing instrumentation code.

Inventive Principle:
Principle #19Periodic action

2Productivity

If sampling is used to reduce instrumentation overhead, then execution time is reduced, but sampling decision process consumes time and resources

Engineering Contradiction:
Improveinstrumentation efficiencyVSAvoidsampling decision time
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent applies self-service by using the processor's existing performance counter hardware to generate and manage the random sampling value. The performance counter automatically increments and can be compared against a threshold without requiring external random number generation hardware or complex software-based sampling logic, thereby minimizing the overhead of the sampling decision process.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The patent leverages the multi-functionality of the performance counter hardware, which is originally designed for performance measurement, and repurposes it for random sampling decisions. This existing hardware structure is used to both count performance events and provide the random value for sampling, eliminating the need for dedicated sampling hardware or software.

Inventive Principle:
Principle #6Universality (Multi-functionality)

3Adaptability or versatility

If random number generation is performed in software, then flexibility is maintained, but processing overhead increases

Engineering Contradiction:
Improvesampling flexibilityVSAvoidprocessing speed
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The patent replaces software-based random number generation with hardware-based generation using the performance counter. The performance counter hardware automatically provides random values through its increment and wrap-around behavior, substituting the mechanical/software random generation process with a hardware mechanism that operates faster and with minimal overhead.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

4Productivity

If hardware random number generation is implemented, then processing speed is improved, but device complexity increases

Engineering Contradiction:
Improvesampling speedVSAvoidhardware circuitry
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent avoids increasing device complexity by reusing existing performance counter hardware for dual purposes: traditional performance measurement and random sampling generation. No additional random number generation hardware is required because the performance counter's inherent behavior provides the necessary random values, thereby maintaining sampling speed improvement without adding hardware complexity.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentUS9448909B2Randomly branching using performance counters
Publication Date: 2016.09.20 ADVANCED MICRO DEVICES INC
  • US9448909B2 patent drawing
  • US9448909B2 patent drawing
  • US9448909B2 patent drawing

AI summary

A system and method for efficiently performing program instrumentation. A processor processes instructions stored in a memory. When the processor processes a given instruction of a given instruction type, the processor updates a corresponding performance counter. When the performance counter reaches a threshold, the processor generates an interrupt and compares a location of the given instruction with stored locations in a given list. If a match is not found, then the processor processes an instruction following the given instruction in the computer program without processing intermediate instrumentation code. If a match is found, then the processor processes instrumentation code. Regardless of whether or not the instrumentation code is processed, when control flow returns to the computer program, the corresponding performance counter is initialized with a random value.