tprof 명령어 (AIX 5.3·6.1)

핵심 정리

  • 개별 프로그램과 시스템 전체의 프로세서 사용을 보고하는 프로파일러입니다. 프로세서 시간을 오브젝트 파일, 프로세스, 스레드, 서브루틴(사용자·커널·공유 라이브러리), 소스 줄, 명령어까지 나눠 보여 줍니다.
  • 다시 컴파일하지 않고 실행 파일 그대로(strip돼도 traceback 표가 있으면) 서브루틴 수준까지 프로파일링합니다. 소스 줄 수준(마이크로 프로파일링)은 -g나 -qlist로 컴파일해야 합니다.
  • 모드: -x 프로그램만 주면 실시간, -A와 함께면 자동 오프라인, -x 없이 기록 파일로는 수동 오프라인·후처리입니다.
  • 자주 쓰는 형태: tprof -skeuj -x sleep 10(시스템 전체를 10초), tprof -u -p workload -x workload(한 프로그램). 결과는 rootstring.prof 파일에 씁니다.
  • 프로파일 범위: -u(사용자), -k(커널), -e(커널 확장), -s(공유 라이브러리), -j(Java). -p·-P·-t로 프로세스·스레드별 절을 만듭니다.
  • 기본은 시간 기반(decrementer 인터럽트)이고, -E로 이벤트 기반(PM_CYC 등)을 씁니다. trace가 이미 쓰이고 있으면 trcstop 뒤 다시 실행합니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (6.1에서 -@, -X(XML), -a(대형 페이지 분석), -b·-B(데이터 프로파일링), -y, Java 6의 -agentlib:jpa가 더해짐)
원문 IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5
파일 /usr/bin/tprof, 보고서 rootstring.prof, 기록 rootstring.syms·rootstring.trc
관련 명령어 trace, trcstop, gensyms, stripnm, prof, gprof, pmlist

목적

프로세스, 스레드, 서브루틴, 소스 줄 수준의 프로세서 사용을 보고합니다.

영어 원문

Reports processor usage.

구문

text
tprof { [ -c ] [ -C { all | cpulist } ] [ -d ] [ -D ] [ -e ] [ -@ { ALL | wparlist } ]
        [ [ { -E [ mode ] [ -b ] [ -B ] } ] [ -f frequency ] ] [ -F ] [ -I ] [ -j ] [ -k ] [ -l ]
        [ -L objectlist ] [ -m objectslist ] [ -M sourcepathlist ] [ -N ] [ -p processlist ]
        [ -P { all | pidslist } ] [ -s ] [ -S searchpathlist ] [ -t ] [ -T buffersize ] [ -u ] [ -v ]
        [ -V verbosefilename ] [ -g ] { [ -z ] [ -Z ] | -R }
        { { -r rootstring } | { [ -A { all | cpulist } [ -n ] ] [ -r rootstring [ -X [ timedata [, buckets=N ] ] ] ]
          { -x program | -y program } } } }

tprof { -a [ -A [ all ] ] [ -f frequency ] [ -F ] [ -v ] [ -z ] [ -V verbosefilename ] [ -T buffersize ]
        { { [ -r rootstring ] -y program } | { -r rootstring } } }
  • 목록 입력은 쉼표로 나누고, 경로 목록만 쌍점으로 나눕니다.
  • 실시간 모드에서는 다중 CPU 프로파일링이 자동으로 꺼지고, 프로세서별 프로파일링을 켜면 마이크로 프로파일링이 꺼집니다. 실시간 모드에서는 지정한 로그 버퍼 크기를 무시합니다.
  • -x만 주면 실시간, -x와 -A를 주면 자동 오프라인, -x가 없으면 cooked 파일과 -F에 따라 후처리나 수동 오프라인 모드입니다.
  • (6.1) -@는 WPAR 안의 실시간·자동 오프라인 모드에서 자동으로 꺼집니다. -y는 -E나 -a와만 씁니다.
  • 5.3 구문에는 -@, -X, -y, -a, -b, -B가 없습니다.

설명

tprof 명령은 개별 프로그램과 시스템 전체의 프로세서 사용을 보고합니다. 프로세서에 묶여 있을지 모르는 Java, C, C++, FORTRAN 프로그램에서 어느 부분이 프로세서를 가장 많이 쓰는지 알고 싶을 때 좋습니다.

프로세서 시간을 오브젝트 파일, 프로세스, 스레드, 서브루틴(사용자 모드, 커널 모드, 공유 라이브러리), 프로그램의 소스 줄이나 개별 명령어에까지 나눠 매길 수 있습니다. 서브루틴에 매기는 것을 프로파일링, 소스 줄에 매기는 것을 마이크로 프로파일링이라고 합니다.

  • 서브루틴 수준 프로파일링은 실행 파일을 바꾸지 않고 할 수 있어 특별한 컴파일 플래그로 다시 컴파일할 필요가 없습니다. 실행 파일이 strip돼도 traceback 표가 남아 있으면 됩니다.
  • 마이크로 프로파일링은 목록 파일이 이미 없으면 다시 컴파일해야 합니다. -g로 컴파일하고 소스 파일을 tprof가 읽을 수 있게 하거나, -qlist로 컴파일해 목록 파일(.lst)을(소스와 함께, 또는 목록만) 읽을 수 있게 합니다. 가장 좋은 것은 .lst와 소스를 모두 주는 것입니다.

실행 모드

모드 조건 동작
실시간(온라인) -x만 백그라운드에서 AIX trace를 시작해 만들어지는 대로 처리하고, 프로그램이 끝나면 기호 이름을 모아 보고서를 만듭니다. 프로세서별 프로파일링은 안 됩니다.
자동 오프라인 -x와 -A trace 데이터를 파일에 기록하고, 다 모으면 기호 이름을 모은 뒤 기록 파일을 처리해 보고서를 만듭니다. 보고서 외에 rootstring.syms, rootstring.trc[-cpuid]를 만듭니다.
수동 오프라인 -x 없음, .syms·.trc 파일 위 파일을 언제든 다시 처리합니다. 파일은 gensyms와 trace를 직접 실행하거나 -c 없이 자동 오프라인 모드로 만듭니다.
후처리 -x 없음, .csyms·.ctrc 파일 -c로 만든 cooked 파일(미리 처리한 판)을 훨씬 빨리 처리합니다.
  • 입력과 보고서 파일의 이름은 모두 rootstring.suffix이며, rootstring은 -r로 정하거나 -x의 프로그램 이름입니다.
  • 실시간·자동 오프라인 모드에서는 프로파일링하는 프로그램의 데이터 영역 ulimit을 unlimited로 둡니다.
  • 자동 오프라인 모드에서 -N은 소스 줄 정보를, -I는 바이너리 명령어를 rootstring.syms에 모읍니다.
  • .syms는 gensyms 출력과 비슷한 기호 이름 정보이고, .trc[-cpuid]는 trace 기록입니다. 프로세서별 trace를 켜면 -cpuid가 붙고 파일마다 한 프로세서의 데이터만 담습니다.
  • -c와 -A를 함께 주면 .syms·.trc 대신 cooked 파일 rootstring.csyms, rootstring.ctrc[-cpuid]를 만듭니다.
  • tprof는 늘 cooked 파일을 먼저 찾고, 없을 때만 .syms·.trc를 찾습니다. 수동 오프라인 모드를 강제하려면 -F를 씁니다.
  • 입력 기호 파일에 풀린(demangled) 이름이 있으면 -Z를 쓸 수 없습니다.

보고서 구성

rootstring.prof 보고서에는 다음 절이 들어갈 수 있습니다.

절 내용
요약(늘 있음) 프로세스 이름별, 스레드(tid)별 프로세서 사용 요약
전역 프로파일 (a) 사용자 모드 루틴(-u), (b) 커널 루틴과 커널 모드 milicode(-k), (c)(d) 커널 확장 요약과 그 서브루틴(-e), (e)(f) 공유 라이브러리 요약(사용자 모드 milicode 포함)과 그 서브루틴(-s), (g)(h) Java 클래스와 메서드(-j)
프로세스·스레드 수준 -p, -P, -t를 주면 프로세스·스레드마다 전역 절과 같은 하위 절(같은 플래그로 고름)
프로세서별 -C를 주면 프로세서마다 같은 구조의 보고서 rootstring.prof[-cpuid]

마이크로 프로파일링(-m)과 목록 주석(-L)

  • -m은 rootstring.source.mprof 보고서를 만듭니다(같은 기본 이름의 소스가 여럿이면 -1 같은 번호). 보고서에는 주석을 단 소스의 전체 경로, hot line 절(샘플이 걸린 줄을 프로세서 사용 순으로, 전체와 프로세스별 비율), 함수마다 소스 줄 절(줄 번호, 사용률, 소스)이 들어갑니다. .lst가 있으면 명령어 줄을 소스 줄 사이에 끼워 명령어별로 나눠 보여 주고, 소스 없이 .lst만 있으면 그것으로, 둘 다 없고 -g로 컴파일했으면 소스 열 없이 줄 번호로 보여 줍니다.
  • 프로세서별 프로파일링을 요청하면 마이크로 프로파일링은 꺼집니다. .c 파일이 다른 .c 파일에 포함되면 줄 정보가 틀리며, Java 클래스와 메서드는 마이크로 프로파일링할 수 없습니다.
  • -m을 주면 자동 오프라인 모드에서 -N이 자동으로 켜집니다. -Z와 함께 쓰면 서브루틴마다 RootString.source.routine.mprof와 RootString.source.HOT_LINES.mprof를 만듭니다.
  • -L은 주석을 단 목록 파일 RootString.source.alst를 만들며, -Z와 함께 쓰면 서브루틴마다 나눕니다.
  • JPA(-x java -Xrunjpa 또는 -agentlib:jpa)로 Java를 프로파일링할 때 -N·-I와 함께 JPA 인수에 source=1(JIT 소스 줄, IBM JRE 1.5.0 이상)과 instructions=1(JIT 명령어)을 주면 그 정보도 모읍니다.

root가 아닌 사용자의 제한

  • 실행 중인 커널이 /unix와 같은지 확인할 수 없어 경고가 나오지만, 대부분은 같으므로 데이터는 정확합니다.
  • root가 아닌 사용자가 gensyms를 실행하면 같은 경고가 나오고 파일에 표시가 남습니다. 오프라인 모드에서 그 파일은 커널을 확인하지 않았다고 tprof에 알립니다.
  • 읽기 권한이 없는 파일(일부 개인 공유 라이브러리와 커널 확장)의 기호는 읽을 수 없습니다.

시간 기반과 이벤트 기반 프로파일링

기본은 decrementer 인터럽트로 움직이는 시간 기반입니다. 이벤트 기반은 소프트웨어 이벤트나 성능 모니터(PM) 이벤트로 인터럽트를 일으키며, 표본 주기와 이벤트를 명령줄에서 바꿀 수 있습니다.

  • -E로 켭니다. 소프트웨어 이벤트(EMULATION, ALIGNMENT, ISLBMISS, DSLBMISS)나 PM 이벤트(PM_로 시작, 예: 프로세서 사이클 PM_CYC, 완료한 명령어 PM_INST_CMPL)를 고르며, 기본은 프로세서 사이클입니다. 프로세서가 지원하는 PM 이벤트는 pmlist로 봅니다. 고른 PM 이벤트는 PM_INST_CMPL과 같은 그룹에 있어야 합니다. POWER4 이후에는 marked 이벤트(PM_MRK_)가 더 정확합니다.
  • (6.1) -y를 주면 지정한 프로그램과 그 자손만 프로파일링합니다. -E나 -a와만 씁니다.
  • -f로 표본 주기를 바꿉니다. 소프트웨어 이벤트와 프로세서 사이클은 1500ms(기본 10ms), 다른 PM 이벤트는 10,000MAXINT번(기본 10,000). -y와 함께면 다른 PM 이벤트는 1~MAXINT번입니다.
  • .prof 파일에 프로세서 이름, 프로파일링 이벤트, 표본 주기가 더해집니다.

Java 응용 프로그램

-j를 주고, 응용 프로그램을 -Xrunjpa(Java 5 이하 JVM)나 -agentlib:jpa(Java 6 JVM, 6.1 설명) 옵션으로 시작합니다. 그러면 JVM이 클래스와 메서드를 메모리에 올릴 때마다 jpa 라이브러리를 불러, 주소와 이름의 대응 정보를 /tmp/JavaPID.syms에 모읍니다. tprof는 이 디렉터리에서 파일을 자동으로 찾습니다. 자동 오프라인 모드나 cooked 플래그에서는 그 정보를 .syms·.csyms로 복사하므로 /tmp의 파일은 지워도 됩니다. JVM이 멈추면 해당 JavaPID.syms는 지워 두는 것이 좋습니다.

프로파일 정확도

정확도는 모은 샘플 수와 hot spot이 얼마나 두드러지는지에 달렸습니다. hot spot이 몇 개인 프로그램은 적은 샘플로도 되지만, 드물게 실행되는 부분은 샘플이 많아야 보입니다. 1분도 안 도는 프로그램은 해상도가 부족할 수 있으므로, 원하는 해상도가 나올 때까지 되풀이해 실행합니다. 의심스러우면 여러 번 돌려 비교합니다.

WPAR, XML, 대형 페이지, 데이터 프로파일링(6.1)

  • -@만 주면 WPAR별 프로세서 사용 요약을 더하고, 프로세스·스레드 요약에 WPAR 이름을 보여 줍니다. ALL은 시스템 전체와 실행 중인 모든 WPAR마다, WPAR 이름 목록은 그 WPAR마다 프로세스·스레드·오브젝트·서브루틴 수준 보고서를 만듭니다. 체크포인트 후 재시작한 WPAR에서 WPAR에 로컬인 공유 라이브러리 영역은 myarea@mywpar처럼 표시합니다.
  • -X는 Visual Performance Analyzer로 볼 수 있는 XML 보고서 RootString.etm(일반 정보, 기호 데이터, 프로파일 계층, 시간 데이터)을 만듭니다. 자동 오프라인 모드에서 바로, 수동 오프라인 모드에서 .syms·.trc로 만들 수 있습니다. timedata를 주면 시간 데이터를 넣고(기본은 꺼짐), buckets=N으로 버킷 수(기본 1800)를 정합니다.
  • -a는 대표 실행의 trace로 대형 페이지 분석을 합니다. 정적 데이터, 힙, 스택, 텍스트 영역을 다른 페이지 크기에 대응시켰을 때의 변환 버퍼 성능을 예측합니다. 첫 예측은 모든 영역을 기본 4KB로, 그 뒤로는 영역을 하나씩 다른 크기로 바꿔 페이지 크기, 필요한 페이지 수, translation miss score, cold translation miss score를 보고하며, 요약에는 메모리 참조 수와 비율, 모델링한 참조, malloc·free 호출 수가 나옵니다.
  • -b는 기본 데이터 프로파일링으로 프로세스마다 커널 데이터, 라이브러리 데이터, 사용자 전역 데이터, 스택·힙의 접근 정보를 보고합니다. -s, -u, -k, -e와 함께 쓰면 가장 많이 쓰인 데이터 구조(내보낸 데이터 기호)와 그것을 쓰는 함수를 보고합니다.

tprof와 prof·gprof의 비교

  • tprof는 프로파일링하는 프로그램의 실행 시간에 영향을 주지 않고, 최적화·strip된 바이너리도 다시 컴파일 없이 다룹니다(마이크로 프로파일링만 예외). prof와 gprof는 마이크로 프로파일링이 없고, 최적화된 바이너리를 다루지 못하며, 특별한 컴파일 플래그가 필요하고 실행을 꽤 느리게 합니다. prof는 strip된 바이너리를 다루지 못합니다.
  • prof와 gprof는 서브프로그램 프로파일링과 정확한 호출 횟수를, gprof는 호출 그래프도 주지만 tprof는 둘 다 주지 않습니다.
  • 셋 다 프로그램 카운터를 표본으로 해서 프로세서 소비를 추정합니다. tprof는 시스템 전체를 모으고, prof·gprof는 프로그램 하나의 사용자 모드만 모읍니다. tprof는 라이브러리와 커널 모드, Java까지 지원합니다.
영어 원문

The tprof command reports processor usage for individual programs and the system as a whole. This command is a useful tool for anyone with a Java™, C, C++, or FORTRAN program that might be processor-bound and who wants to know which sections of the program are most heavily using the processor.

The tprof command can charge processor time to object files, processes, threads, subroutines (user mode, kernel mode and shared library) and even to source lines of programs or individual instructions. Charging processor time to subroutines is called profiling and charging processor time to source program lines is called micro-profiling.

For subroutine-level profiling, the tprof command can be run without modifying executable programs, that is no recompilation with special compiler flags is necessary. This is still true if the executables have been stripped, unless the traceback tables have also been removed. However, recompilation is required to get a micro-profile, unless a listing file is already available. To perform micro-profiling on a program, either the program should be compiled with the -g flag and the source files should be accessible to the tprof command or the program should be compiled with the -qlist flag and either both the object listing files and the source files or just the object listing files should be accessible to the tprof command. To take full advantage of tprof micro-profiling capabilities, it is best to provide both the .lst and the source file.

The tprof command can run in the following modes:

  • Realtime or online

  • Manual offline

  • Automated offline

  • Post-processing

If you specify the -x flag without the -A flag, the tprof command runs in realtime mode. In realtime mode, the tprof command starts the AIX trace utility in the background, and processes the trace data as it gets generated. When the program being profiled ends, tprof collects symbolic name information, and generates the tprof reports.

Note: This mode does not allow per-processor profiling.

If you specify the -x flag with the -A flag, the tprof command runs in automated offline mode. In this mode, the tprof command starts the AIX trace utility and logs the trace data into a file. Once the trace data collection is done, it collects symbolic name information, and the tprof command opens the trace log file and processes the data to generate reports. In this mode, the tprof command generates the following files in addition to the tprof report files:

  • rootstring.syms

  • rootstring.trc [-cpuid]

All of the input and report files used by the tprof command are named rootstring.suffix, where rootstring is either specified with the -r flag, or is the program name specified with the -x flag.

In realtime mode and automated offline mode, the ulimit value of the data area for the program that is being profiled is set to unlimited.

In automated offline mode, you can specify the -N flag to collect source line information into the generated RootString.syms file. And you can specify the -I flag to collect binary instructions into the generated RootString.syms file.

The tprof command can re-process these files any time to generate profiling reports. This is called manual offline mode. The rootstring.syms file contains symbolic name information similar to the output of the gensyms command. The rootstring.trc[-cpuid] files are trace log files. The -cpuid is added to the names when per-processor tracing is on. In that case, each file contains trace data from one processor only.

If you specify the -c flag with the -A flag, the rootstring.syms and rootstring.trc[-cpuid] files are not generated. Instead, the following two files are created:

  • rootstring.csyms

  • rootstring.ctrc[ -cpuid ]

Those files are cooked, that is they are a pre-processed version of the normal trace and name files. tprof post-processes cooked file much faster.

If you specify neither the -A flag nor the -x flag, the tprof command runs either in manual offline or in post-processing mode. To run the tprof command in post-processing mode, the following files must be available:

  • rootstring.csyms

  • rootstring.ctrc[ -cpuid ]

These files are generated when the tprof command runs (in any mode except post-processing mode) with the -c flag.

To run the tprof command in manual offline mode, the following files must be available:

  • rootstring.syms

  • rootstring.trc [-cpuid]

To generate these files, you need to manually run the gensyms command and AIX trace facility, or run the tprof command in automated offline mode without the -c flag.

The tprof command always first looks for rootstring.csyms and rootstring.ctrc[-cpuid] files. Only if these files are not available, does it look for the rootstring.syms and rootstring.trc[-cpuid] files. To prevent the tprof command from looking for the rootstring.csyms and rootstring.ctrc[-cpuid] files, that is, force the manual offline mode, use the -F flag.

If the input symbols file contains demangled names, you cannot use the -Z flag.

The tprof command generates a tprof report file named rootstring.prof, which holds the process, thread, object file and subroutine level profiling report. The file can contain the following sections and subsections:

  • Summary report section: – Processor usage summary by process name – Processor usage summary by threads (tid)

  • Global (pertains to the execution of all processes on system) profile section: – Processor usage of user mode routines – Processor usage of kernel routines, including milicode routines called in kernel mode – Processor usage summary for kernel extensions – Processor usage of each kernel extension's subroutines – Processor usage summary for privately loaded, global, and named shared libraries, and milicode routines called in user mode

– Processor usage of each shared library's subroutines – Processor usage of each Java class – Processor usage of each Java methods of each Java class

  • Process and thread level profile sections (one section for each process or thread) : – Processor usage of user mode routines for this process/thread – Processor usage of kernel routines for this process/thread, including milicode routines called in kernel mode – Processor usage summary for kernel extensions for this process/thread – Processor usage of each kernel extension's subroutines for this process/thread – Processor usage summary for privately loaded, global, and named shared libraries for this process/thread, and milicode routines called in user mode – Processor usage of each shared library's subroutines for this process/thread – Processor usage of each Java class for this process/thread – Processor usage of Java methods of each Java class for this process/thread

The summary report section is always present in the rootstring.prof report file. You can turn on or turn off various subsections of the global profile section using the following profiling flags:

  • -u turns on subsections a

  • -k turns on subsection b

  • -e turns on subsections c and d

  • -s turns on subsections e and f

  • -j turns on subsections g and h

If you specify the -p, -P and -t flags, the process and thread level profile sections are created for processes and threads. The subsections present within each of the per-process of per-thread sections are identical to the subsections present in the global section, they are selected using the profiling flags (-u,-s,-k,-e,-j).

Optionally, if you run the tprof command with the -C flag, the command also generates per-processor profiling reports, which contains one profiling report per processor. The generated tprof reports have the same structure and are named using the convention: rootstring.prof[-cpuid].

If you specify the -m flag, the tprof command generates micro-profiling reports. The reports use the following naming convention: rootstring.source.mprof, where source is the base name of a source file. If more than one source file has the same base name, a number to uniquely identify them is appended to the report file names. For example, rootstring.Filename.c.mprof-1. The micro-profiling report has the following information:

  • The full path name of the annotated source file.

  • A hot line profile section which has all the line numbers from that source file hit by profiling samples, sorted by processor usage. For each source line, one line reports the percentage of time spent on behalf of all processes, followed by additional lines with the breakdown by individual process.

  • A source line profile section for each of the functions in that source file, which have processor usage. This section contains the source line number, processor usage and source code. If a .lst file for that source file is accessible to tprof, then it interlaces the instruction lines from the .lst file with the source lines from the source file and charges processor usage appropriately. This provides breakdown by instruction for each source file. If a source file is not present, but a .lst file is present, tprof only shows the processor usage based on the source lines and the instructions from the .lst file. If neither the .lst file nor the source file is present, but the source file is compiled with the -g flag, the tprof command retrieves the source line numbers and generates a similar report, with the source code column missing.

Note: If per-processor profiling is requested, micro-profiling is automatically disabled. The tprof command cannot report correct source line information if a .c file is included in another .c file. The tprof command cannot micro-profile Java classes or methods.

If you specify the -m flag, the -N flag is automatically specified to gather the source line info into a symbols file in automated offline mode.

If you specify the -Z flag with the -m flag, one report file is generated per subroutine. The following naming convention is used: RootString.source.routine.mprof, where routine is the name of one of the subroutines listed in the source file. In addition, a file named RootString.source.HOT_LINES.mprof containing the hot line profiling information described above is also created.

If you specify the -L flag, the tprof command generates annotated listing files. The files use the following naming convention: RootString.source.alst, where source is the base name of a source file. If more than one source file has the same base name, a number to uniquely identify them is appended to the report file name. For example, RootString.Filename.c.alst-1. If you specify the -Z flag with the -L flag, one report file is generated per subroutine. The following naming convention is then used: RootString.source.routine.alst, where routine is the name of one of the subroutines listed in the source file.

If you specify the -N flag or -I flag when profiling a Java program using JPA (-x java -Xrunjpa or -x java -agentlib:jpa), the JIT source line number and instructions can be collected if the corresponding parameter is added to the -Xrunjpa flag or the -agentlib:jpa flag:

  • source=1 turns on JIT source line collecting (requires IBM JRE 1.5.0 or later version).

  • instructions=1 turns on JIT instructions collecting.

The following restrictions apply for non-root users running the tprof command:

  • The tprof will not be able to verify that the running kernel is the same as the /unix file. This means that even if a warning message is displayed, in most cases the running kernel and /unix are the same, so the data should be accurate.

  • When the gensyms command is run by a non-root user, the same warning as in restriction #1 (above) is given and the gensyms file is marked. If tprof is run in the offline mode, the file created with the gensyms command will flag tprof as to kernel that is not verified.

  • The tprof will not be able to open and read symbols on files which do not have the read permission set. Some private, shared libraries do not have read permission, and some kernel extensions are not readable.

Time-Based versus Event-Based Profiling

By default, tprof is time-based and is driven by the decrementer interrupt. Another mode of profiling is event-based profiling, in which the interrupt is driven by either software-based events or by Performance Monitor events. With event-based profiling, both the sampling frequency and the profiling event can be varied on the command line.

The -E flag enables event-based profiling. The -E flag is one of the four software-based events (EMULATION, ALIGNMENT, ISLBMISS, DSLBMISS) or a Performance Monitor event (PM_*). By default, the profiling event is processor cycles. All Performance Monitor events are prefixed with PM_, such as PM_CYC for processor cycles or PM_INST_CMPL for instructions completed. The pmlist lists all Performance Monitor events that are supported on a processor. The chosen Performance Monitor event must be taken in a group where we can also find the PM_INST_CMPL Performance Monitor event. On POWER4 and later processors, profiling on marked events results in better accuracy. Marked events have the PM_MRK_ prefix.

If you specify the -y flag, only the specified program and its descendents are profiled. Use the -y flag only with the -E or -a flag.

The -f flag varies the sampling frequency for event-based profiling. For software-based events and processor cycles, supported frequencies range from 1 to 500 milliseconds, with a default of 10 milliseconds. For all other Performance Monitor events, the range is from 10000 to MAXINT occurrences of the event, with a default of 10000 events. If you specify the -f flag with the -y flag, the sampling frequency can range from 1 through the MAXINT occurrences for other Performance Monitor events, with a default of 10000 events.

Additional information is added to the .prof file to reflect the processor name, profiling event, and sampling frequency.

Java Applications Profiling

To profile Java applications, you must specify the -j flag, and start the applications with the -Xrunjpa API (for running on Java 5 and earlier JVMs) or the -agentlib:jpa (for running on Java 6 JVM) of the java command line option. When you specify this option, the JVM will automatically calls the jpa library whenever new classes and methods are loaded into memory. The library will in turn collect address to name mapping information for methods and classes in files named /tmp/JavaPID.syms, where PID is the process ID of a process running a Java Virtual Machine. The tprof command will automatically look in that directory for such files.

When running in automated offline mode, or selecting the cooking flags, the tprof command will copy the information contained in JavaPID.syms files into the RootString.syms or RootString.csyms file. The corresponding files in /tmp can then be deleted. The directory content should be kept up to date by tprof command users. Whenever the JVM corresponding to a particular JavaPID.syms is stopped, the file should be deleted.

Profile Accuracy

The degree to which processor activity can be resolved is determined by the number of samples captured and the degree to which hot spots dominate. While a program with a few hot spots can be profiled with relatively few samples, less-frequently executed sections of the program are not visible in the profiling reports unless more samples are captured. In cases where user programs run less than a minute, there may be insufficient resolution to have a high degree of confidence in the estimates.

A simple solution is to repeatedly execute the user program or script until you achieve the degree of resolution you need. The longer a program is run, the finer the degree of resolution of the profile. If you doubt the accuracy of a profile, run the tprof command several times and compare the resulting profiles.

Information

The -@ flag controls the addition of WPAR information to a tprof report. Sub-options specify what information is included to some of the report sections; these sub-options is in one of the following forms:

  • The -@ flag alone (that is, with no suboption) adds a summary of the processor usage WPAR name. Also, the WPAR name is shown for each process listed in the sections summarizing processor usage by process and by thread.

  • The ALL suboption causes the tprof report to contain a process, thread, object file and subroutine-level profiling report for the overall system and for each running WPAR.

  • A comma-separated list of WPAR names results in a process, thread, object file and subroutine-level profile section for each named WPAR in the tprof report.

Note: When a WPAR is used as a checkpoint and is restarted, some shared library areas might be local to the WPAR. In this case, the name of the WPAR is printed after the name of the area myarea@mywpar. In all other cases, the area is system-wide; thus the WPAR name is omitted.

XML Report Generating

The -X flag generates an XML report file named RootString.etm. This file can be shown in Visual Performance Analyzer. The XML report file contains four sections:

  • Profile general information

  • Symbol data

  • Profile hierarchy

  • Temporal data

The -X is used in automated offline mode to generate XML report directly.

The -X is also used in manual offline mode to generate XML report from the RootString.syms and RootString.trc files.

If the -X timedata is specified, the generated XML report will include the time data information. By default, the time data generating function is turned off.

To specify the bucket number for the time data, use the buckets=N argument. The default bucket number is 1800.

Large Page Analysis

The tprof -a command collects the profile trace from a representative application run, and produces performance projections. The projections map different portions of the data space of an application to different page sizes. The large page analysis uses the information in the trace to project translation buffer performance when the command maps any of the following application memory regions to a different page size:

  • Static application data (data that is initialized or not initialized)

  • Application heap (data that is dynamically allocated)

  • Stack

  • Application text

Performance projections are provided for each of the page sizes that the operating system supports. The first performance projection is a baseline projection that maps all of the memory regions to a default page size of 4 KB. Subsequent projections map one region at a time to a different page size. The following statistics are reported for each projection:

  • Page size

  • Number of pages needed to back all of the regions

  • Translation miss score

  • Cold translation miss score

The summary section lists the processes that are profiled and the statistics that are reported. It includes the following information:

  • Number or percentage of memory reference

  • Modeled memory reference

  • Malloc calls

  • Free calls

Data Profiling

The tprof -b command turns on basic data profiling and collects data access information. The summary section reports access information across the kernel data, library data, user global data, and the stack heap sections for each process.

If you specify the -b flag with the -s, -u, -k, and -e flags, the tprof command data profiling reports most used data structures (exported data symbols) in shared library, binary, kernel and kernel extensions. The -b flag also reports the functions that use those data structures.

Comparison of tprof Versus prof and gprof

The most significant differences between these three commands is that tprof collects data with no impact on the execution time of the programs being profiled, and works on optimized and stripped binaries without any need for recompilation, except to generate micro-profiling reports. Neither gprof nor prof have micro-profiling capabilities or work on optimized binaries, while they do require special compilation flags, and induce a slowdown in the execution time that can be significant. prof does not work on stripped binaries.

The prof and gprof tools are standard, supported profiling tools on many UNIX systems, including this operating system. Both prof and gprof provide subprogram profiling and exact counts of the number of times every subprogram is called. The gprof command also provides a very useful call graph showing the number of times each subprogram was called by a specific parent and the number of times each subprogram called a child. The tprof command provides neither subprogram call counts nor call graph information.

Like the tprof command, both the prof and gprof commands obtain their processor consumption estimates for each subprogram by sampling the program counter of the user program.

tprof collects processor usage information for the whole system, while prof and gprof collect only profiling information for a single program and only for the time spent in user mode.tprof also provides summary for all processes active during the execution of the profiled user program and fully support libraries and kernel mode profiling.

tprof support the profiling of Java applications, which prof and gprof do not.

플래그

플래그 설명
-@ {ALL | wparlist} 보고서에 WPAR 정보를 넣습니다. ALL은 'SYSTEM' 보고서와 추적한 WPAR마다 보고서를, wparlist는 지정한 WPAR마다 보고서를 만듭니다. 6.1부터
-a 대형 페이지 분석을 켭니다. 6.1부터
-A {all | cpulist} 자동 오프라인 모드를 켭니다. 인수가 없으면 프로세서별 trace를 끄고, all은 모든 프로세서를, cpulist는 쉼표로 나눈 프로세서만 추적합니다.
-b 기본 데이터 프로파일링을 켭니다. 6.1부터
-B 명령어 주소에 대응하는 함수 정보와 함께 기본 데이터 프로파일링을 켭니다. 6.1부터
-c cooked 파일을 만듭니다.
-C all | cpulist 프로세서별 프로파일링을 켭니다. 프로세서별 trace를 켰거나(자동 오프라인) 썼을 때(수동 오프라인)만 되고, 온라인 모드에서는 안 됩니다. 추적한 CPU가 128개를 넘으면 지원하지 않습니다.
-d trace를 미룹니다. trcon을 부를 때까지 데이터를 모으지 않습니다.
-D 서브루틴마다 명령어 오프셋별 프로세서 사용을 보여 주는 상세 프로파일링을 켭니다.
-e 커널 확장 프로파일링을 켭니다.
-E [mode] 이벤트 기반 프로파일링을 켭니다. mode는 PM_event(하드웨어 이벤트, 기본 PM_CYC), EMULATION, ALIGNMENT, ISLBMISS(명령어 SLB 미스), DSLBMISS(데이터 SLB 미스)입니다.
-f frequency 표본 주기를 정합니다. 프로세서 사이클과 EMULATION·ALIGNMENT·ISLBMISS·DSLBMISS는 1500ms, 다른 PM 이벤트는 10,000MAXINT번입니다. -y와 함께면 다른 PM 이벤트는 1~MAXINT번(기본 10,000)입니다.
-F cooked 파일이 있으면 덮어씁니다. -x 없이 쓰면 수동 오프라인 모드를 강제합니다.
-g 기호 이름을 사람이 읽을 이름으로 바꾸지 않습니다.
-I 바이너리 명령어를 모읍니다. 자동 오프라인 모드에서 기호 파일을 만들 때 동작하며, 수동 오프라인 모드의 보고서에는 영향이 없습니다.
-j Java 클래스와 메서드 프로파일링을 켭니다.
-k 커널 프로파일링을 켭니다.
-l 긴 이름을 그대로 보고합니다. 기본은 자리에 맞지 않는 서브루틴, 프로그램, 소스 파일 이름을 자릅니다.
-L objectlist 쉼표로 나눈 오브젝트의 목록 주석을 켭니다. 프로그램은 -u, 공유 라이브러리는 -s가 켜져 있어야 하며, 라이브러리는 아카이브 이름으로 지정합니다. IPA로 컴파일한 목록은 a.lst로 지정합니다.
-m objectslist 쉼표로 나눈 오브젝트의 마이크로 프로파일링을 켭니다. 실행 파일, 공유 라이브러리, 커널 확장을 할 수 있으며, 각각 -u, -s, -e가 켜져 있어야 합니다.
-M PathList 마이크로 프로파일링과 목록 주석에 필요한 소스와 .lst 파일을 찾을 경로(쌍점으로 나눔)입니다. 기본은 오브젝트 검색 경로입니다.
-n 후처리를 끕니다. -u, -s, -k, -e, -j를 무시하고 .trc와 gensyms 파일만 만들고 .prof는 만들지 않습니다(벤치마크 중 부하를 줄일 때). -A와 함께 써야 합니다.
-N 소스 줄 번호 정보를 모읍니다. 자동 오프라인 모드에서 기호 파일을 만들 때 동작합니다.
-p processlist 쉼표로 나눈 프로세스 이름의 프로세스 수준 프로파일링을 켭니다. -u, -s, -k, -e, -j 중 하나 이상이 켜져 있어야 합니다.
-P {all | PIDList} 만나는 모든 프로세스나 지정한 PID의 프로세스 수준 프로파일링을 켭니다. 프로파일링 모드가 하나 이상 켜져 있어야 합니다.
-r rootstring 입력과 보고서 파일의 이름을 rootstring.suffix로 정합니다. 없으면 -x의 프로그램 이름입니다.
-R 백분율 계산에 PURR 증가값으로 가중한 샘플을 씁니다. SMT나 Micro-Partitioning 환경에서 권하며, -z·-Z와 함께 쓸 수 없습니다.
-s 공유 라이브러리 프로파일링을 켭니다.
-S PathList 실행 파일, 공유 라이브러리, 커널 확장을 찾을 오브젝트 검색 경로(쌍점으로 나눔)입니다. 기본은 $PATH입니다.
-t 스레드 수준 프로파일링을 켭니다. -p·-P가 없으면 -P all -t와 같고, 있으면 고른 프로세스의 스레드를 보고합니다. 프로파일링 모드가 하나 이상 켜져 있어야 합니다.
-T buffersize trace 버퍼 크기를 정합니다. 실시간과 자동 오프라인 모드에서만 의미가 있습니다.
-u 사용자 모드 프로파일링을 켭니다.
-v 자세한 모드를 켭니다.
-V File 자세한 출력을 File에 저장합니다.
-x program tprof가 실행할 프로그램입니다. 프로그램이 끝나거나 trcoff·trcstop으로 trace를 멈추면 데이터 수집이 끝납니다. 플래그 목록의 맨 마지막에 와야 합니다.
-X 프로파일링이 끝나면 XML 생성기를 불러 trace와 기호 데이터로 XML 보고서를 바로 만듭니다. Java가 설치돼 있고 PATH에 있어야 합니다. 6.1부터
-y 지정한 명령과 그 자손만 이벤트 기반으로 프로파일링합니다. 6.1부터
-z tick 보고서를 켭니다(예전 tprof와의 호환 모드). 기본은 백분율만 보고하지만 tick도 보고하고, 서브루틴 보고서에 Address·Bytes 열을 더합니다. -a와 함께 쓰면 프로세스 요약을 백분율 대신 수로 보여 줍니다.
-Z 백분율 대신 tick을 쓰고(-z와 같음), -L·-m의 주석 파일을 서브루틴마다 나눕니다. -g도 켭니다.
영어 원문
  • -@ { ALL | wparlist } — Includes the WPAR information in the generated reports. The ALL option includes summaries for all of the WPAR. When this option is set, the report contains a 'SYSTEM' report and a report per WPAR traced. The wparlist option specifies a comma-separated list of WPAR. When the wparlist option is set, the tprof command produces a report for each WPAR specified.
  • -a — Turns on the large page analysis.
  • -A { all | cpulist } — Turns on automatic offline mode. No argument turns off per-processor tracing. all enables tracing of all processors. cpulist is a comma separated list of processor-ids to be traced.
  • -b — Turns on basic data profiling.
  • -B — Turns on basic data profiling with the information about the instruction address mapped function.
  • -c — Turns on generation of cooked files.
  • -C all | cpulist — Turns on the per-processor profiling. Specify all to generate profile reports for all processors. Processor numbers should be separated with a comma if you give a cpulist (for example, 0,1,2). Note: per-processor profiling is possible only if per-processor trace is either on (in automated offline mode), or has been used (in manual offline mode). It is not possible at all in online mode. This option is not supported if the number of CPUs traced is greater than 128.
  • -d — Turns on deferred tracing mode, that is defers data collection until trcon is called.
  • -D — Turns on detailed profiling which displays processor usage by instruction offset under each subroutine.
  • -e — Turns on kernel extension profiling.
  • -E [ mode ] — Enables event-based profiling. The possible modes are: PM_event Specifies the hardware event to profile. If no mode is specified for the -E flag, the default event is processor cycles (PM_CYC). EMULATION Enables the emulation profiling mode. ALIGNMENT Enables the alignment profiling mode. ISLBMISS Enables the Instruction Segment Lookaside Buffer miss profiling mode. DSLBMISS Enables the Data Segment Lookaside Buffer miss profiling mode.
  • -f frequency — Specifies the sampling frequency. The sampling frequency can be from 1 to 500 milliseconds for processor cycles and EMULATION, ALIGNMENT, ISLBMISS, and DSLBMISS events, and from 10000 to MAXINT event occurrences for other Performance Monitor events. If you specify the -f flag with the -y flag, the value of the sampling frequency ranges from 1 through the value of the MAXINT occurrences for other Performance Monitor events, with the default value of 10000 events.
  • -F — Overwrites cooked files if they exists. If used without the -x flag, this forces the manual offline mode.
  • -g — Does not translate symbol names into human-readable names.
  • -I — Turns on binary instructions collecting. Note: The -I flag activates to gather binary instructions when generating symbol files or cooked symbol files in automated offline mode. However, in manual offline mode, the -I flag does not affect the report files.
  • -j — Turns on Java classes and methods profiling.
  • -k — Enables kernel profiling.
  • -l — Enables long names reporting. By default tprof truncates the subroutine, program and source file names if they do not fit into the available space in the profiling report. This flag disables truncation.
  • -L objectlist — Enables listing annotation for objects specified by the comma separated list, objectlist. Executables and shared libraries can have their listing files annotated. Specify the archive name for libraries. Note: 1. To enable listing annotation of programs, user mode profiling (-u) must be turned on. 2. To enable listing annotation of shared libraries, shared library profiling (-s) must be turned on. 3. To annotate a listing generated with IPA compilations, specify a.lst as the objectlist.
  • -m objectslist — Enables micro-profiling of objects specified by the comma separated list, objectlist. Executables, shared libraries, and kernel extensions can be micro-profiled. Specify the archive name for libraries and kernel extensions. Note: 1. To enable micro-profiling of programs, user mode profiling (-u) must be turned on. 2. To enable micro-profiling of shared libraries, shared library profiling (-s) must be turned on. 3. To enable micro-profiling of kernel extensions, kernel extension profiling (-e) must be turned on.
  • -M PathList — Specifies the source path list. The PathList is a colon separated list of paths that are searched for source files and .lst files that are required for micro-profiling and listing annotation. By default the source path list is the object search path list.
  • -n — Turns off postprocessing. If the -n flag is specified, the -u, -s, -k, -e, and -j flags are ignored. The data is collected, the .trc file and the gensyms files are generated, but the .prof file is not generated. This helps avoid overloading the system during a benchmark, for example. The -A flag must be used if the -n option is used.
  • -N — Turns on source line number info collecting. The -N flag activates to gather source line information when generating symbol files or cooked symbol files in automated offline mode. However, in manual offline mode, the -N flag does not affect the report files.
  • -p processlist — Enables process level profiling of the process names specified in the processlist. processlist is a comma separated list of process names Process level profiling is enabled only if at least one of the profiling modes (-u,-s,-k,-e, or -j) is turned on.
  • -P { all | PIDList } — Enables process level profiling of all processes encountered or for processes specified with PIDList. The PIDList is a comma separated list of process-IDs. Process level profiling is enabled only if at least one of the profiling modes (-u,-s,-k,-e, or -j) is turned on.
  • -r rootstring — Specifies the rootstring.tprof input and report files all have names in the form of rootstring.suffix. If you do not specify the -r flag, the rootstring parameter uses the default program name that the -x flag specifies.
  • -R — Specifies that the tprof command should use samples weighted by PURR increment values to calculate percentages. This is the preferred mode when running in either simultaneous multithreading or Micro-Partitioning environments. The -R flag cannot be used with either the -z flag or the -Z flag.
  • -s — Enables shared library profiling.
  • -S PathList — Specifies the object search PathList. The PathList is a colon separated list of paths that are searched for executables, shared libraries and kernel extensions. The default object search PathList is the environment path list ($PATH).
  • -t — Enables thread level profiling. If -p or -P are not specified with the -t flag, -t is equivalent to -P all -t. Otherwise, it enables thread level reporting for the selected processes. Thread level profiling is enabled only if at least one of the profiling modes (-u,-s,-k,-e, -j) is enabled.
  • -T buffersize — Specifies the trace buffersize. This flag has meaning only in real time or automated offline modes.
  • -u — Enables user mode profiling.
  • -v — Enables verbose mode.
  • -V File — Stores the verbose output in the specified File.
  • -x program — Specifies the program to be executed by tprof. Data collection stops when program completes or trace is manually stopped with either trcoff or trcstop The -x flag must be the last flag in the list of flags specified in tprof.
  • -X — Specifies the tprof command to call XML Generator when the tprof profiling is finished, and to generate the XML report directly from the tprof trace and symlib data. The -X option needs Java. Install the Java first, and make sure Java is in PATH.
  • -y — Turns on the event-based profiling for only the specified command and its descendents.
  • -z — Turns on ticks report. Enables compatibility mode with the previous version of tprof. By default processor usage is only reported in percentages. When -z is used, tprof also reports ticks. This flag also adds the Address and Bytes columns in subroutine reports. If you specify the -z flag with the -a flag, the process summary section in the report displays numbers rather than percentages.
  • -Z — Switches reports to use ticks instead of percentages (same as the -z flag), and splits annotated listing (when used with the -L flag) and annotated source files (when used with the -m flag) into multiple files, one per subroutine. This option turns on the -g flag.

예제

원문 예제의 명령과 하는 일입니다. 출력 예는 영어 원문을 봅니다.

명령 하는 일
tprof -x sleep 10 기본 전역 프로그램·스레드 수준 요약
tprof -skeuj -x sleep 10 모든 옵션을 켠 전역 프로파일링
tprof -u -p workload -x workload 프로세스 하나(workload)의 수준 프로파일링
tprof -se -p send,receive -x startall 여러 프로세스의 수준 프로파일링
tprof -m ./tcalc -L ./tcalc -u -x ./tcalc 마이크로 프로파일링과 목록 주석
tprof -E -f 100 -Askex sleep 10 프로세서 사이클로 100ms마다 표본을 뜨는 이벤트 기반 프로파일링
tprof -E PM_INST_CMPL -f 20000 -Askex sleep 10 완료한 명령어 20,000개마다 표본을 뜨는 이벤트 기반 프로파일링
tprof -E EMULATION -Askex sleep 10 에뮬레이션 인터럽트 10,000번마다 표본을 뜨는 이벤트 기반 프로파일링
tprof -A -x sleep 10, tprof -c -A all -x sleep 10 자동 오프라인 모드(cooked 파일과 모든 프로세서 trace 포함)
tprof -A -N -x sleep 10 소스 줄 수집을 켠 자동 오프라인 모드
tprof -A -N -I -r RootString -x sleep 10 소스 줄과 명령어 수집을 켠 자동 오프라인 모드
tprof -N -I -x java -Xrunjpa:source=1,instructions=1 HelloAIX Java 5 JVM에서 실행하는 HelloAIX의 Java 소스 줄과 명령어 수집(실시간)
tprof -A -n -s -t -r test -x vloop_lib_32 5 공유 라이브러리·스레드 수준·프로세서별 trace·후처리 없이 vloop_lib_32의 프로세서 사용
tprof -A -X -r RootString -x sleep 10 XML 보고서를 만드는 자동 오프라인 모드(6.1)
tprof -A -N -I -X -x sleep 10 소스 줄·명령어 수집과 XML 보고서(6.1)
tprof -A -X timedata,buckets=100 -x sleep 10 시간 데이터를 넣은 XML 보고서(6.1)
tprof -X -r sleep 수동 오프라인 모드에서 XML 보고서(6.1)
tprof -a -y workload 작업 부하와 자손의 대형 페이지 분석(6.1)
tprof -E PM_MRK_LSU_FIN -f 20000 -Aske -y workload PM_MRK_LSU_FIN 이벤트 20,000번마다 표본을 떠 workload와 자손만 프로파일링(6.1)
tprof -N -I -x java -agentlib:jpa=source=1,instructions=1 HelloAIX Java 6 JVM에서 실행하는 HelloAIX의 Java 소스 줄과 명령어 수집(6.1, 64비트는 jpa64)
영어 원문
  1. The following example shows the basic global program and thread-level summary:
$tprof -x sleep 10

An output that is similar to the following is displayed:

Mon May 21 00:39:26 2012 System: AIX 6.1 Node: dreaming Machine: 000671894C00
Starting Command sleep 10
stopping trace collection.
Generating sleep.prof

The sleep.prof file that is generated only contains the summary report section.

  1. The following example shows the global profiling with all options:
$tprof -skeuj -x sleep 10

An output that is similar to the following is displayed:

Mon May 21 00:39:26 2012
System: AIX 6.1 Node: drea
ming Machine: 000671894C00
Starting Command sleep 10
stopping trace collection.
Generating sleep.prof

The sleep.prof file that is generated contains the summary report and global profile sections.

  1. The following example shows the single process level profiling:
$tprof -u -p workload -x workload

An output that is similar to the following is displayed:

Mon May 21 00:39:26 2012
System: AIX 6.1 Node: drea
ming Machine: 000671894C00
Starting Command workload stopping trace collection.
Generating workload.prof

The workload.prof file that is generated contains the summary report, the global user mode profile sections, and one process level profile section for the process 'workload' that contains only a user mode profile subsection.

  1. The following example shows the multiple process level profiling:
$tprof -se -p send,receive -x startall

An output that is similar to the following is displayed:

Mon May 21 00:39:26 2012
System: AIX 6.1 Node: drea
ming Machine: 000671894C00
Starting Command startall
stopping trace collection.
Generating startall.prof

The startall.prof file that is generated contains the summary report, the global shared library mode profile, the global kernel extension profile sections, and two process level profile sections: one for the process 'send', and one for the process 'receive'. The process level sections each contain two subsections: one with shared library profiling information and one with kernel extensions profiling information.

  1. The following example shows the micro-profiling and listing annotation:
$tprof -m ./tcalc -L ./tcalc -u -x ./tcalc

An output that is similar to the following is displayed:

Mon May 21 00:39:26 2012
System: AIX 6.1 Node: drea
ming Machine: 000671894C00
Starting Command ./tcalc
stopping trace collection.
Generating tcalc.prof
Generating tcalc.tcalc.c.mprof
Generating tcalc.tcalc.c.alst

The tcalc.prof file that is generated contains the summary report and the global user mode profile sections. The resulting tcalc.tcalc.c.mprof and tcalc.tcalc.c.alst files contain the micro-profiling report and the annotated listing.

  1. For event-based profiling on processor cycles, sampling once every 100 milliseconds, enter the following command:
$tprof -E -f 100 -Askex sleep 10

The output is similar to the following display:

Starting Command sleep 10
stopping trace collection.
Tue Apr 26 14:44:02 2005
System: AIX 5.3 Node: bigdomino Machine: 00C0046A4C00
Generating sleep.trc
Generating sleep.prof
Generating sleep.syms
  1. For event-based profiling on completed instructions, sampling once every 20,000 completed instructions, enter the following command:
$tprof -E PM_INST_CMPL -f 20000 -Askex sleep 10

The output is similar to the following display:

Starting Command sleep 10
stopping trace collection.
Tue Apr 26 14:42:44 2005
System: AIX 5.3 Node: bigdomino Machine: 00C0046A4C00
Generating sleep.trc
Generating sleep.prof
Generating sleep.syms
  1. For event-based profiling on emulation interrupts, sampling once every 10000 events, enter the following command:
$tprof -E EMULATION -Askex sleep 10

The output is similar to the following display:

Starting Command sleep 10
stopping trace collection.
Tue Apr 26 14:41:44 2005
System: AIX 5.3 Node: bigdomino Machine: 00C0046A4C00
Generating sleep.trc
Generating sleep.prof
Generating sleep.syms
  1. The following example shows the automated offline mode:
$tprof -c -A all -x sleep 10

The output is similar to the following display:

Starting Command sleep 10
stopping trace collection.
Mon May 21 00:39:26 2012
System: AIX 6.1 Node: drea
ming Machine: 000671894C00
Generating sleep.ctrc
Generating sleep.csyms
Generating sleep.prof

The sleep.prof file that is generated only has a summary report section, while the two cooked files are ready to be re-postprocessed.

  1. The following example shows the automated offline mode that is enabling source line collecting:
$tprof -A -N -x sleep 10

The output is similar to the following display:

Starting Command sleep 10
stopping trace collection.
Wed Feb 8 15:12:41 2006
System: AIX 5.3 Node: aixperformance Machine: 000F9F3D4C00
Generating sleep.trc
Generating sleep.prof
Generating sleep.syms

The sleep.prof file that is generated only contains the summary report section, while sleep.syms contains the source line information.

  1. The following example shows the automated offline mode that is enabling source line and instruction collecting:
$tprof -A -N -I -r RootString -x sleep 10

The output is similar to the following display:

Starting Command sleep 10
stopping trace collection.
Wed Feb 8 15:16:37 2006
System: AIX 5.3 Node: aixperformance Machine: 000F9F3D4C00
Generating RootString.trc
Generating RootString.prof
Generating RootString.syms

The rootstring.prof file is generated. The rootstring.syms file contains the source line information and binary instructions.

  1. To enable Java source line and instructions collecting for the application HelloAIX that is running on Java 5 JVM in realtime mode, enter the following command:
$tprof -N -I -x java -Xrunjpa:source=1,instructions=1 Hello AIX

The output is similar to the following display:

Thu Feb 9 13:30:38 2006
System: AIX 5.3 Node: perftdev Machine: 00CEBB4A4C00
Starting Command java -Xrunvpn_jpa:source=1,instructions=1 Hello AIX
Hello AIX!
stopping trace collection.
Generating java.prof

The java.prof file is generated. It contains the JIT source line information and the JIT instructions.

  1. The following example shows the processor usage for the vloop_lib_32 program without any shared library, thread-level profiling, per-processor tracing, or post processing:
$tprof -A -n -s -t -r test -x vloop_lib_32 5

The output is similar to the following display:

Starting Command vloop_lib_32 5
stopping trace collection.
Generating test.trc
Generating test.syms
  1. The following is an example of the automated offline mode for XML report:
$tprof -A -X -r RootString -x sleep 10
Starting Command sleep 10
stopping trace collection.
Tue Apr 17 22:00:24 2007
System: AIX 5.3 Node: test105 Machine: 00CEBB4A4C00
Generating sleep.trc
Generating sleep.syms
Calling tprof2xml to generate XML report.
tprof2xml TraceReader Version 1.2.0
Tue Apr 17 22:00:24 2007
System: AIX 6.1 Node: test105 Machine: 00CEBB4A4C00
------------------0------------------
Record 0
Post-processing counters
Retrieving Disassembly
writing the XML
Writing symbol list
.
Writing process hierarchy
Finished writing sleep.etm
  1. The following is an example of the automated offline mode enabling source line and instruction collecting:
$tprof -A -N -I -X -x sleep 10
Starting Command sleep 10
stopping trace collection.
Tue Apr 17 22:00:24 2007
System: AIX 5.3 Node: test105 Machine: 00CEBB4A4C00
Generating sleep.trc
Generating sleep.syms
Calling tprof2xml to generate XML report.
tprof2xml TraceReader Version 1.2.0
Tue Apr 17 22:00:24 2007
System: AIX 6.1 Node: test105 Machine: 00CEBB4A4C00
------------------0------------------
Record 0
Post-processing counters
Retrieving Disassembly
writing the XML
Writing symbol list
.
Writing process hierarchy
Finished writing sleep.etm
The symbol data elements in the xml report will have both bytes and
LineNumberList child elements.
  1. The following is an example of the automated offline mode for XML report enabling timedata:
$tprof -A -X timedata,buckets=100 -x sleep 10
Starting Command sleep 10
stopping trace collection.
Tue Apr 17 22:18:06 2007
System: AIX 5.3 Node: test105 Machine: 00CEBB4A4C00
Generating RootString.trc
Generating RootString.syms
Calling tprof2xml to generate XML report.
tprof2xml TraceReader Version 1.2.0
Tue Apr 17 22:18:06 2007
System: AIX 5.3 Node: test105 Machine: 00CEBB4A4C00
Tue Apr 17 22:18:06 2007
System: AIX 5.3 Node: test105 Machine: 00CEBB4A4C00
------------------0------------------
Record 0
Post-processing counters
Retrieving Disassembly
writing the XML
Writing symbol list
.
Writing process hierarchy
Finished writing RootString.etm
The RootString.etm will have bucket elements in each object of the profile
hierachy.
  1. The following is an example of the manual offline mode for XML report:
$tprof -A -x sleep 10
Starting Command sleep 10
stopping trace collection.
Tue Apr 17 22:28:01 2007
System: AIX 5.3 Node: test105 Machine: 00CEBB4A4C00
Generating sleep.trc
Generating sleep.prof
Generating sleep.syms

To run the tprof to use the sleep.trc and sleep.syms to generate XML report, enter the following to specify the -r sleep to generate XMLl report:

$tprof -X -r sleep
Calling tprof2xml to generate XML report.
tprof2xml TraceReader Version 1.2.0
Tue Apr 17 22:28:01 2007
System: AIX 6.1 Node: test105 Machine: 00CEBB4A4C00
------------------0------------------
Record 0
Post-processing counters
Retrieving Disassembly
writing the XML
Writing symbol list
.
Writing process hierarchy
Finished writing sleep.etm
  1. For large page analysis of the workload and its descendants, enter the following command:
$tprof -a -y workload

The output is similar to the following display:

Starting Command workload
stopping trace collection.
Tue Apr 26 14:42:44 2005
System: AIX 5.3 Node: bigdomino Machine: 00C0046A4C00
Generating workload.trc
Generating workload.prof
Generating workload.syms
  1. To profile only the specified program workload and its descendents, enter the following command:
$tprof -E PM_MRK_LSU_FIN -f 20000 -Aske -y workload

The output is similar to the following display:

Starting Command workload
stopping trace collection.
Tue Apr 26 16:42:44 2005
System: AIX 5.3 Node: bigdomino Machine: 00C0046A4C00
Generating workload.trc
Generating workload.prof
Generating workload.syms
  1. To enable Java source line and instructions collecting for the application HelloAIX that is running on Java 6 JVM in realtime mode, enter the following command:
$ tprof -N -I -x java -agentlib:jpa=source=1,instructions=1 Hello AIX

Note: When a 64-bit JDK is used, enter the -agentlib:jpa64 command instead of -agentlib:jpa in the following format:

$ tprof -N -I -x java -agentlib:jpa64=source=1,instructions=1 Hello AIX

The output is similar to the following display:

Fri May 30 04:16:27 2008
System: AIX 6.1 Node: toolbox2 Machine: 00CBA6FE4C00
Starting Command java -agentlib:jpa=source=1,instructions=1 Hello AIX
Hello AIX!
stopping trace collection.
Generating java.prof

The java.prof file is generated. It contains the JIT source line information and JIT instructions.

Messages

/dev/systrace: device busy나 trcon: TRCON:no such device 메시지가 나오면 trace 기능을 이미 쓰고 있다는 뜻입니다. 프로그램을 멈추고 trcstop을 입력해 trace를 멈춘 뒤 다시 실행합니다.

관련 명령어: stripnm, trace 데몬, gprof, prof

영어 원문

If your system displays the following message: /dev/systrace: device busy or trcon: TRCON:no such device

This means the trace facility is already in use. Stop your program and try again after typing trcstop, stops the trace.

Related reference:

  • stripnm Command
  • trace Daemon

Related information:

  • gprof command
  • prof command

리눅스(GNU)와 다른 점

리눅스에서는 perf(perf record -g, perf report, perf top)가 같은 역할을 합니다. 하드웨어 이벤트 기반 표본은 perf record -e cycles처럼 고르며, AIX의 -E PM_CYC와 비슷합니다.