Instruction Cache Prefetching for Branch Heavy Applications

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Traditional hardware prefetching techniques are ineffective in predicting instruction execution order in large commercial applications with many branch points, leading to high instruction cache misses and significant execution delays.

Innovation Solution

A system and method that profiles application code to identify 'hot' code regions likely to experience instruction cache misses, linearizes the code into execution traces, and inserts prefetch instructions based on estimated execution times to ensure timely prefetching of instructions into the cache.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Measurement precision

If traditional hardware prefetching techniques are used, then the system can attempt to predict future instructions, but it fails to accurately predict instruction execution order in applications with many branch points, resulting in high instruction cache misses

Engineering Contradiction:
Improveinstruction execution prediction accuracyVSAvoidinstruction cache hit rate
Core Design Contradiction:
Measurement precisionVSReliability

Solution Approach 1:

The system performs preliminary profiling of application code to identify 'hot' code regions that are likely to be executed frequently. Based on this advance analysis, prefetch instructions are strategically inserted before these hot regions to load instructions into cache before they are needed, rather than relying on runtime hardware prediction. This preliminary action ensures instructions are available when needed, resolving the contradiction between prediction accuracy and cache hit rate.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The application code is segmented into execution traces and further divided into chunks, with each chunk analyzed independently to determine prefetch requirements. By segmenting the code and applying targeted prefetching to specific hot regions rather than attempting to predict the entire instruction stream, the system improves both prediction accuracy for critical regions and overall cache hit rate.

Inventive Principle:
Principle #1Segmentation

2Productivity

If instructions are fetched from main memory when cache misses occur, then the application can continue execution, but execution speed significantly decreases due to the time required to retrieve instructions

Engineering Contradiction:
Improveapplication execution speedVSAvoidinstruction cache miss penalty
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

Prefetch instructions are inserted into the code to load instruction chunks into cache before they are needed for execution. By performing this data movement in advance, the system eliminates the time penalty associated with cache misses, as instructions are already available in cache when the processor needs them, maintaining execution speed without sacrificing productivity.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system takes preliminary action to prevent cache misses by prefetching instructions before they are needed. This anti-action counteracts the potential harm of cache misses by ensuring instructions are already in cache, thereby preventing the execution delays that would otherwise occur when instructions must be fetched from main memory.

Inventive Principle:
Principle #9Preliminary anti-action

3Reliability

If the instruction cache size is increased to hold more application instructions, then cache hit rate improves, but the cost and complexity of the system increases

Engineering Contradiction:
Improveinstruction cache hit rateVSAvoidinstruction cache size
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

Instead of increasing cache size to improve hit rate, the system extracts and prefetches only the critical 'hot' code regions into cache. By identifying and selectively loading only the frequently executed instruction chunks, the system maintains high cache hit rates with a smaller cache, avoiding the increased complexity and cost associated with larger cache structures.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The system applies different strategies to different parts of the code: hot regions receive prefetch instructions to ensure they are loaded into cache, while cold regions rely on traditional caching. This localized approach optimizes cache utilization for critical regions without requiring a uniformly large cache, thereby maintaining high hit rates with reduced overall cache size and complexity.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS8978022B2Reducing instruction miss penalties in applications
Publication Date: 2015.03.10 ORACLE INT CORP
  • US8978022B2 patent drawing
  • US8978022B2 patent drawing
  • US8978022B2 patent drawing

AI summary

Embodiments include systems and methods for reducing instruction cache miss penalties during application execution. Application code is profiled to determine “hot” code regions likely to experience instruction cache miss penalties. The application code can be linearized into a set of traces that include the hot code regions. Embodiments traverse the traces in reverse, keeping track of instruction scheduling information, to determine where an accumulated instruction latency covered by the code blocks exceeds an amount of latency that can be covered by prefetching. Each time the accumulated latency exceeds the amount of latency that can be covered by prefetching, a prefetch instruction can be scheduled in the application code. Some embodiments insert additional prefetches, merge prefetches, and/or adjust placement of prefetches to account for scenarios, such as loops, merging or forking branches, edge confidence values, etc.