digitalmars.D.learn - LDC2 and classic profiling
- Denis Feklushkin (7/7) May 10 2019 Build with dub some package. Profiling are enabled by dub.json:
- Johan Engelen (7/15) May 10 2019 You only need `-fprofile-instr-generate` for generating
- Denis Feklushkin (8/14) May 10 2019 Yes. Probably, it was uftrace output.
- Denis Feklushkin (10/12) May 10 2019 Tried to remove lambda with same result.
- Johan Engelen (11/26) May 11 2019 Those calls are to templated functions I presume? (they are
- Denis Feklushkin (7/21) May 11 2019 Ok.
- Denis Feklushkin (5/7) May 11 2019 Maybe DUB caches binaries and linker links previous
- Denis Feklushkin (2/6) May 12 2019 Checked with "dub -f" and nothing changed.
- Johan Engelen (19/42) May 12 2019 Then I don't understand how you'd see instrumentation on
- Denis Feklushkin (12/17) May 13 2019 Got it!
Build with dub some package. Profiling are enabled by dub.json: "dflags-ldc": ["-fprofile-instr-generate", "-finstrument-functions", "-cov"], Resulting default.profraw (and generated default.profdata) contains only calls to external libraries, but not my internal functions calls. Why?
May 10 2019
On Friday, 10 May 2019 at 14:00:30 UTC, Denis Feklushkin wrote:Build with dub some package. Profiling are enabled by dub.json: "dflags-ldc": ["-fprofile-instr-generate", "-finstrument-functions", "-cov"], Resulting default.profraw (and generated default.profdata) contains only calls to external libraries, but not my internal functions calls. Why?You only need `-fprofile-instr-generate` for generating default.profraw.contains only calls to external librariesThat's impossible, because those are exactly _not_ profiled. This may help: https://forum.dlang.org/post/voknxddblrbuywcyfdwt forum.dlang.org -Johan
May 10 2019
On Friday, 10 May 2019 at 18:09:28 UTC, Johan Engelen wrote:You only need `-fprofile-instr-generate` for generating default.profraw.Yep, it is because I also tried to use uftrace and xrayYes. Probably, it was uftrace output. But, nevertheless, I do not see calls of my own functions. In addition to the call _Dmain and _D4mainQfFAAyaZ9__lambda2MFZv All another calls is made inside of this lambda - maybe lambdas is not traced by profiler?contains only calls to external librariesThat's impossible, because those are exactly _not_ profiled.This may help: https://forum.dlang.org/post/voknxddblrbuywcyfdwt forum.dlang.orgAlready read it.
May 10 2019
On Saturday, 11 May 2019 at 05:46:29 UTC, Denis Feklushkin wrote:All another calls is made inside of this lambda - maybe lambdas is not traced by profiler?Tried to remove lambda with same result. Command: llvm-profdata show -all-functions -topn=100000 default.profdata returns huge amount of std*, core*, vibe* calls - it is all used in my code. But here is no one my own function (except "main"). Also I changed flags to "dflags-ldc": ["-fprofile-instr-generate", "-O0"] - second flag disables optimisation (I assumed that optimizations magically completely remove calls to my functions. But this is probably not the case.)
May 10 2019
On Saturday, 11 May 2019 at 06:59:52 UTC, Denis Feklushkin wrote:On Saturday, 11 May 2019 at 05:46:29 UTC, Denis Feklushkin wrote:Those calls are to templated functions I presume? (they are instantiated in your program and hence instrumented)All another calls is made inside of this lambda - maybe lambdas is not traced by profiler?Tried to remove lambda with same result. Command: llvm-profdata show -all-functions -topn=100000 default.profdata returns huge amount of std*, core*, vibe* calls - it is all used in my code. But here is no one my own function (except "main").Also I changed flags to "dflags-ldc": ["-fprofile-instr-generate", "-O0"] - second flag disables optimisation (I assumed that optimizations magically completely remove calls to my functions. But this is probably not the case.)No, indeed, -O0 doesn't (shouldn't!) matter. It is strange that you don't see calls to your functions. Just to verify, could you compile a simple program manually (without dub) and verify that you see calls to your own functions? Lambdas should also be instrumented, so please test that. By the way, if you are on linux, then XRay should work like with clang ( -fxray-instrument ) -Johan
May 11 2019
On Saturday, 11 May 2019 at 09:12:24 UTC, Johan Engelen wrote:Those calls are to templated functions I presume?Noinstantiated in your program and hence instrumented)Ok.Also I changed flags to "dflags-ldc": ["-fprofile-instr-generate", "-O0"] - second flag disables optimisation (I assumed that optimizations magically completely remove calls to my functions. But this is probably not the case.)No, indeed, -O0 doesn't (shouldn't!) matter.It is strange that you don't see calls to your functions. Just to verify, could you compile a simple program manually (without dub) and verify that you see calls to your own functions?Tried, and it works!Lambdas should also be instrumented, so please test that.Works on simple program too.By the way, if you are on linux, then XRay should work like with clang ( -fxray-instrument )Tried it, and xray also does not returns any info about my own functions...
May 11 2019
On Saturday, 11 May 2019 at 11:34:35 UTC, Denis Feklushkin wrote:Tried it, and xray also does not returns any info about my own functions...Maybe DUB caches binaries and linker links previous non-instrumented object files? I tried "dub clean" and "dub clean-caches" but maybe it is need remove someting else?
May 11 2019
On Saturday, 11 May 2019 at 11:38:17 UTC, Denis Feklushkin wrote:Maybe DUB caches binaries and linker links previous non-instrumented object files? I tried "dub clean" and "dub clean-caches" but maybe it is need remove someting else?Checked with "dub -f" and nothing changed.
May 12 2019
On Saturday, 11 May 2019 at 11:34:35 UTC, Denis Feklushkin wrote:On Saturday, 11 May 2019 at 09:12:24 UTC, Johan Engelen wrote:Then I don't understand how you'd see instrumentation on functions that you did not compile with -fprofile-instr-generate (indirect calls to such functions may be recorded); the std lib is not compiled with profiling instrumentation, and so you shouldn't see any internal instrumentation of it. Unless those functions are instantiated in your object file (e.g. templates or explicitly inlined functions).Those calls are to templated functions I presume?NoExcellent. I think dub -v will output the exact commands that dub is executing. Looks like some parts are not compiled with the compile flag, and some other parts are?Ok.Also I changed flags to "dflags-ldc": ["-fprofile-instr-generate", "-O0"] - second flag disables optimisation (I assumed that optimizations magically completely remove calls to my functions. But this is probably not the case.)No, indeed, -O0 doesn't (shouldn't!) matter.It is strange that you don't see calls to your functions. Just to verify, could you compile a simple program manually (without dub) and verify that you see calls to your own functions?Tried, and it works!Lambdas should also be instrumented, so please test that.Works on simple program too.You tried with DUB or manually? Note that XRay has a (configurable) threshold for not instrumenting very small functions. See for example this test: https://github.com/ldc-developers/ldc/blob/master/tests/instrument/xray_simple_execution.d -JohanBy the way, if you are on linux, then XRay should work like with clang ( -fxray-instrument )Tried it, and xray also does not returns any info about my own functions...
May 12 2019
On Sunday, 12 May 2019 at 17:24:24 UTC, Johan Engelen wrote:Excellent. I think dub -v will output the exact commands that dub is executing. Looks like some parts are not compiled with the compile flag, and some other parts are?Got it! -v displays only one ldc2 execution with -fprofile-instr-generate It contains huge number of -I and -dversion options, and this call contains main.d compilation. But main.d placed inside of subpackage and uses my own (outer) dependency package which also compiled without -fprofile-instr-generate and calls inside of this dependency is not displayed! So, all another ldc2 calls which compiles dependencies is not contain -fprofile-instr-generate! (Also, xray was affected same misconfiguration) Thanks!
May 13 2019