perf

Use perf inside a docker container without --privileged

此生再无相见时 提交于 2019-12-01 03:50:47
I am trying to use the perf tool inside a Docker container to record a given command. kernel.perf_event_paranoid is set to 1, but the container behaves just as if it where 2, when I don't put the --privileged flag. I could use --privileged, but the code I am running perf on is not trusted and if I am OK with taking a slight security risk by allowing perf tool, giving privileged rights on the container seems a different level of risk. Is there any other way to use perf inside the container? ~$ docker version Client: Version: 17.03.1-ce API version: 1.27 Go version: go1.7.5 Git commit: 7392c3b

Perf overcounting simple CPU-bound loop: mysterious kernel work?

梦想的初衷 提交于 2019-12-01 03:47:23
I've been using Linux perf for some time to do application profiling. Usually the profiled application is fairly complex, so one tends to simply take the reported counter values at face value, as long as there isn't any gross discrepancy with what you might expect based on first principles. Recently, however, I have profiled some trivial 64-bit assembly programs - triival enough that one can calculate almost exactly the expected value of various counters, and it seems that perf stat is overcounting. Take the following loop for example: .loop: nop dec rax nop jne .loop This will simply loop n

Python subprocess running in background before returning output

让人想犯罪 __ 提交于 2019-12-01 03:46:57
问题 I have some Python code that I want to debug with perf. For that purpose I want to use subprocess. The following command returns instruction-related information of a process until the command is exited via Ctrl^C. perf stat -p <my_pid> Now, I want to run this inside a Python code in background, until some point where I want to be able to terminate its operation and print the commands output. To show what I mean: x = subprocess.call(["perf","stat","-p",str(GetMyProcessID())]) .. CODE TO DEBUG

How to narrow down perf.data to a time sub interval

老子叫甜甜 提交于 2019-12-01 02:57:03
问题 I use linux perf (perf_events) to produce a perf.data file with timestamps. How can I generate a report of all the events in a sub interval of time [i-start, i-end]? Can I maybe narrow down perf.data to a perf_subinterv.data file with only events in [i-start, i-end]? I need to do this to analyze short intervals (2s - 6s) of poor performance every 5mins or so. 回答1: Most perf tools, including perf report , support filtering by time: --time:: Only analyze samples within given time window: <start

Perf overcounting simple CPU-bound loop: mysterious kernel work?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 01:05:29
问题 I've been using Linux perf for some time to do application profiling. Usually the profiled application is fairly complex, so one tends to simply take the reported counter values at face value, as long as there isn't any gross discrepancy with what you might expect based on first principles. Recently, however, I have profiled some trivial 64-bit assembly programs - triival enough that one can calculate almost exactly the expected value of various counters, and it seems that perf stat is

Android Systrace Trace File Format

别说谁变了你拦得住时间么 提交于 2019-11-30 15:12:36
问题 Android systrace tool, calls atrace tool via ADB. However, I don't understand very well the format of the traces file. Apparently it is very similar to linux ftrace tool with some differences. The main difference is that is doesn't uses a System.Map file but it includes all that information into the trace file. Also, there are new B|E entries that are android specific. There is some information about this format in Android Source Code at: http://androidxref.com/4.1.1/xref/external/chromium

Android Systrace Trace File Format

删除回忆录丶 提交于 2019-11-30 14:12:42
Android systrace tool, calls atrace tool via ADB. However, I don't understand very well the format of the traces file. Apparently it is very similar to linux ftrace tool with some differences. The main difference is that is doesn't uses a System.Map file but it includes all that information into the trace file. Also, there are new B|E entries that are android specific. There is some information about this format in Android Source Code at: http://androidxref.com/4.1.1/xref/external/chromium-trace/src/tracing/linux_perf_importer.js However, in that documentation we can read that the format

zprofiler工具

丶灬走出姿态 提交于 2019-11-30 12:17:59
转自: zprofiler三板斧解决cpu占用率过高问题 此工具为阿里自产的profiler工具,在其他文章中看到有用此工具进行性能问题定位的。在此转载文章学习一下。 上周五碰到了一个线上机器cpu占用率过高的问题。问题本身比较简单,但是定位过程中动用了多个zprofiler的主要功能,感觉是一个很好的介绍使用zprofiler定位此类问题流程的案例。 在开始使用zprofiler之前,先使用perf确认瓶颈点是否在native中。(以下操作需要root权限,需要pe协助操作) 如果线上服务器没有安装perf,可以到 http://yum.corp.taobao.com/taobao/6/x86_64/test/aliperf/aliperf-0.3.9-9.el6.x86_64.rpm 下载rpm包,然后安装。 使用 perf top 命令,查看当前系统的热点函数。 如上图所示的情况即表明,热点在java代码中,因为java代码是jit执行的,perf看不到其符号,所以默认归入perf-<pid>.map中。 如果热点在libjvm.so中的函数,可以联系我们团队,协助进一步分析。比如如果热点是jit相关的函数,一般是codecache或者jit相关参数的问题;如果是gc相关的函数,可以用zprofiler分析一下gclog,然后调整gc相关的参数。 排除其他可能

Perf shows mangled function names

余生颓废 提交于 2019-11-30 11:59:52
I wanted to give perf a shot to profile some programs after I saw this talk from CppCon 2015. I downloaded the same Google benchmark library that the guy uses in the talk, compiled my program with the appropriate switches, linked it to it, then used perf to record a run. The report option gives me this: As you can see the function names are not very readable. I assume this has to do with C++ name mangling. Interestingly, all the function names show up correctly in the video for the guy who gave the talk, but not for me. I don't think it's a case of completely missing the symbol information

perf_event_open - how to monitoring multiple events

北战南征 提交于 2019-11-30 05:32:08
does anyone know how to set perf_event_attr struct that can trigger PMU to monitoring multiple (type) event via perf_event_open() ? Like perf record -e cycles,faults ls , it has two different event type (PERF_TYPE_HARDWARE and PERF_TYPE_SOFTWARE), but in example on perf_event_open's manpage , perf_event_attr.type can only assigned single value. Any suggestion will be appreciate, thanks! 20170208 Update Thanks for @gudok pointing me a direction, but the result seems some abnormal. Demo program as below (for measure whole system's CPU cycle and cache miss): #define _GNU_SOURCE #include <stdlib.h