Difference between revisions of "Memory Operations Tracker Probe"
(Created page with "== Memory Operations Tracker Probe: memoptb.ual == (Since 4.5.3). The '''memoptb.ual''' predefined probe tracks the use of memory operations (move, compare, set, ...) within...") |
m |
||
(9 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
Memory operation tracking allows you to determine where there may be hidden "slow" operations in your application. The memory operation tracking information can be used to locate where generated code may be slow in your application. | Memory operation tracking allows you to determine where there may be hidden "slow" operations in your application. The memory operation tracking information can be used to locate where generated code may be slow in your application. | ||
+ | Check out the other memory probes: [[Memstat_Predefined_Probe|'''memstat.ual''']], [[Memleak_Predefined_Probe|'''memleak.ual''']], [[Memcheck_Tracker_Probe|'''memcheck.ual''']] and [[Memwatch_Predefined_Probe|'''memwatch.ual''']]. | ||
=== Usage === | === Usage === | ||
− | This probe is applied at run time using [[AUG_Tools_Reference#aprobe|aprobe]] as described under [[#Profile UAL Parameters|Profile UAL Parameters]] below. Memory operation tracking data will be collected for the standard memory functions: memmove, memcpy, memcmp, memset, bzero. This probe is also capable of tracking memory operations which have been converted to string instructions on Linux x86/x86_64 and calls to AIX low-core | + | This probe is applied at run time using [[AUG_Tools_Reference#aprobe|aprobe]] as described under [[#Profile UAL Parameters|Profile UAL Parameters]] below. Memory operation tracking data will be collected for the standard memory functions: memmove, memcpy, memcmp, memset, bzero. This probe is also capable of tracking memory operations which have been converted to string instructions on Linux x86/x86_64 and calls to AIX low-core millicode functions. |
− | The memory operation tracking information is logged to the APD file for later processing by [[AUG_Tools_Reference#apformat|apformat]]. At format time a report is generated detailing where memory operation points are located and sorted by size and number. The memory operation points are organized by unique traceback paths. | + | The memory operation tracking information is collected during runtime and logged to the APD file at program termination for later processing by [[AUG_Tools_Reference#apformat|apformat]]. At format time a report is generated detailing where memory operation points are located and sorted by size and number. The memory operation points are organized by unique traceback paths. |
− | The default parameters will track | + | The default parameters will track memory operation sizes greater than 1000 bytes, but upper and lower buonds can be set to focus on specific sizes (and reduce the amount of collected data). Instrumentation of x86/x86_64 string instructions and AIX low-core millicode is on by default for the application module but can be turned off or enabled for other modules. |
=== UAL Parameters === | === UAL Parameters === | ||
Line 24: | Line 25: | ||
where param_list may include: | where param_list may include: | ||
− | ; '''- | + | ; '''-addr path''' |
− | : don't | + | : instrument only addresses in the file. (For debugging.) |
+ | ; '''-D''' | ||
+ | : don't enable tracking at program start [FALSE] | ||
; '''-d Depth''' | ; '''-d Depth''' | ||
: traceback depth [9] | : traceback depth [9] | ||
− | ; '''- | + | ; '''-exc path''' |
− | : | + | : do not instrument functions named in the file. (For debugging.) |
+ | ; '''-f''' | ||
+ | : summarize at format time not runtime [FALSE] | ||
+ | ; '''-h''' | ||
+ | : print this message | ||
; '''-i''' | ; '''-i''' | ||
: report tracebacks inline in the tables | : report tracebacks inline in the tables | ||
+ | ; '''-inc path''' | ||
+ | : instrument only functions named in the file. (For debugging.) | ||
+ | ; '''-ins path''' | ||
+ | : write instrumented locations to the file. (For debugging.) | ||
; '''-I''' | ; '''-I''' | ||
− | : don't instrument string instructions | + | : don't instrument x86/_64 string instructions or AIX low-core calls [FALSE] |
; '''-l LowerBound''' | ; '''-l LowerBound''' | ||
− | : lower bound size cut off for operations; larger operations will be tracked [ | + | : lower bound size cut off for operations; larger operations will be tracked [1000] |
− | ; '''- | + | ; '''-off path''' |
− | : | + | : instrument only offset in function listed in file. Use with -inc to name the function(s). (For debugging.) |
− | ; '''- | + | ; '''-S SigNum''' |
− | : don't | + | : use signal SigNum to enable/disable tracking [0] |
+ | ; '''-T kind''' | ||
+ | : don't report the operation kind (move, set, tmp, zero, fill) | ||
+ | ; '''-trap''' | ||
+ | : use trap patching on x86/_64 for string instruction instrumentation | ||
; '''-u UpperBound''' | ; '''-u UpperBound''' | ||
− | : upper bound size cut off for operations; smaller operations will be tracked [ | + | : upper bound size cut off for operations; smaller operations will be tracked [0] |
− | ; '''- | + | ; '''-v''' |
− | : | + | : print progress messages [FALSE] |
+ | ; '''-w secs''' | ||
+ | : wait secs seconds before tracking. [0] | ||
; '''[module ...]''' | ; '''[module ...]''' | ||
− | : modules to instrument for string instructions or low-core calls | + | : modules to instrument for string instructions or low-core calls [application module] |
+ | === Examples === | ||
+ | |||
+ | The following would track memory operations 1000 bytes or larger in the application module: | ||
+ | <pre> | ||
+ | aprobe -u memooptb main.exe | ||
+ | </pre> | ||
+ | |||
+ | The following will track memory operations between 40 and 50 bytes in two shared libraries: | ||
+ | <pre> | ||
+ | aprobe -u memooptb -p "-l 40 -u 50 my_shared_libary1.so my_shared_libary2.so" main.exe | ||
+ | </pre> | ||
+ | |||
+ | === Memoptb API === | ||
+ | |||
+ | You can control the behavior of the <code>memoptb.ual</code> probe by calls from within your own probes. The API for the <code>memoptb.ual</code> probe is defined as follows: | ||
+ | <pre> | ||
+ | extern void ap_Memoptb_Enable(); | ||
+ | extern void ap_Memoptb_Disable(); | ||
+ | </pre> | ||
+ | You can define a trigger probe like this: | ||
+ | <pre> | ||
+ | // You must define these. | ||
+ | extern void ap_Memoptb_Enable(); | ||
+ | extern void ap_Memoptb_Disable(); | ||
+ | |||
+ | probe thread | ||
+ | { | ||
+ | probe "MyFunc" | ||
+ | { | ||
+ | // turn on tracking on entry, and off on exit. | ||
+ | on_entry { ap_Memoptb_Enable(); ] | ||
+ | on_exit { ap_Memoptb_Disble(); ] | ||
+ | } | ||
+ | } | ||
+ | </pre> | ||
+ | You would compile your trigger probe (in <code>trigger.apc</code>) as follows: | ||
+ | <pre> | ||
+ | apc -g -x my_app.exe trigger.apc memoptb.ual | ||
+ | </pre> | ||
+ | And you would probably invoke the <code>memooptb.ual</code> probe with the <code>-D</code> option as follows: | ||
+ | <pre> | ||
+ | aprobe -u trigger -u memooptb -p "-D" my_app.exe | ||
+ | </pre> | ||
+ | Note that you must list <code>trigger.ual</code> first so that <code>memoptb.ual</code> can process its arguments. | ||
=== Memory Operation Tracker Performance Issues === | === Memory Operation Tracker Performance Issues === | ||
Line 52: | Line 113: | ||
See [[AUG_Predefined_Probes|Performance_Issues]] for a general discussion of factors that affect performance. | See [[AUG_Predefined_Probes|Performance_Issues]] for a general discussion of factors that affect performance. | ||
− | + | The instrumentation of modules for string instructions or low-core calls may require significant up-front processing, but if you need the information this is how to get it. | |
+ | The default mode of runtime summary collects memory operation information in a runtime table and will require more memory and processing at application runtime. You can choose format time summary, which only logs operations at runtime and builds the table at format time, but that will require larger APD sizes. Use the <code>-s</code> option to increase the size of App files, and use the <code>-n</code> option to increase the number of APD files in the APD ring. See [[AUG_Files_Reference#APD_file|APD File]] for more information. | ||
=== Memory Operations Tracker Report === | === Memory Operations Tracker Report === | ||
− | This is an example report Linux x86 with some standard memory operation functions and some x86 string instructions: | + | This is an example report on Linux x86 with some standard memory operation functions and some x86 string instructions: |
<nowiki> | <nowiki> |
Latest revision as of 18:32, 6 November 2023
Contents
Memory Operations Tracker Probe: memoptb.ual
(Since 4.5.3).
The memoptb.ual predefined probe tracks the use of memory operations (move, compare, set, ...) within an application program and shared libraries. The probe records the location, number, and size of memory operations. The tracking information is recorded as the application runs and is formatted to produce a report.
Memory operation tracking allows you to determine where there may be hidden "slow" operations in your application. The memory operation tracking information can be used to locate where generated code may be slow in your application.
Check out the other memory probes: memstat.ual, memleak.ual, memcheck.ual and memwatch.ual.
Usage
This probe is applied at run time using aprobe as described under Profile UAL Parameters below. Memory operation tracking data will be collected for the standard memory functions: memmove, memcpy, memcmp, memset, bzero. This probe is also capable of tracking memory operations which have been converted to string instructions on Linux x86/x86_64 and calls to AIX low-core millicode functions.
The memory operation tracking information is collected during runtime and logged to the APD file at program termination for later processing by apformat. At format time a report is generated detailing where memory operation points are located and sorted by size and number. The memory operation points are organized by unique traceback paths.
The default parameters will track memory operation sizes greater than 1000 bytes, but upper and lower buonds can be set to focus on specific sizes (and reduce the amount of collected data). Instrumentation of x86/x86_64 string instructions and AIX low-core millicode is on by default for the application module but can be turned off or enabled for other modules.
UAL Parameters
memoptb.ual is specified on the aprobe command line or in an APO file as described in Command Line. The specific options are:
aprobe -u memoptb.ual [-p "param-list"] your_program
where param_list may include:
- -addr path
- instrument only addresses in the file. (For debugging.)
- -D
- don't enable tracking at program start [FALSE]
- -d Depth
- traceback depth [9]
- -exc path
- do not instrument functions named in the file. (For debugging.)
- -f
- summarize at format time not runtime [FALSE]
- -h
- print this message
- -i
- report tracebacks inline in the tables
- -inc path
- instrument only functions named in the file. (For debugging.)
- -ins path
- write instrumented locations to the file. (For debugging.)
- -I
- don't instrument x86/_64 string instructions or AIX low-core calls [FALSE]
- -l LowerBound
- lower bound size cut off for operations; larger operations will be tracked [1000]
- -off path
- instrument only offset in function listed in file. Use with -inc to name the function(s). (For debugging.)
- -S SigNum
- use signal SigNum to enable/disable tracking [0]
- -T kind
- don't report the operation kind (move, set, tmp, zero, fill)
- -trap
- use trap patching on x86/_64 for string instruction instrumentation
- -u UpperBound
- upper bound size cut off for operations; smaller operations will be tracked [0]
- -v
- print progress messages [FALSE]
- -w secs
- wait secs seconds before tracking. [0]
- [module ...]
- modules to instrument for string instructions or low-core calls [application module]
Examples
The following would track memory operations 1000 bytes or larger in the application module:
aprobe -u memooptb main.exe
The following will track memory operations between 40 and 50 bytes in two shared libraries:
aprobe -u memooptb -p "-l 40 -u 50 my_shared_libary1.so my_shared_libary2.so" main.exe
Memoptb API
You can control the behavior of the memoptb.ual
probe by calls from within your own probes. The API for the memoptb.ual
probe is defined as follows:
extern void ap_Memoptb_Enable(); extern void ap_Memoptb_Disable();
You can define a trigger probe like this:
// You must define these. extern void ap_Memoptb_Enable(); extern void ap_Memoptb_Disable(); probe thread { probe "MyFunc" { // turn on tracking on entry, and off on exit. on_entry { ap_Memoptb_Enable(); ] on_exit { ap_Memoptb_Disble(); ] } }
You would compile your trigger probe (in trigger.apc
) as follows:
apc -g -x my_app.exe trigger.apc memoptb.ual
And you would probably invoke the memooptb.ual
probe with the -D
option as follows:
aprobe -u trigger -u memooptb -p "-D" my_app.exe
Note that you must list trigger.ual
first so that memoptb.ual
can process its arguments.
Memory Operation Tracker Performance Issues
See Performance_Issues for a general discussion of factors that affect performance.
The instrumentation of modules for string instructions or low-core calls may require significant up-front processing, but if you need the information this is how to get it.
The default mode of runtime summary collects memory operation information in a runtime table and will require more memory and processing at application runtime. You can choose format time summary, which only logs operations at runtime and builds the table at format time, but that will require larger APD sizes. Use the -s
option to increase the size of App files, and use the -n
option to increase the number of APD files in the APD ring. See APD File for more information.
Memory Operations Tracker Report
This is an example report on Linux x86 with some standard memory operation functions and some x86 string instructions:
Memory Operations Tracker Probe 4.5.2 (201023) Copyright 1993-2019 OC Systems, Inc. All rights reserved. For support/questions send mail to support@ocsystems.com. PID: 25235 - Summary of options Program start: Fri Oct 23 17:29:45.743505 2020 Options: TracebackDepth: 9 SizeLowerBound: 1000 SizeUpperBound: 0 Track Compares: 1 Track Fills: 1 Track Moves: 1 Track Sets: 1 Track Zeros: 1 Instrument Ins: 1 ------------------------------------------------------------------ Ops sorted by size: ------------------------------------------------------------------ TbkId | Op | NumOps | TotalOpSize | AvgOpSize ------------------------------------------------------------------ @8 MEMSET 1000 4000000 4000 @9 STOS 1000 4000000 4000 @10 STOS 1000 4000000 4000 @4 MOVS 1000 4000000 4000 @5 MOVS 1000 4000000 4000 @6 MOVS 1000 4000000 4000 @7 MEMSET 1000 4000000 4000 @2 MEMCMP 1000 4000000 4000 @3 MOVS 1000 4000000 4000 @1 MEMCMP 1000 4000000 4000 ------------------------------------------------------------------ Ops sorted by count: ------------------------------------------------------------------ TbkId | Op | NumOps | TotalOpSize | AvgOpSize ------------------------------------------------------------------ @8 MEMSET 1000 4000000 4000 @9 STOS 1000 4000000 4000 @10 STOS 1000 4000000 4000 @4 MOVS 1000 4000000 4000 @5 MOVS 1000 4000000 4000 @6 MOVS 1000 4000000 4000 @7 MEMSET 1000 4000000 4000 @2 MEMCMP 1000 4000000 4000 @3 MOVS 1000 4000000 4000 @1 MEMCMP 1000 4000000 4000 --------------------------------------------------------- Op traceback ids: --------------------------------------------------------- @8 MEMSET 1000 4000000 "__memset_sse2()" in "libc.so" ==> extern:"main()" at line 24 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @9 STOS 1000 4000000 extern:"main()" at line 25 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @10 STOS 1000 4000000 extern:"main()" at line 26 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @4 MOVS 1000 4000000 extern:"main()" at line 20 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @5 MOVS 1000 4000000 extern:"main()" at line 21 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @6 MOVS 1000 4000000 extern:"main()" at line 22 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @7 MEMSET 1000 4000000 "__memset_sse2()" in "libc.so" ==> extern:"main()" at line 23 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @2 MEMCMP 1000 4000000 "__GI_memcmp()" in "libc.so" ==> extern:"main()" at line 16 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @3 MOVS 1000 4000000 extern:"main()" at line 19 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe" @1 MEMCMP 1000 4000000 "__GI_memcmp()" in "libc.so" ==> extern:"main()" at line 15 (main.c) ==> extern:"__libc_start_main()" + 0x00f2 in "libc.so" ==> Unknown symbol at 0x80483a0 in "main.exe"
This report shows output on AIX with some standard memory operation functions and some low-core calls.
Memory Operations Tracker Probe 4.5.2-64 (201023) Copyright 1993-2019 OC Systems, Inc. All rights reserved. For support/questions send mail to support@ocsystems.com. PID: 10158244 - Summary of options Program start: Fri Oct 23 18:59:04.157421 2020 Options: TracebackDepth: 9 SizeLowerBound: 1000 SizeUpperBound: 0 Track Compares: 1 Track Fills: 1 Track Moves: 1 Track Sets: 1 Track Zeros: 1 Instrument Ins: 1 ------------------------------------------------------------------ Ops sorted by size: ------------------------------------------------------------------ TbkId | Op | NumOps | TotalOpSize | AvgOpSize ------------------------------------------------------------------ @9 BZERO 1000 4000000 4000 @10 BZERO 1000 4000000 4000 @2 MEMCMP 1000 4000000 4000 @4 MEMMOVE 1000 4000000 4000 @8 FILL 1000 4000000 4000 @5 MEMMOVE 1000 4000000 4000 @3 MEMMOVE 1000 4000000 4000 @6 MEMMOVE 1000 4000000 4000 @7 FILL 1000 4000000 4000 @11 MEMCMP 999 3996000 4000 @1 MEMCMP 1 4000 4000 ------------------------------------------------------------------ Ops sorted by count: ------------------------------------------------------------------ TbkId | Op | NumOps | TotalOpSize | AvgOpSize ------------------------------------------------------------------ @10 BZERO 1000 4000000 4000 @2 MEMCMP 1000 4000000 4000 @4 MEMMOVE 1000 4000000 4000 @8 FILL 1000 4000000 4000 @9 BZERO 1000 4000000 4000 @5 MEMMOVE 1000 4000000 4000 @7 FILL 1000 4000000 4000 @3 MEMMOVE 1000 4000000 4000 @6 MEMMOVE 1000 4000000 4000 @11 MEMCMP 999 3996000 4000 @1 MEMCMP 1 4000 4000 --------------------------------------------------------- Op traceback ids: --------------------------------------------------------- @8 FILL 1000 4000000 extern:"main()" at line 24 (main.c) ==> Unknown symbol at 0x100001828 @9 BZERO 1000 4000000 extern:"bzero()" ==> extern:"main()" at line 25 (main.c) ==> extern:"__start()" + 0x0070 @10 BZERO 1000 4000000 extern:"bzero()" ==> extern:"main()" at line 26 (main.c) ==> extern:"__start()" + 0x0070 @11 MEMCMP 999 3996000 extern:"main()" at line 15 (main.c) ==> extern:"main()" at line 26 (main.c) @4 MEMMOVE 1000 4000000 extern:"memcpy()" ==> extern:"main()" at line 20 (main.c) ==> extern:"__start()" + 0x0070 @5 MEMMOVE 1000 4000000 extern:"main()" at line 21 (main.c) ==> extern:"main()" at line 20 (main.c) @6 MEMMOVE 1000 4000000 extern:"main()" at line 22 (main.c) ==> Unknown symbol at 0x100001520 @7 FILL 1000 4000000 extern:"main()" at line 23 (main.c) ==> Unknown symbol at 0x1000016a4 @2 MEMCMP 1000 4000000 extern:"main()" at line 16 (main.c) ==> Unknown symbol at 0x100001218 @3 MEMMOVE 1000 4000000 extern:"memcpy()" ==> extern:"main()" at line 19 (main.c) ==> extern:"__start()" + 0x0070 @1 MEMCMP 1 4000 extern:"main()" at line 15 (main.c) ==> extern:"__start()" + 0x0070