Difference between revisions of "Memory Operations Tracker Probe"

From OC Systems Wiki!
Jump to: navigation, search
m (UAL Parameters)
m (Memory Operation Tracker Performance Issues)
 
Line 114: Line 114:
 
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 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 app ring.  See [[AUG_Files_Reference#APD_file|APD File]] for more information.
+
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 ===

Latest revision as of 00:37, 21 November 2020

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.


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