Nested Conditional Check Instrumentation for Accurate PGO

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current profile-guided optimization (PGO) techniques for nested conditional checks are insufficient in accurately determining the execution frequency of inner conditional checks, leading to suboptimal code optimization decisions.

Innovation Solution

The method involves duplicating inner conditional checks and placing them before the original nested conditional checks in the program code, allowing for the collection of execution frequency data that is not otherwise available, thereby enhancing the accuracy of optimization decisions during the recompilation phase.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If current PGO instrumentation techniques are used for nested conditional checks, then the instrumentation is simple to implement, but the execution frequency data collected is inaccurate

Engineering Contradiction:
Improveexecution frequency data accuracyVSAvoidinstrumentation complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The patent segments the nested conditional check structure by introducing separate instrumentation for outer and inner checks. Each conditional check is instrumented independently with dedicated counters, allowing accurate measurement of execution frequencies at different nesting levels without requiring complex unified instrumentation.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent introduces intermediary basic blocks and counter variables that mediate between the nested conditional checks and the profile data collection. These intermediary elements facilitate accurate frequency measurement by capturing execution paths separately before aggregation, resolving the complexity-accuracy tradeoff.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If instrumentation is added to collect nested conditional check frequencies, then optimization decisions improve, but the program execution time during profiling increases

Engineering Contradiction:
Improveoptimization decision qualityVSAvoidprofiling execution time
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent performs preliminary instrumentation during the compilation phase, preparing counter variables and instrumentation code before execution. This allows the profiling phase to collect data efficiently without repeated compilation overhead, improving optimization quality while minimizing runtime penalty.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent changes the parameter of instrumentation granularity by selectively instrumenting only nested conditional checks rather than all program statements. This parameter optimization reduces the overhead of frequency collection while maintaining sufficient data quality for effective optimization decisions.

Inventive Principle:
Principle #35Parameter changes

3Loss of information

If duplicate conditional checks are inserted for instrumentation, then execution frequency metadata is obtained, but the instrumented code size increases

Engineering Contradiction:
Improvemetadata completenessVSAvoidcode size
Core Design Contradiction:
Loss of informationVSQuantity of substance

Solution Approach 1:

The patent uses copying by creating lightweight duplicate basic blocks that contain only the conditional check and associated counter increment operations. These copied blocks are minimal in size compared to full function duplicates, providing necessary metadata while minimizing code size increase.

Inventive Principle:
Principle #26Copying

Solution Approach 2:

The patent applies partial action by instrumenting only the specific nested conditional checks that benefit from profile-guided optimization, rather than duplicating or instrumenting entire functions or modules. This selective approach obtains necessary metadata while avoiding excessive code size growth.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS11561778B1Instrumentation for nested conditional checks
Publication Date: 2023.01.24 INTERNATIONAL BUSINESS MACHINE CORPORATION
  • US11561778B1 patent drawing
  • US11561778B1 patent drawing
  • US11561778B1 patent drawing

AI summary

Aspects include executing a first phase that includes injecting instrumentation into program code in response to identifying an inner conditional check in the program code and running the instrumented program with a representative workload. The injecting includes duplicating the inner conditional check and placing a duplicate of the inner conditional check before a respective original nested conditional check in the program code to create an instrumented program. The instrumented program includes a plurality of basic blocks including original basic blocks and a newly added basic block that includes the duplicate of the inner conditional check. The method also includes executing a second phase that includes collecting execution frequency values from counters associated with the basic blocks to form metadata used to make optimization decisions for the program code.