Perf learning-linux built-in performance analysis tool

Source: Internet
Author: User
Perf learning-what is the built-in performance analysis tool in linux? Linux Performance Tuning Tool, 32 or more built-in tools, and software performance analysis. In Linux kernel 2.6.31 and later versions, it is very easy to install perf. Almost all performance-related events can be handled. What is a performance event... perf learning-what is a built-in linux performance analysis tool? Linux Performance Tuning Tool, 32 or more built-in tools, and software performance analysis. In Linux kernel 2.6.31 and later versions, it is very easy to install perf. Almost all performance-related events can be handled. What is a performance event? A hardware event or software event that occurs in a processor or operating system and may affect program performance. Where are the main concerns? Algorithm optimization (space complexity, time complexity), Code Optimization (when it comes to execution speed, reduce memory usage) evaluate the program's usage of hardware resources, such as the number of accesses to cache at all levels, the number of cache loss at all levels, the pause period of the pipeline, and the number of front-end bus accesses. Evaluate the program's usage of operating system resources, system calls, context switches, and task migration times. What is the basic principle? Performance monitoring unit (PMC) CPU is used to detect whether or not performance events occur and the number of times of occurrence under specific conditions. The software performance test is built in the kernel and is distributed in various functional modules to collect statistics on performance events related to the operating system. How to use high-precision sampling? If high-precision sampling is required, you need to add the suffix ": p" or ": pp" after the event when formulating performance issues. 0: No precision guarantee. 1: the deviation of the command with good sampling instruction triggering performance time is a constant (: p) 2: the deviation is 0 (: pp) as far as possible. 3: The deviation must be 0 (: ppp) which common commands are available? 1. perf list all events that can trigger the perf sampling points (performance events supported by the current hardware environment) are generally divided into three types: hardware (hardware generation) and software (kernel software generation) and tradepoint (the static tracepoint trigger event in the kernel ). List of pre-defined events (to be used in-e ): cpu-cycles OR cycles [Hardware event] stalled-cycles-frontend OR idle-cycles-frontend [Hardware event] stalled-cycles-backend OR idle-cycles-backend [Hardware event] instructions [Hardware event] cache-references [Hardware event] cache-misses [Hardware event] branch-instructions OR branches [Hardware event] branch-misses [Hardware event] bus-cy Cles [Hardware event] cpu-clock [Software event] task-clock [Software event] page-faults OR faults [Software event] minor-faults [Software event] major-faults [Software event] context-switches OR cs [Software event] cpu-migrations OR migrations [Software event] alignment-faults [Software event] emulation-faults [Software event] L1-dcache-loads [Hardware cache event] l1-dcache-load-misses [Hardware Cache event] L1-dcache-stores [Hardware cache event] L1-dcache-store-misses [Hardware cache event] L1-dcache-prefetches [Hardware cache event] L1-dcache-prefetch-misses [Hardware cache event] L1-icache-loads [Hardware cache event] L1-icache-load-misses [Hardware cache event] L1-icache-prefetches [Hardware cache event] L1-icache-prefetch-misses [Hardware cache event] LLC-loads [Hardware cache even T] LLC-load-misses [Hardware cache event] LLC-stores [Hardware cache event] LLC-store-misses [Hardware cache event] LLC-prefetches [Hardware cache event] LLC- prefetch-misses [Hardware cache event] dTLB-loads [Hardware cache event] dTLB-load-misses [Hardware cache event] dTLB-stores [Hardware cache event] dTLB-store-misses [hardware cache event] dTLB-prefetches [Hardware cache event] dTLB-prefetch- Misses [Hardware cache event] iTLB-loads [Hardware cache event] iTLB-load-misses [Hardware cache event] branch-loads [Hardware cache event] branch-load-misses [Hardware cache event] 2. the overall performance of the perf stat analyzer analyzes the application with 10 typical events. Task-clock: the time in which the target task really occupies the processor, in milliseconds. this is called the task execution time, followed by the CPU usage of the task (the ratio of the execution time to the duration) the duration value indicates the total time from task submission to task completion (the total time is printed after stat is completed ). Context-switches: the number of context switches. the first half is the number of switches, followed by the average number of occurrences per second (M is the 6th power of 10 ). Cpu-migrations: processor migration. for the server load balancer of each processor in linux, a task is migrated from one processor to another under certain conditions, A processor migration occurs. Page-fault: page missing exception. The linux Memory management subsystem uses the paging mechanism. when the page requested by the application is not created, the requested page is not in the memory, or the requested page is in the memory, however, if the ing between physical and virtual addresses is not established, a page missing exception is triggered. Cycles: number of processor cycles consumed by tasks instructions: number of processor commands generated during task execution, and IPC (instructions perf cycle) IPC is an important indicator for evaluating the performance of processors and applications. (Many commands require multiple processing cycles to complete execution.) the larger the IPC, the better. This means that the program fully utilizes the features of the processor. Branches: number of branch commands that a program encounters during execution. Branch-misses: number of branch commands with incorrect prediction cache-misses: number of cache validity periods cache-references: number of cache hits common parameters are as follows-e, specifying performance event-p, specify the PID-t of the analysis process, specify the TID-r N of the thread to be analyzed, and analyze the-d continuously for N times, the results of an analysis with more Performance events are as follows: Performance counter stats for process id '20140901 ': 42677.253367 task-clock #0.142 CPUs utilized 587,906 context-switches #0.014 M/sec 29,209 CPU-migrations #0.001 M/sec 117 page-faults #0.000 M/sec 82,341,400,508 cycles #1.929 GHz [83.4 8%] 61,262,984,952 stalled-cycles-frontend # 74.40% frontend cycles idle [83.28%] 43,113,701,768 stalled-cycles-backend # 52.36% backend cycles idle [66.72%] 44,023,301,495 instructions #0.53 insns per cycle #1.39 stalled cycles per insn [83.50%] 8,137,448,528 branches #190.674 M/sec [83.22%] 430,957,756 branch-misses # 5.30% of all branches [83.34%] 300.393753095 seconds time elapsed 3, perf P real-time display of System/process performance statistics by default performance event "cycles CPU cycle count" for system-wide performance analysis common parameters are as follows:-p: specify process PID-t: TID-a of the specified thread: analyzes the performance of the entire system (default)-d: interface refresh cycle. the default value is 2 seconds, the ratio is the percentage of the performance time caused by this symbol in the entire monitoring domain, usually called heat. Samples pcnt function DSO _______ _____________________________________________________________________________________________________________ 61.00 19.4% native_write_msr_safe [kernel] 18.00 5.7% JVM_InternString libjvm. so 17.00 5.4% find_busiest_group [kernel] 17.00 5.4% _ spin_lock [kernel] 12.00 3.8% kernel [kernel] 11.00 3.5% tg_load_down [kernel] 9.00 2.9% futex_wake [kernel] 8.00 2.5% do_futex [kernel] 7.00 2.2% load_balance_fair [kernel] 7.00 2.2% weighted_cpuload [kernel] 7.00 2.2% update_cfs_shares [kernel] 7.00 2.2% JVM_LatestUserDefinedLoader libjvm. so 6.00 1.9% update_cfs_load [kernel] 5.00 _ ZN16SystemDictionary30resolve_instance_class_or_nullE12symbolHandle6HandleS1_P6Thread libjvm. so 5.00 1.6% br_sysfs_delbr [bridge] 5.00 1.6% futex_wait [kernel] 4. perf record/report records the performance events of the system/process over a period of time. by default, the data file perf is generated under the current directory. datareport reads the generated perf. data File,-I parameter specifies the path
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.