Dynamic Library Profiling via Breakpoint PMU Counting
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional library function profiling methods are intrusive, require recompiling, and produce inaccurate results due to context switching in time sharing systems, especially when profiling dynamically loaded library functions or functions called from other library functions.
Innovation Solution
A dynamic library profiling method that sets break points at the start and return addresses of library functions to measure Performance Measurement Unit (PMU) event counts, allowing for accurate and non-intrusive profiling of dynamic library functions, including those loaded at runtime and called from other library functions, by using a process scheduler to manage PMU counts independently for each process.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If conventional library function profiling methods are used, then profiling coverage is achieved, but the methods are intrusive and require recompiling
Solution Approach 1:
The patent introduces a dynamic linker as an intermediary component that sits between the executable file and the dynamic library functions. The dynamic linker intercepts function calls and redirects them through profiling code, enabling non-intrusive profiling without requiring modifications to the target library functions or recompilation. This mediator approach allows the profiling system to collect performance data while maintaining the original execution flow.
2Measurement precision
If conventional profiling methods are used, then some performance data is collected, but results are inaccurate due to context switching in time sharing systems
Solution Approach 1:
The patent performs preliminary actions by saving the current PMU counter values at the entry point of library functions and restoring them at the return point. This preliminary saving and restoration mechanism ensures that context switching during the function execution does not corrupt the performance measurement. The system captures the PMU state before the function call and restores it after, effectively isolating the measurement from external interruptions.
3Adaptability or versatility
If dynamic library functions are profiled, then runtime flexibility is achieved, but profiling becomes more difficult due to dynamic loading
Solution Approach 1:
The patent creates a universal profiling solution that handles multiple types of function calls through a single dynamic linker interface. The dynamic linker is designed to work with any dynamically loaded library function, regardless of when it is loaded or what type of function it is. This multi-functional approach unifies the profiling mechanism to handle both statically linked and dynamically linked functions through the same interception and redirection framework.
Data Source
Figure 1
Figure 2
Figure 3
AI summary
A dynamic library profiling method and a dynamic library profiling system including writing a first break point instruction at a start address of a dynamic library function, recording a first event count value that is a process performance management unit (PMU) count when a target process executes the first break point instruction, writing a second break point instruction to a return address of the dynamic library function, and calculating a PMU count generated in a processor core while the dynamic library function is executed, by comparing the recorded first event count value with a second event count value that is a process PMU count when the target process executes the second break point instruction, wherein the process PMU count is a cumulative value of PMU counts generated in the processor core while the target process is executed.