digitalmars.D - Profiler Speed
- dsimcha (6/6) Jan 15 2009 I'm working on optimizing some code now, and a nagging issue that I've b...
- Nick Sabalausky (3/11) Jan 15 2009 Isn't that kind of a common thing with profilers in general?
- bearophile (6/7) Jan 15 2009 Any physical measure alters the thing to be measured, but with a good en...
- Christopher Wright (7/13) Jan 15 2009 Additionally, you can turn profiling on and off with most profilers, so
- Bill Baxter (11/28) Jan 15 2009 Right, that would probably do the trick, except I don't think there's
- Walter Bright (3/13) Jan 15 2009 You can do profiling for specific modules only by compiling just those
- Bill Baxter (6/20) Jan 15 2009 That's a good point. I never think of stuff like that because I use
- bearophile (6/9) Jan 16 2009 I usually compile programs with bud, that applies the same thing to all ...
- Robert Fraser (8/19) Jan 16 2009 Back when I was working, someone had put a pragma somewhere in the
- Tim M (4/20) Jan 16 2009 Is bud still maintained or is 11 month gaps between changes in /trunk
- Walter Bright (4/19) Jan 16 2009 It's a careful decision about whether to embed a switch in the source
- BCS (4/26) Jan 16 2009 A better way to go could be to have a config file passed to DMD that has...
- Denis Koroskin (2/25) Jan 16 2009 You can't set version (and some other options) on per-file basis. Your b...
- BCS (4/14) Jan 16 2009 That's not the point: I'm thinking you would run dsss with file-at-a-tim...
- BCS (2/10) Jan 16 2009 I think this is unavodable. Just let it run overnight.
- dsimcha (6/16) Jan 16 2009 One other thing I've noticed about the DMD profiler (I don't have any ex...
- BCS (3/6) Jan 16 2009 I think that would be DMD running some stats (fan-in/fan-out, sums, sort...
- Tom S (21/27) Jan 16 2009 You could try using an external non-intrusive profiler. If you compile
- BCS (2/6) Jan 16 2009 A neat trick. I've done the same thing by hand with the VS debugger.
- KlausO (5/22) Jan 16 2009 There is also an advanced version of sleepy called verysleepy :-)
- J Duncan (3/9) Jan 16 2009 If you are on windows, you should check out GlowCode. Its pretty simple
I'm working on optimizing some code now, and a nagging issue that I've been meaning to bring up is how slow stuff runs when profiling is turned on. It seems that, given any code that's slow enough to be worth profiling/optimizing, the DMD profiler slows it down further, to the point where it's impractical to profile because it would take forever to get the results. Does anyone have any tips for speeding this up?
Jan 15 2009
"dsimcha" <dsimcha yahoo.com> wrote in message news:gkobmc$17r0$1 digitalmars.com...I'm working on optimizing some code now, and a nagging issue that I've been meaning to bring up is how slow stuff runs when profiling is turned on. It seems that, given any code that's slow enough to be worth profiling/optimizing, the DMD profiler slows it down further, to the point where it's impractical to profile because it would take forever to get the results. Does anyone have any tips for speeding this up?Isn't that kind of a common thing with profilers in general?
Jan 15 2009
Nick Sabalausky:Isn't that kind of a common thing with profilers in general?Any physical measure alters the thing to be measured, but with a good enough brain you can generally invent ways to decrease such alteration to tolerable levels. So it's a matter of inventing better solutions. There are many kinds of profilers, some of them work "outside" with a random probing of a program, while it runs. I think such kind of profiler may slow down your code as little as you want (but the less it sample the less precise is the result). The new Intel CPUs also have some hardware to profile programs with a very little overhead. Bye, bearophile
Jan 15 2009
bearophile wrote:Nick Sabalausky:Additionally, you can turn profiling on and off with most profilers, so you only get a 3-4x slowdown until you start profiling (at which point I don't see any profiling stuff in the runtime. I suppose incrementing a global variable is just a lot faster than calling a method in the runtime, except for cache issues.Isn't that kind of a common thing with profilers in general?Any physical measure alters the thing to be measured, but with a good enough brain you can generally invent ways to decrease such alteration to tolerable levels. So it's a matter of inventing better solutions. There are many kinds of profilers, some of them work "outside" with a random probing of a program, while it runs. I think such kind of profiler may slow down your code as little as you want (but the less it sample the less precise is the result).
Jan 15 2009
On Fri, Jan 16, 2009 at 9:44 AM, Christopher Wright <dhasenan gmail.com> wrote:bearophile wrote:Right, that would probably do the trick, except I don't think there's anyway to programatically turn D's profiler on or off. So if you've got a program with a big startup cost and you want to profile something that happens after startup, it means you could be waiting a long time to get to the thing you actually care about, and by that time the profile logs are filled up with a bunch of unrelated junk. So I think your only hope with the D profile is to try to extract out the chunk you want to profile into a separate program. Not always possible, and often when possible only painfully so. --bbNick Sabalausky:Additionally, you can turn profiling on and off with most profilers, so you only get a 3-4x slowdown until you start profiling (at which point it's moreIsn't that kind of a common thing with profilers in general?Any physical measure alters the thing to be measured, but with a good enough brain you can generally invent ways to decrease such alteration to tolerable levels. So it's a matter of inventing better solutions. There are many kinds of profilers, some of them work "outside" with a random probing of a program, while it runs. I think such kind of profiler may slow down your code as little as you want (but the less it sample the less precise is the result).
Jan 15 2009
Bill Baxter wrote:Right, that would probably do the trick, except I don't think there's anyway to programatically turn D's profiler on or off. So if you've got a program with a big startup cost and you want to profile something that happens after startup, it means you could be waiting a long time to get to the thing you actually care about, and by that time the profile logs are filled up with a bunch of unrelated junk. So I think your only hope with the D profile is to try to extract out the chunk you want to profile into a separate program. Not always possible, and often when possible only painfully so.You can do profiling for specific modules only by compiling just those modules with profiling on.
Jan 15 2009
On Fri, Jan 16, 2009 at 2:24 PM, Walter Bright <newshound1 digitalmars.com> wrote:Bill Baxter wrote:That's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-( --bbRight, that would probably do the trick, except I don't think there's anyway to programatically turn D's profiler on or off. So if you've got a program with a big startup cost and you want to profile something that happens after startup, it means you could be waiting a long time to get to the thing you actually care about, and by that time the profile logs are filled up with a bunch of unrelated junk. So I think your only hope with the D profile is to try to extract out the chunk you want to profile into a separate program. Not always possible, and often when possible only painfully so.You can do profiling for specific modules only by compiling just those modules with profiling on.
Jan 15 2009
Bill Baxter:That's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-(I usually compile programs with bud, that applies the same thing to all modules. I presume as dsss. As soon as Walter realizes that's a quite natural way to use D (that is, to let something (possibly the compiler) find the modules it needs by itself. LDC may eventually grow this essential feature), he may think about ways to influence the compiler from the code itself, creating compiler directives that can be embedded in the code (as in Pascal). I am not sure this is the best good solution, maybe there are better solutions, like improving those tools (or the compiler) to allow a finer specification of the compilation flags. Bye, bearophile
Jan 16 2009
bearophile wrote:Bill Baxter:Back when I was working, someone had put a pragma somewhere in the source tree that turned on link-time code generation for the whole project. Every build (i.e. a developer build on my machine) took ~26 minutes. This is especially damning when you've spent your entire programming career being taught to recompile at every code change (or using IDEs that compile stuff in the background). (I eventually hunted down the flag and got the build time down to manageable levels)That's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-(I usually compile programs with bud, that applies the same thing to all modules. I presume as dsss. As soon as Walter realizes that's a quite natural way to use D (that is, to let something (possibly the compiler) find the modules it needs by itself. LDC may eventually grow this essential feature), he may think about ways to influence the compiler from the code itself, creating compiler directives that can be embedded in the code (as in Pascal). I am not sure this is the best good solution, maybe there are better solutions, like improving those tools (or the compiler) to allow a finer specification of the compilation flags. Bye, bearophile
Jan 16 2009
On Fri, 16 Jan 2009 21:18:46 +1300, bearophile <bearophileHUGS lycos.com> wrote:Bill Baxter:Is bud still maintained or is 11 month gaps between changes in /trunk normal?That's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-(I usually compile programs with bud, that applies the same thing to all modules. I presume as dsss. As soon as Walter realizes that's a quite natural way to use D (that is, to let something (possibly the compiler) find the modules it needs by itself. LDC may eventually grow this essential feature), he may think about ways to influence the compiler from the code itself, creating compiler directives that can be embedded in the code (as in Pascal). I am not sure this is the best good solution, maybe there are better solutions, like improving those tools (or the compiler) to allow a finer specification of the compilation flags. Bye, bearophile
Jan 16 2009
bearophile wrote:Bill Baxter:It's a careful decision about whether to embed a switch in the source code or not. One can really make a mess making the wrong choice. For profiling, though, it clearly should not go in the source code.That's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-(I usually compile programs with bud, that applies the same thing to all modules. I presume as dsss. As soon as Walter realizes that's a quite natural way to use D (that is, to let something (possibly the compiler) find the modules it needs by itself. LDC may eventually grow this essential feature), he may think about ways to influence the compiler from the code itself, creating compiler directives that can be embedded in the code (as in Pascal). I am not sure this is the best good solution, maybe there are better solutions, like improving those tools (or the compiler) to allow a finer specification of the compilation flags.
Jan 16 2009
Reply to bearophile,Bill Baxter:A better way to go could be to have a config file passed to DMD that has a long list of "codefile.d: -flags" and let DMD pick the correct flags to append to the command lineThat's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-(I usually compile programs with bud, that applies the same thing to all modules. I presume as dsss. As soon as Walter realizes that's a quite natural way to use D (that is, to let something (possibly the compiler) find the modules it needs by itself. LDC may eventually grow this essential feature), he may think about ways to influence the compiler from the code itself, creating compiler directives that can be embedded in the code (as in Pascal). I am not sure this is the best good solution, maybe there are better solutions, like improving those tools (or the compiler) to allow a finer specification of the compilation flags. Bye, bearophile
Jan 16 2009
On Fri, 16 Jan 2009 22:47:26 +0300, BCS <ao pathlink.com> wrote:Reply to bearophile,You can't set version (and some other options) on per-file basis. Your best bet would be having two (or more) passes with different files and compilation options.Bill Baxter:A better way to go could be to have a config file passed to DMD that has a long list of "codefile.d: -flags" and let DMD pick the correct flags to append to the command lineThat's a good point. I never think of stuff like that because I use dsss most of the time. You want per-file flags? Ha! Dsss laughs at you. Unfortunately. :-(I usually compile programs with bud, that applies the same thing to all modules. I presume as dsss. As soon as Walter realizes that's a quite natural way to use D (that is, to let something (possibly the compiler) find the modules it needs by itself. LDC may eventually grow this essential feature), he may think about ways to influence the compiler from the code itself, creating compiler directives that can be embedded in the code (as in Pascal). I am not sure this is the best good solution, maybe there are better solutions, like improving those tools (or the compiler) to allow a finer specification of the compilation flags. Bye, bearophile
Jan 16 2009
Reply to Denis,On Fri, 16 Jan 2009 22:47:26 +0300, BCS <ao pathlink.com> wrote:That's not the point: I'm thinking you would run dsss with file-at-a-time and dmd would add in one line of the file depending on what file is being compiled. It would be up to the user to make sure that doesn't foobar stuff.A better way to go could be to have a config file passed to DMD that has a long list of "codefile.d: -flags" and let DMD pick the correct flags to append to the command lineYou can't set version (and some other options) on per-file basis. Your best bet would be having two (or more) passes with different files and compilation options.
Jan 16 2009
Hello dsimcha,I'm working on optimizing some code now, and a nagging issue that I've been meaning to bring up is how slow stuff runs when profiling is turned on. It seems that, given any code that's slow enough to be worth profiling/optimizing, the DMD profiler slows it down further, to the point where it's impractical to profile because it would take forever to get the results. Does anyone have any tips for speeding this up?I think this is unavodable. Just let it run overnight.
Jan 16 2009
== Quote from BCS (none anon.com)'s articleHello dsimcha,One other thing I've noticed about the DMD profiler (I don't have any experience w/ any other profilers): After the program appears done, it sits there at high CPU usage for a long time if it's been profiling for a while, long enough that I often end up killing it. Is the profiler supposed to take a while after the program is done running to output the results?I'm working on optimizing some code now, and a nagging issue that I've been meaning to bring up is how slow stuff runs when profiling is turned on. It seems that, given any code that's slow enough to be worth profiling/optimizing, the DMD profiler slows it down further, to the point where it's impractical to profile because it would take forever to get the results. Does anyone have any tips for speeding this up?I think this is unavodable. Just let it run overnight.
Jan 16 2009
Reply to dsimcha,Is the profiler supposed to take a while after the program is done running to output the results?I think that would be DMD running some stats (fan-in/fan-out, sums, sorts, etc.) just lest it run for a while.
Jan 16 2009
dsimcha wrote:I'm working on optimizing some code now, and a nagging issue that I've been meaning to bring up is how slow stuff runs when profiling is turned on. It seems that, given any code that's slow enough to be worth profiling/optimizing, the DMD profiler slows it down further, to the point where it's impractical to profile because it would take forever to get the results. Does anyone have any tips for speeding this up?You could try using an external non-intrusive profiler. If you compile your stuff with GCC on *nix, I've been hearing that kcachegrind is pretty awesome: http://kcachegrind.sourceforge.net/html/Home.html If you'd like to profile a DMD-Win-compiled executable, I've written a simple tool to do it which is similar to the Sleepy profiler: http://sleepy.sourceforge.net/ ( Sleepy doesn't work with DMD-made executables ): http://team0xf.com:1024/dprof/ ; if you compile Main.d and run it, passing the name of your executable as a parameter, it will attach to it (your app must be compiled with -g and without -O). Then it pauses the target thread a few thousand times a second, checking its register states and finding the currently executed function. The stats are gathered and when you hit Enter, you're provided with some info. The program is a pretty simple one and may not do what you'd like, however the actual profiler is a separate lib (dprof.Profiler) which could be used in a more sophisticated way. So far, I've used it to successfully optimize some ray-tracing code and remove a few bottlenecks from Hybrid. -- Tomasz Stachowiak http://h3.team0xf.com/ h3/h3r3tic on #D freenode
Jan 16 2009
Reply to Tom,Then it pauses the target thread a few thousand times a second, checking its register states and finding the currently executed function. The stats are gathered and when you hit Enter, you're provided with some info.A neat trick. I've done the same thing by hand with the VS debugger.
Jan 16 2009
Tom S schrieb:You could try using an external non-intrusive profiler. If you compile your stuff with GCC on *nix, I've been hearing that kcachegrind is pretty awesome: http://kcachegrind.sourceforge.net/html/Home.html If you'd like to profile a DMD-Win-compiled executable, I've written a simple tool to do it which is similar to the Sleepy profiler: http://sleepy.sourceforge.net/ ( Sleepy doesn't work with DMD-made executables ): http://team0xf.com:1024/dprof/ ; if you compile Main.d and run it, passing the name of your executable as a parameter, it will attach to it (your app must be compiled with -g and without -O). Then it pauses the target thread a few thousand times a second, checking its register states and finding the currently executed function. The stats are gathered and when you hit Enter, you're provided with some info. The program is a pretty simple one and may not do what you'd like, however the actual profiler is a separate lib (dprof.Profiler) which could be used in a more sophisticated way. So far, I've used it to successfully optimize some ray-tracing code and remove a few bottlenecks from Hybrid.There is also an advanced version of sleepy called verysleepy :-) (http://www.codersnotes.com/sleepy) and a commercial profiler called LTProf (http://www.lw-tech.com) using the same technique. KlausO
Jan 16 2009
dsimcha wrote:I'm working on optimizing some code now, and a nagging issue that I've been meaning to bring up is how slow stuff runs when profiling is turned on. It seems that, given any code that's slow enough to be worth profiling/optimizing, the DMD profiler slows it down further, to the point where it's impractical to profile because it would take forever to get the results. Does anyone have any tips for speeding this up?If you are on windows, you should check out GlowCode. Its pretty simple but its extremely fast http://www.glowcode.com/
Jan 16 2009