5 ms·
Here is an actual Hacker tool that allows all sorts of insane CPU close performance work. No comments all day. This is heartbreaking.
by xal 14y ago
Here is an actual Hacker tool that allows all sorts of insane CPU close performance work. No comments all day. This is heartbreaking.
- tptacek 14y agoSo... what do you think about it? Or, do you have questions? I'm not very familiar with Pin, but am somewhat familiar with DynamoRIO, which is a competing project.
- lallysingh 14y agoFirst, it's Sunday night. Second, PIN gives you very low-level access, sure, but it also requires quite a bit of work to get that data. You can get a lot of the same data (as seen in the examples) with libpfm4 (http://perfmon2.sourceforge.net/ http://perfmon2.sourceforge.net/). CPU Performance counters can give you a lot of this data with much lower run-time overhead, and a lot less work. Also, PIN's a little hairy. If you just want to generate code for run-time execution, LLVM's your best bet. If you want to diddle with a running executable, you can always use libelf(3) and ptrace(2) to read and diddle with the running process. It may be useful for specific sorts of analyses you want to run on an executable, but it's messy. If you're doing performance instrumentation, dynamically modifying the code is going to alter your results that can be hard to compensate for.
- tptacek 14y agoYou can't effectively do things like instrumenting every write instruction in a program using ptrace. Also, the techniques Pin uses sound hairy, but they're the same things software virtualization does.
- lallysingh 14y agoTrue, but what do you do with that data? Transfer it out of process? Analyze it? And how many systems can withstand that sort of slowdown without timeouts? Performance counters can tell you quite a bit, and they cost very little to set up. Snapshots and a little differential analysis can get you more comprehend-able data without transfer/storage problems.
- nkurz 14y agoI came across it as a platform for running and debugging code for a non-yet-released CPU: http://software.intel.com/en-us/articles/intel-software-development-emulator http://software.intel.com/en-us/articles/intel-software-deve... A couple other uses that I thought it would be good for were marking instructions with unaligned loads and stores and flagging switches to and from 256-bit VEX code. Although probably you can do these with other tools as well. I posted this here because it seemed potentially useful, and I was surprised I'd never heard of this project. I'm mostly familiar with the ones Lally mentioned, but Thomas brought up DynamoRIO which is also new to me. Are there other niche optimization tools I should know about? A specific question would whether there is anything more useful than IACA and gut instinct for determining optimal instruction order. Even just something that would generate an easy to parse data dependency graph for a short section of code?
- lgeek 14y agoI think it's all about using the right tool for the right job. Sure enough, there are some things that dynamic binary modification(DBM) does that can also be implemented another way (e.g. generic application level profiling), but even some of those things are sometimes done faster/better by DBM tools: Want to log the system calls to RANDOM_SYSCALL? Sure, use ptrace and do these context switches: app>kernel>ptrace_app>kernel(actual syscall)>ptrace_app>kernel>app every time any system call executes... Or use PIN and take the usually small performance hit. ptrace also messes up signal delivery. Want to profile dynamically generated code? libelf won't be much help there. Or do you want to run memory accesses through a cache simulator? ptrace won't be much help. There are plenty of uses when DBM is the right (or only) tool.
- nkurz 14y agoYou can get a lot of the same data (as seen in the examples) with libpfm4 (http://perfmon2.sourceforge.net/ http://perfmon2.sourceforge.net/). CPU Performance counters can give you a lot of this data with much lower run-time overhead, and a lot less work. What's the preferred way of using libpfm4? I've ended up using it's sample program as a way to convert from readable counter names to hex to put into a perf command line. I've found several defunct patches to give perf this functionality directly, and am confused why this seemingly essential functionality is left out. What I'd like is the ability to measure just sections of code, and access to all available counters without needing to copy-and-paste hex. I'm getting the sense that perf is not the tool for this: http://lwn.net/Articles/441209/ http://lwn.net/Articles/441209/ http://www.mail-archive.com/linux-perf-users@vger.kernel.org/msg00789.html http://www.mail-archive.com/linux-perf-users@vger.kernel.org... Is Likwid a viable option? https://code.google.com/p/likwid/ https://code.google.com/p/likwid/
- lallysingh 14y agoI wrapped the perf_event syscall with something easier to use, and just call it directly around the code I care about.