www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Profiling

reply JG <someone somewhere.com> writes:
I was trying to profile a d program. So I ran: dub build 
--build=profile. I then ran the program and it produced trace.log 
and trace.def. I then ran d-profile-viewer and got the following 
error:

std.conv.ConvException /home/jg/dlang/ldc-1.24.0/bin/../impo
t/std/conv.d(2382): Unexpected '-' when converting from type char[] to type
ulong
----------------
??:? [0x564a8630fda5]
??:? [0x564a86333286]
??:? [0x564a863199fd]
/home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d:2382 
[0x564a862c89a1]
/home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d:1941 
[0x564a862c86cc]
/home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d:223 
[0x564a862c869c]
app.d:1095 [0x564a862cdd71]
app.d:1138 [0x564a862ce7ba]
??:? [0x564a863196cb]
??:? [0x564a863195c7]
??:? [0x564a8631941d]
/home/jg/dlang/ldc-1.24.0/bin/../import/core/internal/entrypoint.d:42
[0x564a862ce7e4]
??:? __libc_start_main [0x7fd482807cb1]

Is d-profile-viewer no longer working? Or did I do something 
wrong?
Feb 08 2021
next sibling parent reply Dukc <ajieskola gmail.com> writes:
On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote:
 Is d-profile-viewer no longer working? Or did I do something 
 wrong?
You may have or may not have done it wrong, but in any case this is a bug. If you do something wrong, the program should tell you what you did wrong, instead of telling you that character '-' does not belong to middle of a long int. You can try older d-profile-viewers as a workaround. Or you can try different ways to invoke the profile viewer or to profile different programs and see if you can pinpoint the cause.
Feb 09 2021
parent Dukc <ajieskola gmail.com> writes:
On Tuesday, 9 February 2021 at 16:39:25 UTC, Dukc wrote:
 You may have or may not have done it wrong, but in any case 
 this is a bug. If you do something wrong, the program should 
 tell you what you did wrong, instead of telling you that 
 character '-' does not belong to middle of a long int.
Oh wait a bit. The stack trace shows calling some function of 'app.d' - that's presumably your program. I wonder why it's being called - aren't you supposed to be viewing the profiling results instead of profiling? I'm not sure what's happening.
Feb 09 2021
prev sibling next sibling parent reply drug <drug2004 bk.ru> writes:
On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote:
 I was trying to profile a d program. So I ran: dub build 
 --build=profile. I then ran the program and it produced 
 trace.log and trace.def. I then ran d-profile-viewer and got 
 the following error:

 std.conv.ConvException /home/jg/dlang/ldc-1.24.0/bin/../impo
t/std/conv.d(2382): Unexpected '-' when converting from type char[] to type
ulong
I'm guessing only but it looks like slurp is used to read text output but the format used does not correspond to the real data format.
Feb 09 2021
parent reply JG <someone somewhere.com> writes:
On Tuesday, 9 February 2021 at 18:33:16 UTC, drug wrote:
 On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote:
 I was trying to profile a d program. So I ran: dub build 
 --build=profile. I then ran the program and it produced 
 trace.log and trace.def. I then ran d-profile-viewer and got 
 the following error:

 std.conv.ConvException /home/jg/dlang/ldc-1.24.0/bin/../impo
t/std/conv.d(2382): Unexpected '-' when converting from type char[] to type
ulong
I'm guessing only but it looks like slurp is used to read text output but the format used does not correspond to the real data format.
Thanks for the suggestions. However, I would prefer not to spend time trying to debug d-profile-viewer at the moment. As a follow up question I would like to know what tool people use to profile d programs?
Feb 10 2021
next sibling parent drug <drug2004 bk.ru> writes:
On 2/10/21 2:52 PM, JG wrote:
 On Tuesday, 9 February 2021 at 18:33:16 UTC, drug wrote:
 On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote:
 I was trying to profile a d program. So I ran: dub build 
 --build=profile. I then ran the program and it produced trace.log and 
 trace.def. I then ran d-profile-viewer and got the following error:

 std.conv.ConvException /home/jg/dlang/ldc-1.24.0/bin/../impo
t/std/conv.d(2382): 
 Unexpected '-' when converting from type char[] to type ulong
I'm guessing only but it looks like slurp is used to read text output but the format used does not correspond to the real data format.
Thanks for the suggestions. However, I would prefer not to spend time trying to debug d-profile-viewer at the moment. As a follow up question I would like to know what tool people use to profile d programs?
Could you provide trace.log that I can take a look? I have no much time but some bugs can be fixed fast. It would be ideal if you create the issue in the package repo and provides the test case. Also there is probability the author will fix this.
Feb 10 2021
prev sibling next sibling parent reply Guillaume Piolat <first.last gmail.com> writes:
On Wednesday, 10 February 2021 at 11:52:51 UTC, JG wrote:
 Thanks for the suggestions. However, I would prefer not to 
 spend time trying to debug d-profile-viewer at the moment.

 As a follow up question I would like to know what tool people 
 use to profile d programs?
Here is what I use for sampling profiler: (On Windows) Build with LDC, x86_64, with dub -b release-debug in order to have debug info. Run your program into: - Intel Amplifier (free with System Studio) - AMD CodeXL (more lightweight, and very good) - Very Sleepy (On Mac) Build with dub -b release-debug Run your program with Instruments.app which you can find in your Xcode.app (On Linux) I don't know. Though most of the time to validate the optimization a comparison program that runs two siilar programs and computer the speed difference can be needed.
Feb 10 2021
parent Max Haughton <maxhaton gmail.com> writes:
On Wednesday, 10 February 2021 at 13:31:09 UTC, Guillaume Piolat 
wrote:
 On Wednesday, 10 February 2021 at 11:52:51 UTC, JG wrote:
 [...]
Here is what I use for sampling profiler: (On Windows) Build with LDC, x86_64, with dub -b release-debug in order to have debug info. Run your program into: - Intel Amplifier (free with System Studio) - AMD CodeXL (more lightweight, and very good) - Very Sleepy (On Mac) Build with dub -b release-debug Run your program with Instruments.app which you can find in your Xcode.app (On Linux) I don't know. Though most of the time to validate the optimization a comparison program that runs two siilar programs and computer the speed difference can be needed.
All Intel tools I'm aware of support (and are free on) Linux. Also, it's just called vTune now and it's been put under the "oneAPI" banner.
Feb 10 2021
prev sibling parent reply mw <mingwu gmail.com> writes:
On Wednesday, 10 February 2021 at 11:52:51 UTC, JG wrote:
 As a follow up question I would like to know what tool people 
 use to profile d programs?
I use this one: https://code.dlang.org/packages/profdump e.g. ``` dub build --build=debug --build=profile profdump -b trace.log trace.log.b profdump -f --dot --threshold 1 trace.log trace.log.dot echo 'view it with: xdot trace.log.dot' ```
Feb 10 2021
next sibling parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Wednesday, 10 February 2021 at 23:42:31 UTC, mw wrote:
 On Wednesday, 10 February 2021 at 11:52:51 UTC, JG wrote:
 As a follow up question I would like to know what tool people 
 use to profile d programs?
I use this one: https://code.dlang.org/packages/profdump e.g. ``` dub build --build=debug --build=profile profdump -b trace.log trace.log.b profdump -f --dot --threshold 1 trace.log trace.log.dot echo 'view it with: xdot trace.log.dot' ```
Nice, didn't even know that existed
Feb 11 2021
prev sibling parent reply JG <JG somewhere.com> writes:
On Wednesday, 10 February 2021 at 23:42:31 UTC, mw wrote:
 On Wednesday, 10 February 2021 at 11:52:51 UTC, JG wrote:
 As a follow up question I would like to know what tool people 
 use to profile d programs?
I use this one: https://code.dlang.org/packages/profdump e.g. ``` dub build --build=debug --build=profile profdump -b trace.log trace.log.b profdump -f --dot --threshold 1 trace.log trace.log.dot echo 'view it with: xdot trace.log.dot' ```
I tried to do this, but I am not sure how to install profdump. What I did is cloned the repository using git. Tried to build it using dub but got an error as described here: https://github.com/AntonMeep/profdump/issues/6 I then modified the dub.json and got it to build but it only produced a library. So I modified the dub.json again to tell it to build an executable and got: core.exception.AssertError source/app.d(4): TODO ---------------- ??:? [0x561af7b38025] ??:? [0x561af7b39aa6] ??:? [0x561af7b1cd8f] ??:? [0x561af7b15469] app.d:4 [0x561af7aebc62] ??:? [0x561af7b1ca7b] ??:? [0x561af7b1c977] ??:? [0x561af7b1c7cd] /home/james/dlang/ldc-1.26.0/bin/../import/core/internal/entrypoint.d:42 [0x561af7aebc94] ??:? __libc_start_main [0x7f5ba99accb1] ??:? [0x561af7aeb62d] Program exited with code 1 I then looked inside source/app.d and found: version(unittest) { } else { void main() { assert(0, "TODO"); } } How does one install profdump?
Aug 24 2021
parent reply JG <JG somewhere.com> writes:
On Tuesday, 24 August 2021 at 09:36:06 UTC, JG wrote:
 On Wednesday, 10 February 2021 at 23:42:31 UTC, mw wrote:
 [...]
I tried to do this, but I am not sure how to install profdump. What I did is cloned the repository using git. Tried to build it using dub but got an error as described here: [...]
In case anyone is interested it seems that it was forked to here: https://github.com/joakim-brannstrom/profdump Perhaps the dub page could be updated?
Aug 24 2021
parent reply JG <JG somewhere.com> writes:
On Tuesday, 24 August 2021 at 09:42:29 UTC, JG wrote:
 On Tuesday, 24 August 2021 at 09:36:06 UTC, JG wrote:
 On Wednesday, 10 February 2021 at 23:42:31 UTC, mw wrote:
 [...]
I tried to do this, but I am not sure how to install profdump. What I did is cloned the repository using git. Tried to build it using dub but got an error as described here: [...]
In case anyone is interested it seems that it was forked to here: https://github.com/joakim-brannstrom/profdump Perhaps the dub page could be updated?
Tried to continue following the instructions. Ran: profdump -b trace.log trace.log.b Got: core.exception.RangeError source/app.d(134): Range violation ---------------- ??:? [0x557458c2bad5] ??:? [0x557458c2d556] ??:? [0x557458c147af] ??:? [0x557458c0b458] ??:? [0x557458c0bb47] app.d:133 [0x557458b96199] ??:? [0x557458c1449b] ??:? [0x557458c14397] ??:? [0x557458c141ed] /home/jg/dlang/ldc-1.26.0/bin/../import/core/internal/entrypoint.d:42 [0x557458b979d4] ??:? __libc_start_main [0x7f0f84d39cb1] ??:? [0x557458b4a0cd]
Aug 24 2021
parent reply JG <JG somewhere.com> writes:
On Tuesday, 24 August 2021 at 09:45:31 UTC, JG wrote:
 On Tuesday, 24 August 2021 at 09:42:29 UTC, JG wrote:
 On Tuesday, 24 August 2021 at 09:36:06 UTC, JG wrote:
 [...]
In case anyone is interested it seems that it was forked to here: https://github.com/joakim-brannstrom/profdump Perhaps the dub page could be updated?
Tried to continue following the instructions. Ran: profdump -b trace.log trace.log.b Got: core.exception.RangeError source/app.d(134): Range violation ---------------- ??:? [0x557458c2bad5] ??:? [0x557458c2d556] ??:? [0x557458c147af] ??:? [0x557458c0b458] ??:? [0x557458c0bb47] app.d:133 [0x557458b96199] ??:? [0x557458c1449b] ??:? [0x557458c14397] ??:? [0x557458c141ed] /home/jg/dlang/ldc-1.26.0/bin/../import/core/internal/entrypoint.d:42 [0x557458b979d4] ??:? __libc_start_main [0x7f0f84d39cb1] ??:? [0x557458b4a0cd]
The reason for the crash boils down to the fact that this fails: foreach(k; sort!"a > b"(funcs.keys)) assert(k in funcs); funcs is of type ubyte[4][float] Is this a compiler bug?
Aug 24 2021
parent =?UTF-8?B?UmVuw6k=?= Zwanenburg <renezwanenburg gmail.com> writes:
On Tuesday, 24 August 2021 at 10:33:07 UTC, JG wrote:
 The reason for the crash boils down to the fact that this fails:

 foreach(k; sort!"a > b"(funcs.keys)) assert(k in funcs);

 funcs is of type ubyte[4][float]

 Is this a compiler bug?
That assert will fail if there are NaN keys in the AA. This for example will print null: ```d bool[float] aa; aa[float.nan] = true; writeln(float.nan in aa); ``` Sort may also act funny when NaNs are involved, not sure about that.
Aug 25 2021
prev sibling parent James Blachly <james.blachly gmail.com> writes:
On 2/9/21 12:45 AM, JG wrote:
 I was trying to profile a d program. So I ran: dub build 
 --build=profile. I then ran the program and it produced trace.log and 
 trace.def. I then ran d-profile-viewer and got the following error:
 
 std.conv.ConvException /home/jg/dlang/ldc-1.24.0/bin/../impo
t/std/conv.d(2382): 
 Unexpected '-' when converting from type char[] to type ulong
 ----------------
 ??:? [0x564a8630fda5]
 ??:? [0x564a86333286]
 ??:? [0x564a863199fd]
 /home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d:2382 [0x564a862c89a1]
 /home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d:1941 [0x564a862c86cc]
 /home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d:223 [0x564a862c869c]
 app.d:1095 [0x564a862cdd71]
 app.d:1138 [0x564a862ce7ba]
 ??:? [0x564a863196cb]
 ??:? [0x564a863195c7]
 ??:? [0x564a8631941d]
 /home/jg/dlang/ldc-1.24.0/bin/../import/core/internal/entrypoint.d:42 
 [0x564a862ce7e4]
 ??:? __libc_start_main [0x7fd482807cb1]
 
 Is d-profile-viewer no longer working? Or did I do something wrong?
Speaking of D profile viewer [1] we had good luck with it after fixing the missing timestamps in the profile (I think on Linux platforms it cannot actually measure times and so we had to rewrite the profile file to generate some fake timestamp(s) or timings -- hazy on details). Anyway, if you can get it working it was a nice callgraph tool [1] https://bitbucket.org/andrewtrotman/d-profile-viewer/src/master/
Feb 12 2021