New to profiling: dmd -profile; ldc2 --fdmd-trace-functions

2023-03-31 Thread Paul via Digitalmars-d-learn

Thanks in advance for any assistance.

As the subject line states I'm just now trying to learn 
profiling.  I have a very small program with 1/2 dozen functions 
and would like to see where the cpu is spending the most time.


I've tried both of these lines with identical results:
**ldc2 --fdmd-trace-functions myprog.d**
**dmd -profile myprog.d**

The result is that no 'trace' files are generatedas far as I 
can tell.  When I run myprog.exe it generates no errors, runs 
very quickly, and does not do what it previously was doing.


**ldc2 --version**
**LDC - the LLVM D compiler (1.30.0-git-5fd86e5):**
**based on DMD v2.100.1 and LLVM 14.0.3**

**dmd --version**
**DMD64 D Compiler v2.100.2-dirty**


Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn

On Sunday, 13 November 2022 at 19:02:29 UTC, mw wrote:
BTW, can --build=profile-gc can intercept "Ctrl+C" and 
generate *partial* report file?


And what's the suggested proper way to do


Is there a profile-gc plugin function I can call in the middle of 
my program to generate *partial* report file?


Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn

On Sunday, 13 November 2022 at 18:51:17 UTC, mw wrote:

On Sunday, 13 November 2022 at 18:48:42 UTC, mw wrote:
BTW, can --build=profile-gc can intercept "Ctrl+C" and 
generate *partial* report file?


And what's the suggested proper way to do early exit, and 
still let --build=profile-gc generate reports?


I tried presss "Ctrl+C", and that cannot stop the program, it 
just hangs there.


I have to `kill -9 ` it to get it stopped.


My build command is:
```
/dmd2/linux/bin64/dub build --build=profile-gc --config=... 
--compiler=dmd

```



Re: does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn

On Sunday, 13 November 2022 at 18:48:42 UTC, mw wrote:
BTW, can --build=profile-gc can intercept "Ctrl+C" and generate 
*partial* report file?


And what's the suggested proper way to do early exit, and still 
let --build=profile-gc generate reports?


I tried presss "Ctrl+C", and that cannot stop the program, it 
just hangs there.


I have to `kill -9 ` it to get it stopped.


does dmd --build=profile-gc work with core.stdc.stdlib.exit()?

2022-11-13 Thread mw via Digitalmars-d-learn

Hi,

I'm mem-profiling a multi-threaded program, and want it to exit 
early, so I added a call

```
core.stdc.stdlib.exit(-1);
```

in a loop in one of the thread.

However when the program reached this point, it seems hang: it's 
not exiting, and CPU usage dropped to 0%.


I'm wondering does dmd --build=profile-gc work with 
core.stdc.stdlib.exit()?


And where is the output report file, and the filename? I didn't 
see any report file generated in the current working dir.


BTW, can --build=profile-gc can intercept "Ctrl+C" and generate 
*partial* report file?


And what's the suggested proper way to do early exit, and still 
let --build=profile-gc generate reports?


Thanks!


Re: How to profile compile times of a source code?

2021-08-08 Thread Vladimir Panteleev via Digitalmars-d-learn

On Saturday, 30 January 2021 at 22:47:39 UTC, Ahmet Sait wrote:
I'm looking for ways to figure out what parts of the code slows 
down the compiler other than brute force trial.


You could try some of the tools listed on the wiki for build time 
profiling:


https://wiki.dlang.org/Development_tools#Build_time_profiling

(intentional bump to aid search results, as apparently this list 
is not very well known)


Re: How to profile compile times of a source code?

2021-01-31 Thread Johan via Digitalmars-d-learn

On Sunday, 31 January 2021 at 16:39:12 UTC, Boris Carvajal wrote:

On Sunday, 31 January 2021 at 16:13:24 UTC, Anonymouse wrote:
Does ldc produce traces in a format that Tracy supports? I 
can't seem to open the generated *.time-trace files with it. 
(tracy 0.7.5-1 installed from Arch Linux AUR.)


Use the 'import-chrome' tool bundled in Tracy to convert it.


Indeed. It's a little annoying that you will see many horizontal 
'traces' in tracy and probably will have to scroll all the way 
down to see the actual LDC trace.
It's a tradeoff I made between nicely displayed trace block 
names, vs. using only a few categories... Maybe other people can 
chime in a figure out a better way of outputting the trace item 
names (we are using LLVM functionality here btw).


-Johan



Re: How to profile compile times of a source code?

2021-01-31 Thread Boris Carvajal via Digitalmars-d-learn

On Sunday, 31 January 2021 at 16:13:24 UTC, Anonymouse wrote:

On Sunday, 31 January 2021 at 12:31:59 UTC, Johan Engelen wrote:
Try LDC 1.25 (now in beta testing) with --ftime-trace. Clang 
has the same option, so you can read more about it online in 
that context. Be sure to check out the related commandline 
flags.
I recommend the Tracy UI to look at traces, because it is by 
far the fastest viewer of large traces. 
https://github.com/wolfpld/tracy


-Johan


Does ldc produce traces in a format that Tracy supports? I 
can't seem to open the generated *.time-trace files with it. 
(tracy 0.7.5-1 installed from Arch Linux AUR.)


Use the 'import-chrome' tool bundled in Tracy to convert it.


Re: How to profile compile times of a source code?

2021-01-31 Thread Anonymouse via Digitalmars-d-learn

On Sunday, 31 January 2021 at 12:31:59 UTC, Johan Engelen wrote:
Try LDC 1.25 (now in beta testing) with --ftime-trace. Clang 
has the same option, so you can read more about it online in 
that context. Be sure to check out the related commandline 
flags.
I recommend the Tracy UI to look at traces, because it is by 
far the fastest viewer of large traces. 
https://github.com/wolfpld/tracy


-Johan


Does ldc produce traces in a format that Tracy supports? I can't 
seem to open the generated *.time-trace files with it. (tracy 
0.7.5-1 installed from Arch Linux AUR.)


Re: How to profile compile times of a source code?

2021-01-31 Thread Imperatorn via Digitalmars-d-learn

On Sunday, 31 January 2021 at 12:31:59 UTC, Johan Engelen wrote:

On Sunday, 31 January 2021 at 12:16:50 UTC, Imperatorn wrote:
On Saturday, 30 January 2021 at 23:34:50 UTC, Stefan Koch 
wrote:

[...]


Interesting. Is this something that we could get into dmd with 
a switch? 🤔


Try LDC 1.25 (now in beta testing) with --ftime-trace. Clang 
has the same option, so you can read more about it online in 
that context. Be sure to check out the related commandline 
flags.
I recommend the Tracy UI to look at traces, because it is by 
far the fastest viewer of large traces. 
https://github.com/wolfpld/tracy


-Johan


Cool, will take a look 👍


Re: How to profile compile times of a source code?

2021-01-31 Thread Johan Engelen via Digitalmars-d-learn

On Sunday, 31 January 2021 at 12:16:50 UTC, Imperatorn wrote:

On Saturday, 30 January 2021 at 23:34:50 UTC, Stefan Koch wrote:

On Saturday, 30 January 2021 at 22:47:39 UTC, Ahmet Sait wrote:

[...]


I have a way of getting the profile data your are after.
Get the dmd_tracing_20942 branch from 
https://github.com/UplinkCoder/dmd

Compile that version of dmd.
this special version of dmd will generate a trace file which 
can be read with the included printTraceHeader tool


Interesting. Is this something that we could get into dmd with 
a switch? 🤔


Try LDC 1.25 (now in beta testing) with --ftime-trace. Clang has 
the same option, so you can read more about it online in that 
context. Be sure to check out the related commandline flags.
I recommend the Tracy UI to look at traces, because it is by far 
the fastest viewer of large traces. 
https://github.com/wolfpld/tracy


-Johan



Re: How to profile compile times of a source code?

2021-01-31 Thread Imperatorn via Digitalmars-d-learn

On Saturday, 30 January 2021 at 23:34:50 UTC, Stefan Koch wrote:

On Saturday, 30 January 2021 at 22:47:39 UTC, Ahmet Sait wrote:

[...]


I have a way of getting the profile data your are after.
Get the dmd_tracing_20942 branch from 
https://github.com/UplinkCoder/dmd

Compile that version of dmd.
this special version of dmd will generate a trace file which 
can be read with the included printTraceHeader tool


Interesting. Is this something that we could get into dmd with a 
switch? 🤔


Re: How to profile compile times of a source code?

2021-01-30 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 30 January 2021 at 23:34:50 UTC, Stefan Koch wrote:


this special version of dmd will generate a trace file which 
can be read with the included printTraceHeader tool


you will want to take a look at the PhaseHist command which shows 
you the compiler phase that took the most time.


Alternative I recommend using callgrind to profile where dmd 
spents most of it's time.

For that to be useful you need a debug build of dmd though.




Re: How to profile compile times of a source code?

2021-01-30 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 30 January 2021 at 22:47:39 UTC, Ahmet Sait wrote:
I'm looking for ways to figure out what parts of the code slows 
down the compiler other than brute force trial.


Can I use -vtemplates switch for this?
Would -v (verbose) switch helpful in some way?
How would I know if my bottleneck is ctfe or templates?
How do the compiler devs approach this issue?

I'm interested in all kinds of tricks to the point of debugging 
the compiler itself although anything less complicated would be 
appreciated.


I have a way of getting the profile data your are after.
Get the dmd_tracing_20942 branch from 
https://github.com/UplinkCoder/dmd

Compile that version of dmd.
this special version of dmd will generate a trace file which can 
be read with the included printTraceHeader tool




How to profile compile times of a source code?

2021-01-30 Thread Ahmet Sait via Digitalmars-d-learn
I'm looking for ways to figure out what parts of the code slows 
down the compiler other than brute force trial.


Can I use -vtemplates switch for this?
Would -v (verbose) switch helpful in some way?
How would I know if my bottleneck is ctfe or templates?
How do the compiler devs approach this issue?

I'm interested in all kinds of tricks to the point of debugging 
the compiler itself although anything less complicated would be 
appreciated.


Re: Is there a way to benchmark/profile portably?

2020-05-07 Thread Dukc via Digitalmars-d-learn

On Thursday, 7 May 2020 at 10:51:27 UTC, Simen Kjærås wrote:


If I understand correctly, you want to measure how many cycles 
pass, rather than clock time?


Something like that. Well, I would also like to eliminate 
differences based on different memory caches between machines.


In addition, if the profiler could eliminate the randomness of 
the benchamrks that results from memory aligment, context 
switches and dunno, that would obviously be a big plus for 
automatic testing.




If so, it seems perf can do that: 
https://perf.wiki.kernel.org/index.php/Tutorial



Sounds worth a look. Thanks!


Re: Is there a way to benchmark/profile portably?

2020-05-07 Thread Dukc via Digitalmars-d-learn

On Thursday, 7 May 2020 at 11:06:17 UTC, Dennis wrote:


You can make a reference program that you use to get a measure 
for how fast the computer is that you run the benchmark on. 
Then you can use that to scale your actual benchmark results.


When testing regressions there's a fairly obvious choice for 
this reference program: the old version. You can compare those 
results with the new version and report the relative difference.


I have to keep that in mind, but I'd prefer something that does 
not require keeping old sources working, or floating their 
binaries around.




Re: Is there a way to benchmark/profile portably?

2020-05-07 Thread Dennis via Digitalmars-d-learn

On Thursday, 7 May 2020 at 10:21:07 UTC, Dukc wrote:
Is there some way to measure the performance of a function so 
that the results will be same in different computers (all x86, 
but otherwise different processors)? I'm thinking of making a 
test suite that could find performance regressions 
automatically.


You can make a reference program that you use to get a measure 
for how fast the computer is that you run the benchmark on. Then 
you can use that to scale your actual benchmark results.


When testing regressions there's a fairly obvious choice for this 
reference program: the old version. You can compare those results 
with the new version and report the relative difference.


Re: Is there a way to benchmark/profile portably?

2020-05-07 Thread Simen Kjærås via Digitalmars-d-learn

On Thursday, 7 May 2020 at 10:21:07 UTC, Dukc wrote:
Is there some way to measure the performance of a function so 
that the results will be same in different computers (all x86, 
but otherwise different processors)? I'm thinking of making a 
test suite that could find performance regressions 
automatically.


I figured out Bochs[1] could be used for that, but it seems an 
overkill for me to install a whole virtual operating system 
just to benchmark functions. Does anybody know more lightweight 
way?


[1] http://bochs.sourceforge.net/


If I understand correctly, you want to measure how many cycles 
pass, rather than clock time?


If so, it seems perf can do that: 
https://perf.wiki.kernel.org/index.php/Tutorial


--
  Simen


Is there a way to benchmark/profile portably?

2020-05-07 Thread Dukc via Digitalmars-d-learn
Is there some way to measure the performance of a function so 
that the results will be same in different computers (all x86, 
but otherwise different processors)? I'm thinking of making a 
test suite that could find performance regressions automatically.


I figured out Bochs[1] could be used for that, but it seems an 
overkill for me to install a whole virtual operating system just 
to benchmark functions. Does anybody know more lightweight way?


[1] http://bochs.sourceforge.net/


How to use -profile when I initialize D-runtime myself?

2020-01-15 Thread Robert M. Münch via Digitalmars-d-learn

Hi, I had a related question in the "Does -profile need the D runtime?" thread.

Since D runtime is required for profile to work, the question is how 
can I use profile when initializing it myself?


--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Issue with --build=profile

2019-10-18 Thread drkameleon via Digitalmars-d-learn
I'm working on a rather big project which I'm compiling with 
DMD/LDC.


The thing is when I'm trying to profile it, using `dub build 
--build=profile`, weird issues keep popping up, coming from the 
project's dependencies... eg. "Warning: statement is not 
reachable" from the dyaml package. And then it crashes with 
"/Library/D/dmd/bin/dmd failed with exit code 1."


How could I deal with this?

(In case it matters, I could also point you to my project 
sources, although I don't think it has anything to do with my 
project per-se)


Re: Does -profile need the D runtime?

2019-05-19 Thread Robert M. Münch via Digitalmars-d-learn

On 2019-05-18 17:46:52 +, Stefan Koch said:


On Saturday, 18 May 2019 at 16:35:44 UTC, Robert M. Münch wrote:
I want to profile my windows app which has a WinMain(). One of the 
first statements in WinMain() within a try{} is:


Runtime.initialize();

But when I compile my app with -profile, it crashes on entry of 
WinMain(). Looks like this function is instrumented with code, that 
might need the D runtime. Is this the case?


Is there a way to flag specific functions as "don't profile"?


yes profiling does relay on druntime being present.

There is currently no such thing as "don't profile"


Ok, thanks.

So, how to best do it when compiling a windows program? I read that 
with WinMain() it's necessary to start the druntime manually. Which is 
to late when using the profiler. Or am I missing something?


--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: Does -profile need the D runtime?

2019-05-18 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 18 May 2019 at 16:35:44 UTC, Robert M. Münch wrote:
I want to profile my windows app which has a WinMain(). One of 
the first statements in WinMain() within a try{} is:


Runtime.initialize();

But when I compile my app with -profile, it crashes on entry of 
WinMain(). Looks like this function is instrumented with code, 
that might need the D runtime. Is this the case?


Is there a way to flag specific functions as "don't profile"?


yes profiling does relay on druntime being present.

There is currently no such thing as "don't profile"


Does -profile need the D runtime?

2019-05-18 Thread Robert M. Münch via Digitalmars-d-learn
I want to profile my windows app which has a WinMain(). One of the 
first statements in WinMain() within a try{} is:


Runtime.initialize();

But when I compile my app with -profile, it crashes on entry of 
WinMain(). Looks like this function is instrumented with code, that 
might need the D runtime. Is this the case?


Is there a way to flag specific functions as "don't profile"?

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-10 Thread Simon via Digitalmars-d-learn

On Saturday, 9 March 2019 at 09:12:13 UTC, Dennis wrote:

On Friday, 8 March 2019 at 11:42:11 UTC, Simon wrote:
Thanks, this works flawlessly. Out of interest: what is the 
"enum" doing there? I had the exact same behaviour in a 
function before, that I only called at compile-time, so why 
did it complain then? Can I somehow tell the compiler that a 
function should only be available at compile-time?


The enum (which in D is not only for enumerations, but also for 
"manifest constants") ensures it is evaluated at compile-time, 
since things are only evaluated at compile-time if they have to.

See also Adam D. Ruppe's post in this thread:
https://forum.dlang.org/post/blaawtdhljjantvga...@forum.dlang.org


Thanks!


Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-09 Thread Dennis via Digitalmars-d-learn

On Friday, 8 March 2019 at 11:42:11 UTC, Simon wrote:
Thanks, this works flawlessly. Out of interest: what is the 
"enum" doing there? I had the exact same behaviour in a 
function before, that I only called at compile-time, so why did 
it complain then? Can I somehow tell the compiler that a 
function should only be available at compile-time?


The enum (which in D is not only for enumerations, but also for 
"manifest constants") ensures it is evaluated at compile-time, 
since things are only evaluated at compile-time if they have to.

See also Adam D. Ruppe's post in this thread:
https://forum.dlang.org/post/blaawtdhljjantvga...@forum.dlang.org


Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-08 Thread Simon via Digitalmars-d-learn

On Thursday, 7 March 2019 at 21:50:17 UTC, Johannes Loher wrote:

```
enum profile_scope(string name) = "import core.stdc.stdio : 
printf;

printf(\""
~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");";

extern (C) void main()
{
mixin(profile_scope!"func1");
}

```
This uses string concatenation only at compile time and not 
during run
time, so it does not require the garbage collector and is 
compatible

with betterC :)


Thanks, this works flawlessly. Out of interest: what is the 
"enum" doing there? I had the exact same behaviour in a function 
before, that I only called at compile-time, so why did it 
complain then? Can I somehow tell the compiler that a function 
should only be available at compile-time?


Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 22:50 schrieb Johannes Loher:
> [...]

As a small addition, if you always want to pass the function name as a
parameter, you can simplify this to the following:

```
enum profile_scope(string name = __FUNCTION__) = "import core.stdc.stdio
: printf; printf(\""
~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");";

extern (C) void main()
{
mixin(profile_scope!());
foo();
}

extern (C) void foo() {
mixin(profile_scope!());
}
```
This will print
```
main.main
main.foo
main.foo
main.main
```
to the commandline.



Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 22:21 schrieb Simon:
> 
> Is there a way to achieve this while compiling with -betterC? I use a
> custom string struct right now, and your version needs TypeInfo,
> concatening using ~ needs the garbage collector. I have the feeling D is
> really not agreeing with the way I want to do things. If this is not
> possible, I will just roll with the Adam's struct solution.
> 

Using Adams struct solution is perfectly fine. I believe it is probably
the cleaner solution overall.

My solution depends on TypeInfo because format does. I used format
because it makes the string more readable. You can avoid this and use
string concatenation in combination with providing the function name as
template parameter instead:

```
enum profile_scope(string name) = "import core.stdc.stdio : printf;
printf(\""
~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");";

extern (C) void main()
{
mixin(profile_scope!"func1");
}

```
This uses string concatenation only at compile time and not during run
time, so it does not require the garbage collector and is compatible
with betterC :)


Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Simon via Digitalmars-d-learn

On Thursday, 7 March 2019 at 20:34:48 UTC, Johannes Loher wrote:


auto profile_scope(string name)
{
import std.format : format;
return q{import std.stdio : writeln; writeln("%1$s"); 
scope(exit)

writeln("%1$s");}.format(name);
}

void main()
{
mixin(profile_scope("func1"));
}


Is there a way to achieve this while compiling with -betterC? I 
use a custom string struct right now, and your version needs 
TypeInfo, concatening using ~ needs the garbage collector. I have 
the feeling D is really not agreeing with the way I want to do 
things. If this is not possible, I will just roll with the Adam's 
struct solution.




Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Johannes Loher via Digitalmars-d-learn
Am 07.03.19 um 21:07 schrieb Simon:
> Hello,
> 
> I am currently porting the frontend of my instrumenting profiler to D.
> It features a C++-makro that profiles the time between entering and
> leaving a scope (achieved with con-/destructors in C++). Since D has
> scopeguards, I hoped to achieve this by creating a mixin that generates
> the following code:
> 
> measure("func1");
> scope(exit) measure("func1");
> 
> Since I of course don't want to type a mixin for that everytime I want
> to use it, I tried to alias it:
> 
> import std.meta : Alias;
> alias profile_scope(string name) = Alias!(mixin("measure(\"" ~ name ~
> "\"); scope(exit) measure(\"" ~ name ~ "\");"));
> 
> I expected this to generate the code above by typing
> profile_scope("func1") in my programm. However the compiler (dmd) gives
> me the following error:
> 
> source\main.d(24): Error: template plattform.profile_scope cannot deduce
> function from argument types !()(string), candidates are:
> source\plattform.d(262):    plattform.profile_scope(string name)
> 
> This looks like a deduction/overload kind of error, which has me
> completly confused since there is no other identifier of the name
> "profile_scope" in my programm and the error message shows only one
> candidate.
> 
> Is there any way I can achive generating those two statements using only
> something that effectively looks like a function call/C-macro with an
> argument?
The error you are seeing is due to the fact that you pass "func1" as
runtime parameter instead of as a teamplate parameter. You would need to
do `profile_scope!("func1");`. However, this will still not work and
you'll get an error message similar to this:
```
main.d(4): Error: incomplete mixin expression writeln("func1");
scope(exit) writeln("func1");
main.d(8): Error: template instance `main.profile_scope!"func1"` error
instantiating
```

The underlying problem is that you can only alias expressions, i.e. you
cannot use alias to generate macro like functionality.

`measure("func1"); scope(exit) measure("func1");` is not an expression,
it is simply a statement, so the alias cannot work.

If you want to inject code directly at some place, basically your only
option is to use a string mixin. I understand that you do not want to
write `mixin` all the time, but to me, this does not look that bad:
```
auto profile_scope(string name)
{
import std.format : format;
return q{import std.stdio : writeln; writeln("%1$s"); scope(exit)
writeln("%1$s");}.format(name);
}

void main()
{
mixin(profile_scope("func1"));
}
```
(replace writeln with your appropriate function call, "measure" in your
example).



Re: Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 7 March 2019 at 20:07:27 UTC, Simon wrote:

measure("func1");
scope(exit) measure("func1");


I would suggest just using a struct. Make its constructor do the 
first measure, and its destructor do the second measure.


I betcha you can avoid mixin entirely.


Aliasing a mixin (or alternative ways to profile a scope)

2019-03-07 Thread Simon via Digitalmars-d-learn

Hello,

I am currently porting the frontend of my instrumenting profiler 
to D. It features a C++-makro that profiles the time between 
entering and leaving a scope (achieved with con-/destructors in 
C++). Since D has scopeguards, I hoped to achieve this by 
creating a mixin that generates the following code:


measure("func1");
scope(exit) measure("func1");

Since I of course don't want to type a mixin for that everytime I 
want to use it, I tried to alias it:


import std.meta : Alias;
alias profile_scope(string name) = Alias!(mixin("measure(\"" ~ 
name ~ "\"); scope(exit) measure(\"" ~ name ~ "\");"));


I expected this to generate the code above by typing 
profile_scope("func1") in my programm. However the compiler (dmd) 
gives me the following error:


source\main.d(24): Error: template plattform.profile_scope cannot 
deduce function from argument types !()(string), candidates are:
source\plattform.d(262):plattform.profile_scope(string 
name)


This looks like a deduction/overload kind of error, which has me 
completly confused since there is no other identifier of the name 
"profile_scope" in my programm and the error message shows only 
one candidate.


Is there any way I can achive generating those two statements 
using only something that effectively looks like a function 
call/C-macro with an argument?


Re: Understanding gc memory profile report

2017-09-08 Thread Ali Çehreli via Digitalmars-d-learn


Although I responded below, I'm curious on what others think about this 
question.


On 09/08/2017 02:13 AM, John Burton wrote:
> I wrote this simple program to test out my understanding of memory
> allocation :-

I changed it to display the location and capacity:

import std.stdio;

void info(A)(A array) {
writefln("ptr: %s, capacity: %s, length: %s",
 array.ptr, array.capacity, array.length);
}

void main()
{
int [] array = new int[250];

info(array);

// Append one value to the array
array ~= 123;
info(array);
}

Sample output:

ptr: 7FD9B63CD000, capacity: 255, length: 250
ptr: 7FD9B63CD000, capacity: 255, length: 251

> I compiled it with 'dmd test.d -profile=gc'
>
> After running it, the profile report was :-
>
> bytes allocated, allocations, type, function, file:line
>2000   1 int[] D main test.d:5
>   4   1 int[] D main test.d:10

Here's my output with v2.076.0-dirty (that really is the version :o)):

   4000   1 int[] D main deneme.d:412
 72	  1	std.format.FormatException 
std.exception.enforceEx!(FormatException).enforceEx!bool.enforceEx 
/usr/include/dmd/phobos/std/exception.d:615
 64	  2	std.array.Appender!string.Appender.Data 
std.array.Appender!string.Appender.this 
/usr/include/dmd/phobos/std/array.d:2817
 32	  1 
std.array.Appender!(char[]).Appender.Data 
std.array.Appender!(char[]).Appender.this 
/usr/include/dmd/phobos/std/array.d:2817

  4   1 int[] D main deneme.d:417

And why is mine 4000 bytes? I guess it's the size of the underlying buffer.

> This is not how I expected it to be. I would have expected that the
> runtime either did not have to allocate at all at line 10 to add a new
> element because there was already space or it would have to allocate
> space for the new enlarged array and copy the array to it, in which case
> I'd expect it to allocate 2004 bytes (or more) to copy the enlarged
> array in to.
>
> I would not expect that it could have allocated 4 bytes to add an item
> separably from the original 2000. Is there some way that the runtime can
> grown the original allocation by 4 bytes and that's what I'm seeing? If
> so, is there a limit to how much it can do this?
>
> Can anyone help me understand what is going on here?

I think you're right. Perhaps more accurate information is not possible 
with the current implementation. Perhaps a higher-layer function counts 
"potential" allocations without being sure whether the space could be 
used for this slice or not. The "D Slices" article has related information:


  https://dlang.org/d-array-article.html

Ali



Understanding gc memory profile report

2017-09-08 Thread John Burton via Digitalmars-d-learn
I wrote this simple program to test out my understanding of 
memory allocation :-


import std.stdio;

void main()
{
int [] array = new int[250];

writeln(array.length, " elements ", array);

// Append one value to the array
array ~= 123;
writeln(array.length, " elements ", array);
}

I compiled it with 'dmd test.d -profile=gc'

After running it, the profile report was :-

bytes allocated, allocations, type, function, file:line
   2000   1 int[] D main test.d:5
  4   1 int[] D main test.d:10

This is not how I expected it to be. I would have expected that 
the runtime either did not have to allocate at all at line 10 to 
add a new element because there was already space or it would 
have to allocate space for the new enlarged array and copy the 
array to it, in which case I'd expect it to allocate 2004 bytes 
(or more) to copy the enlarged array in to.


I would not expect that it could have allocated 4 bytes to add an 
item separably from the original 2000. Is there some way that the 
runtime can grown the original allocation by 4 bytes and that's 
what I'm seeing? If so, is there a limit to how much it can do 
this?


Can anyone help me understand what is going on here?



Re: Can compiler profile itself?

2017-01-25 Thread Profile Anaysis via Digitalmars-d-learn

On Wednesday, 25 January 2017 at 12:49:05 UTC, Stefan Koch wrote:
On Tuesday, 24 January 2017 at 23:25:12 UTC, Profile Anaysis 
wrote:
I am trying to compile some code and it takes around 6 
seconds. Even if I change one line in one module, it takes the 
same time. There are about 20 different d modules.


[...]


yes the compiler can be used to profile itself.
build it with make ENABLE_PROFILE=1

If your code is overly slow you are probably using recursive 
variaidic templates.


Would it not be easier to have this feature as a command line 
argument that enables it in the compiler or include a compiler 
version that does this?


Not all everyone is good at building from sources...


Re: Can compiler profile itself?

2017-01-25 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 23:25:12 UTC, Profile Anaysis 
wrote:
I am trying to compile some code and it takes around 6 seconds. 
Even if I change one line in one module, it takes the same 
time. There are about 20 different d modules.


[...]


yes the compiler can be used to profile itself.
build it with make ENABLE_PROFILE=1

If your code is overly slow you are probably using recursive 
variaidic templates.


Can compiler profile itself?

2017-01-24 Thread Profile Anaysis via Digitalmars-d-learn
I am trying to compile some code and it takes around 6 seconds. 
Even if I change one line in one module, it takes the same time. 
There are about 20 different d modules.


I used to get around 1-2 second compile times several months ago 
on different projects.


I did upgrade a few things and it seems that something has made 
things slow.


Can we ask the compiler what seems to be taking the most time(a 
module, a template, etc...)?


If the compiler can profile itself then it would be very easy to 
figure out what is slowing things down in compilation.


I feel that I should be able to compile all the modules 
separately and only have to recompile the module that I 
changed... and that it should be quite fast(e.g., if the module 
contains nothing but the main and a write statement, regardless 
of all the other stuff in the project, I'd expect that to be 
fast).


For example, If I do the

import std.stdio;

int main(string[] argv)
{
writeln("Hello D-World!");
return 0;
}

it takes <1s.

Yet if I import a bunch of modules it takes 6+s and the time 
never reduces on subsequent builds.


I am using Visual D.

Visual D has a separate compile and link feature but when I try 
it for dmdx64 I get


Internal error: backend\mscoffobj.c 2016

It does work for x32 but the speed does not change.

I'm convinved that dmd is recompiling everything each time... and 
this doesn't seem very fast IMO when less than 0.1% of the 
project has changed.










Profile ldc2

2016-04-07 Thread jmh530 via Digitalmars-d-learn
I like how dmd has the -profile switch, but I'm not sure how to 
go about profiling ldc2. I don't see any compiler flags in the 
-help.


I'm also using Windows, if that matters, but if the best options 
are on Linux, I can dual-boot.


Re: Profile Ouput

2015-07-15 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote:



--
 4000   _Dmain
_D4main6selectFZk   40002736471
 4000   _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk
--




Got it now. The 2736 and 471 are the call tree time and function 
call time, respectively, in *ticks*. They are converted to 
seconds then displayed as milliseconds int the table at the 
bottom of the file.





Re: Profile Ouput

2015-07-15 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 15 July 2015 at 18:02:11 UTC, jmh530 wrote:


I've been confused by this too. The only thing I can find is 
this

http://www.digitalmars.com/ctg/trace.html

I think it would be cool to write something that takes the 
output and puts it in a prettier format.


Yeah, I eventually stumbled on to that, but it unfortunately 
tells me nothing I don't already know. I suppose I'll just email 
Walter and ask him.


Re: Profile Ouput

2015-07-15 Thread jmh530 via Digitalmars-d-learn

On Wednesday, 15 July 2015 at 11:47:53 UTC, Mike Parker wrote:

On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote:


--
 4000   _Dmain
_D4main6selectFZk   40002736471
	 
4000	_D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk

--



OK, I've finally realized that the top part of trace.log is an 
inverted (with main at the bottom) call tree. I've got 
everything now except that 2736 and 471 on the second line. 
Anyone?


I've been confused by this too. The only thing I can find is this
http://www.digitalmars.com/ctg/trace.html

I think it would be cool to write something that takes the output 
and puts it in a prettier format.


Re: Profile Ouput

2015-07-15 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 14 July 2015 at 13:35:40 UTC, Mike Parker wrote:


--
 4000   _Dmain
_D4main6selectFZk   40002736471
 4000   _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk
--



OK, I've finally realized that the top part of trace.log is an 
inverted (with main at the bottom) call tree. I've got everything 
now except that 2736 and 471 on the second line. Anyone?


Profile Ouput

2015-07-14 Thread Mike Parker via Digitalmars-d-learn
Perhaps my googlefu has failed me, but I can find anything 
describing the output of DMD's -profile switch. I get that 
trace.def is a list of all functions called and I understand the 
table at the bottom of trace.log. What I'm not sure about is 
everything above the table in trace.log, stuff like this:


--
 4000   _Dmain
_D4main6selectFZk   40002736471
 4000   _D3std6random27__T7uniformVAyaa2_5b29TkTkZ7uniformFNfkkZk
--

I get that it's telling me that the function main.select is 
called 4000 times and that it, in turn, calls std.random.uniform 
4000 times. What I not clear about is the 2736 and the 471. They 
match none of the times int the table below, where main.select 
has a Tree Time of 823 and a Func Time of 141. I also don't 
understand the 4000 next to _Dmain, as it's only called once. If 
anyone could clarify, or point me somewhere that explains it, I'd 
appreciate it.


Re: core.atomic and -profile switch

2014-04-02 Thread bearophile

Saurabh Das:


I see. I wasn't sure - hence I asked.


https://d.puremagic.com/issues/show_bug.cgi?id=11471



In general, how do I check if this is a known issue?


Search in Bugzilla and/or ask to people.

Bye,
bearophile


Re: core.atomic and -profile switch

2014-04-02 Thread Saurabh Das


I see. I wasn't sure - hence I asked.

In general, how do I check if this is a known issue?

Thanks,
Saurabh

On Wednesday, 2 April 2014 at 11:19:16 UTC, bearophile wrote:

Saurabh Das:


With error:
/usr/include/dmd/druntime/import/core/atomic.d(910): Error: 
asm statements are assumed to throw


Is there a workaround for this? I have a decent sized codebase 
which I wish to profile for hotspots - but it won't compile 
with '-profile'.


Isn't this a recent regression?

Bye,
bearophile




Re: core.atomic and -profile switch

2014-04-02 Thread bearophile

Saurabh Das:


With error:
/usr/include/dmd/druntime/import/core/atomic.d(910): Error: asm 
statements are assumed to throw


Is there a workaround for this? I have a decent sized codebase 
which I wish to profile for hotspots - but it won't compile 
with '-profile'.


Isn't this a recent regression?

Bye,
bearophile


core.atomic and -profile switch

2014-04-02 Thread Saurabh Das

Hello

For this test program ('test.d'):

import core.atomic;
int func1(shared int a)
{
return atomicLoad(a);
}

These invocations of dmd succeed:
1. dmd -main test.d
2. dmd -main -debug test.d
3. dmd -main -release test.d

But this one fails:
dmd -main -profile test.d

With error:
/usr/include/dmd/druntime/import/core/atomic.d(910): Error: asm 
statements are assumed to throw


Is there a workaround for this? I have a decent sized codebase 
which I wish to profile for hotspots - but it won't compile with 
'-profile'.


Warm Regards,
Saurabh



Re: Strange behaviour with -profile

2014-02-24 Thread Jesse Phillips

On Sunday, 23 February 2014 at 20:46:47 UTC, Jesse Phillips wrote:

On Sunday, 23 February 2014 at 08:32:50 UTC, Danny Arends wrote:
I have a medium sized project at: 
https://github.com/DannyArends/DaNode


it compiles fine with the normal build switches I used:

  $ rdmd --build-only -O -gc -release -w danode/server.d

if I compile with the -profile switch, I get a weird error:

  $ rdmd --build-only -O -gc -release -profile -w 
danode/server.d

  "Warning: statement is not reachable"


I thought DMD provided an error if you tried to optimize with 
debug symbols.


-O should not be used with -gc, -g, or -profile

Maybe that will address the problem.


While I think my advice is still correct, I can't seem to find 
the combination which caused a compiler message:


dmd -g -O -profile -release -debug -inline test.d

Also found that dub will do the same odd mix of switches:

["profile", "optimize", "inline", "debugInfo"]

Debug and optimize just don't make sense together, and profile 
needs debug symbols I thought.


Re: Strange behaviour with -profile

2014-02-23 Thread Jesse Phillips

On Sunday, 23 February 2014 at 08:32:50 UTC, Danny Arends wrote:
I have a medium sized project at: 
https://github.com/DannyArends/DaNode


it compiles fine with the normal build switches I used:

   $ rdmd --build-only -O -gc -release -w danode/server.d

if I compile with the -profile switch, I get a weird error:

   $ rdmd --build-only -O -gc -release -profile -w 
danode/server.d

   "Warning: statement is not reachable"


I thought DMD provided an error if you tried to optimize with 
debug symbols.


-O should not be used with -gc, -g, or -profile

Maybe that will address the problem.


Strange behaviour with -profile

2014-02-23 Thread Danny Arends
I have a medium sized project at: 
https://github.com/DannyArends/DaNode


it compiles fine with the normal build switches I used:

   $ rdmd --build-only -O -gc -release -w danode/server.d

if I compile with the -profile switch, I get a weird error:

   $ rdmd --build-only -O -gc -release -profile -w danode/server.d
   "Warning: statement is not reachable"

No line number or anything to point me to a solution

The weird thing is, I'm compiling using also with the -w switch, 
so in theory this should break compilation at the first warning, 
but the executable is created, and runs.


I am using DMD64 D Compiler v2.064, so it could be that the 
newest betas would fix this issue. But I haven gotten around to 
testing those, and this current build 2.064 works fine as a semi 
production build, so updating might also 'degrade' stability, and 
I have to find time to test it.


So I rather fix this, any suggestions ?

Danny Arends
http://www.dannyarends.nl


Re: Error when trying to compile with --profile.

2013-10-31 Thread Dmitry Olshansky

31-Oct-2013 13:28, bearophile пишет:

Wolftein:


Using --debug or --release works fine. But when i use --profile i get:

c:\Program Files
(x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2187):
 Error: balancedParens is not nothrow
c:\Program Files
(x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2188):
 Error: balancedParens is not nothrow
Error: this.__invariant is not nothrow
Error: this.__invariant is not nothrow


Is this bug in Bugzilla? DMD 2.064 should not come out with this
problem.



It would unless the above is a regression. The release can't be stalled 
forever.



Do you have a small test case?

Bye,
bearophile



--
Dmitry Olshansky


Re: Error when trying to compile with --profile.

2013-10-31 Thread bearophile

Wolftein:

Using --debug or --release works fine. But when i use --profile 
i get:


c:\Program Files 
(x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2187):

 Error: balancedParens is not nothrow
c:\Program Files 
(x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2188):

 Error: balancedParens is not nothrow
Error: this.__invariant is not nothrow
Error: this.__invariant is not nothrow


Is this bug in Bugzilla? DMD 2.064 should not come out with this
problem.

Do you have a small test case?

Bye,
bearophile


Error when trying to compile with --profile.

2013-10-30 Thread Wolftein
Using --debug or --release works fine. But when i use --profile i 
get:


c:\Program Files 
(x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2187):

 Error: balancedParens is not nothrow
c:\Program Files 
(x86)\DLang\dmd2\windows\bin\..\..\src\phobos\std\path.d(2188):

 Error: balancedParens is not nothrow
Error: this.__invariant is not nothrow
Error: this.__invariant is not nothrow


Re: -profile and nothrow

2013-10-29 Thread Paolo Invernizzi

On Monday, 28 October 2013 at 18:34:51 UTC, Dicebot wrote:
Any difference in semantics between -profile and normal flow is 
a

bug, so, yes, please report to bugzilla.


Done: http://d.puremagic.com/issues/show_bug.cgi?id=11375


Re: -profile and nothrow

2013-10-28 Thread Dicebot

Any difference in semantics between -profile and normal flow is a
bug, so, yes, please report to bugzilla.


Re: -profile and nothrow

2013-10-28 Thread Paolo Invernizzi

Reduced:

module b;
class B {
this() {}
}

module a;
import b;

class C : B {}
class D(X) : X {}
alias D!(C) HtmlPanel;

dmd -profile a.d
Error: 'a.C.this' is not no throw

Everything is ok without the profile... may I post a bug report 
for this?


/Paolo


On Monday, 28 October 2013 at 15:20:59 UTC, Paolo Invernizzi 
wrote:

Hi all,

Compiling my application with 2.064.beta.4 and 2.063.2 with the 
"-profile" switch, I have an error like:


  Error: 'foo.ui.Widgets.this' is not no throw

I've read something similar involving contracts, but this seems 
something different.
Of course everything compiles and run fine without the 
"-profile" switch.


Any clue, or may I try to reduce (it is a BIG codebase)?

Thanks,
Paolo


-profile and nothrow

2013-10-28 Thread Paolo Invernizzi

Hi all,

Compiling my application with 2.064.beta.4 and 2.063.2 with the 
"-profile" switch, I have an error like:


  Error: 'foo.ui.Widgets.this' is not no throw

I've read something similar involving contracts, but this seems 
something different.
Of course everything compiles and run fine without the "-profile" 
switch.


Any clue, or may I try to reduce (it is a BIG codebase)?

Thanks,
Paolo


Re: How do you profile your apps under windows?

2013-08-11 Thread Alexandr Druzhinin

10.08.2013 01:30, Gary Willoughby пишет:

On Friday, 9 August 2013 at 16:39:41 UTC, Alexandr Druzhinin wrote:

-profile switch doesn't work for me (nothing happens), so I'm curious
how to profile?


I had the same problem on Linux where -profile didn't seem to produce
anything. I had a program which ran an infinite loop running as a
daemon. When compiled and run using -profile i'd let it run for a bit
then kill it and nothing was produced. After much head scratching i
implemented a timer in the program that only ran in debug mode and after
the timer expired i raised an assert fail:

 assert(false);

This exited the program and produced the trace file which i could then
examine. I guess killing the process also killed the profiler and so
never gave me the report.
Tried this approach but the app hangs up somewhere in druntime code 
after my code execution finished.


Re: How do you profile your apps under windows?

2013-08-11 Thread Alexandr Druzhinin

10.08.2013 00:59, H. S. Teoh пишет:

On Fri, Aug 09, 2013 at 11:39:41PM +0700, Alexandr Druzhinin wrote:

-profile switch doesn't work for me (nothing happens), so I'm
curious how to profile?


You've to run your program first. It will create a bunch of extra files
in your current working directory that contains the profile results.


T

Of course I run the program first. When the program was simpler it 
worked fine. But at the some moment I tried to profile it again but 
there were no profile results generated. More over now my app just hangs 
up after finishing (my code) execution somewhere in druntime kingdom.
To try gprof I installed ubuntu 12.04 (newer versions didn't install 
from flushdisk) and also installed gdc-4.8 ("native" gdc-4.6 doesn't 
compile my code) from a package (compiling gdc from source fails, 
playing with configure options just wasted several hours of my spare 
time) and even build my app and became exciting that now I would get 
opportunity to profile using gprof but my app just crashed with dumping 
without any informative message. I tried to use gdb (I'm a noob with it) 
and found that it crashed somewhere about exit from static ctors - I'm 
not sure I interpreted gdb output correctly.
So now I have a choice - to wait when good and smart guys solve these 
problems either with dmd -profile or gdc code generating and try to work 
around myself - probably gdc codegen isn't the real reason. Here I'm 
sitting and making decision what to do further...
But nevertheless thanks to all who made the universe more beautiful and 
handy by means of D language and its infrastructure! Thank you guys!


Re: How do you profile your apps under windows?

2013-08-09 Thread Richard Webb
The Very Sleepy profiler works ok (if you run the apps through 
cv2pdb to get the debug symbols in the right format at least)


Re: How do you profile your apps under windows?

2013-08-09 Thread Gary Willoughby
On Friday, 9 August 2013 at 16:39:41 UTC, Alexandr Druzhinin 
wrote:
-profile switch doesn't work for me (nothing happens), so I'm 
curious how to profile?


I had the same problem on Linux where -profile didn't seem to 
produce anything. I had a program which ran an infinite loop 
running as a daemon. When compiled and run using -profile i'd let 
it run for a bit then kill it and nothing was produced. After 
much head scratching i implemented a timer in the program that 
only ran in debug mode and after the timer expired i raised an 
assert fail:


assert(false);

This exited the program and produced the trace file which i could 
then examine. I guess killing the process also killed the 
profiler and so never gave me the report.


Re: How do you profile your apps under windows?

2013-08-09 Thread Dmitry Olshansky

09-Aug-2013 20:39, Alexandr Druzhinin пишет:

-profile switch doesn't work for me (nothing happens), so I'm curious
how to profile?


My take is to compile with -g and use say AMD CodeAnalyst (or Intel's 
analog). Works quite well even though all symbols are mangled.


With -profile the app usually outputs trace.log somewhere in the folder 
launched.


--
Dmitry Olshansky


Re: How do you profile your apps under windows?

2013-08-09 Thread H. S. Teoh
On Fri, Aug 09, 2013 at 11:39:41PM +0700, Alexandr Druzhinin wrote:
> -profile switch doesn't work for me (nothing happens), so I'm
> curious how to profile?

You've to run your program first. It will create a bunch of extra files
in your current working directory that contains the profile results.


T

-- 
A bend in the road is not the end of the road unless you fail to make the turn. 
-- Brian White


How do you profile your apps under windows?

2013-08-09 Thread Alexandr Druzhinin
-profile switch doesn't work for me (nothing happens), so I'm curious 
how to profile?


how to profile compilation steps?

2013-07-11 Thread Timothee Cour
I'd like to at least get timestamps for the various steps appearing the the
dmd -v output.
Is there an easy way to modify dmd to output that?
That could be fed to a D function that parses it and generates a nice
profile report (ie the compiler would do not much more than just adding
timestamps, leaving most of the details to a D function)


Re: -profile

2013-06-07 Thread bearophile

Anthony Goins:


What is the error here :)
1. dmd profiletest.d
   should fail because balancedParens is not nothrow
   even though it is called from a contract.

2. dmd -profile profiletest.d
  should succeed because nothrow, @safe, pure don't apply to 
contracts


I think -profile and pre-conditions should not be correlated. 
That's why I have reported this bug as a dmd bug instead just of 
a Phobos bug.
I am not sure what's the right answer. I think the right answer 
is 1.


Bye,
bearophile


Re: -profile

2013-06-07 Thread bearophile

Anthony Goins:


Is this even worth a bug report?


http://d.puremagic.com/issues/show_bug.cgi?id=10295

Bye,
bearophile


Re: -profile

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 23:57:37 UTC, bearophile wrote:

Anthony Goins:


Is this even worth a bug report?


Yes, it's worth a bug report in Bugzilla, it's a (small) Phobos 
Bug. I confirmed its presence.


Bye,
bearophile


Thank you for all your help. Not just here but throughout the 
forums.

One more question though...

What is the error here :)
1. dmd profiletest.d
   should fail because balancedParens is not nothrow
   even though it is called from a contract.

2. dmd -profile profiletest.d
  should succeed because nothrow, @safe, pure don't apply to 
contracts


Re: -profile

2013-06-07 Thread bearophile

Anthony Goins:


Is this even worth a bug report?


Yes, it's worth a bug report in Bugzilla, it's a (small) Phobos 
Bug. I confirmed its presence.


Bye,
bearophile


Re: -profile

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 23:42:58 UTC, Anthony Goins wrote:

On Friday, 7 June 2013 at 21:39:26 UTC, bearophile wrote:

Anthony Goins:


Simple question is why?


I am compiling this code with -profile, and I don't see errors:


import std.string: balancedParens;
void main() {
   assert(balancedParens("[[]]", '[', ']'));
}


Bye,
bearophile


okay found it

module profiletest;
import std.path;

void main()
{
assert(globMatch("foo.bar", "*"));
}

dmd -profile profiletest.d
/usr/include/dmd/phobos/std/path.d(2187): Error: balancedParens 
is not nothrow
/usr/include/dmd/phobos/std/path.d(2188): Error: balancedParens 
is not nothrow



globMatch is @safe pure nothrow
balancedParens is not nothrow
-release ignores contracts, right?

 oops forgot to say
balancedParens is called from the 'in' contract of globMatch.
Is this even worth a bug report?


Re: -profile

2013-06-07 Thread Anthony Goins

On Friday, 7 June 2013 at 21:39:26 UTC, bearophile wrote:

Anthony Goins:


Simple question is why?


I am compiling this code with -profile, and I don't see errors:


import std.string: balancedParens;
void main() {
assert(balancedParens("[[]]", '[', ']'));
}


Bye,
bearophile


okay found it

module profiletest;
import std.path;

void main()
{
assert(globMatch("foo.bar", "*"));
}

dmd -profile profiletest.d
/usr/include/dmd/phobos/std/path.d(2187): Error: balancedParens 
is not nothrow
/usr/include/dmd/phobos/std/path.d(2188): Error: balancedParens 
is not nothrow



globMatch is @safe pure nothrow
balancedParens is not nothrow
-release ignores contracts, right?



Re: -profile

2013-06-07 Thread bearophile

Anthony Goins:


Simple question is why?


I am compiling this code with -profile, and I don't see errors:


import std.string: balancedParens;
void main() {
assert(balancedParens("[[]]", '[', ']'));
}


Bye,
bearophile


Re: -profile

2013-06-07 Thread bearophile

Anthony Goins:


Simple question is why?


Looks like a little compiler bug. Please create a minimal example 
that shows the problem. If it's a real problem then it's for 
Bugzilla.


Bye,
bearophile


-profile

2013-06-07 Thread Anthony Goins

Compiling with -profile and without -release
Gives the following error (not exactly but the best I can recall)
balancedParens is not nothrow  safe pure

With -release and -profile all is fine.
Builds fine without -profile.

Simple question is why?


Reading results from dmd -profile

2012-10-28 Thread cal
I am trying to read the text file (trace.log) created by running 
the dmd profiler on some code, so that I can use demangle to make 
the output a bit more readable. I can read it in as a char[], but 
the whenever I try any string ops I get an exception because 
there are invalid UTF-8 sequences in the text.


So two questions: why does the output contain invalid UTF-8 
sequences, and what would be a good way to handle the invalid 
sequences, since I guess I need them for proper demangling?


Cheers


profiling with -profile

2012-07-26 Thread Minas Mina

I have this code:

import std.stdio;

void main()
{
f();
g();
}

void f()
{
writeln("f()");
}

void g()
{
writeln("g()");
}

I compile with the command:

dmd test.d -profile

Then I execute it. It prints:
f()
g()

as expected. Shouldn't it print profiling information as well?


Re: profiling with -profile

2012-07-26 Thread Minas Mina

Sorry, I just saw the generated file...

:p


Re: GUI or more human readable -profile data?

2012-02-29 Thread Jonathan M Davis
On Thursday, March 01, 2012 00:17:55 Robert Clipsham wrote:
> Just as a side note, -profile doesn't work with multi-threaded
> applications, so using some other profiler would probably be a better
> bet anyway.

It doesn't work with 64-bit programs either.

- Jonathan M Davis


Re: GUI or more human readable -profile data?

2012-02-29 Thread Robert Clipsham

On 29/02/2012 21:30, simendsjo wrote:

On Wed, 29 Feb 2012 22:28:29 +0100, Robert Clipsham
 wrote:


On 29/02/2012 19:41, simendsjo wrote:

http://www.digitalmars.com/ctg/trace.html

Has someone made some GUI/pretty printing/dump to database or other
tools to make the profile data a bit simpler to digest?


If you're on Windows you could try:

http://h3.gd/code/xfProf/

Although I don't believe it uses the data from -profile. On linux/OS X
you can use valgrind/kcachegrind, though it doesn't have demangling
for D symbols (at least, last time I checked).



Nope, linux. But I bet the feature is used, so somewhere out there,
there's some tools for making it simpler to make sense of :)


Just as a side note, -profile doesn't work with multi-threaded 
applications, so using some other profiler would probably be a better 
bet anyway.


--
Robert
http://octarineparrot.com/


Re: GUI or more human readable -profile data?

2012-02-29 Thread Andrej Mitrovic
Boom: https://bitbucket.org/stqn/profiled

I've never used it though.


Re: GUI or more human readable -profile data?

2012-02-29 Thread simendsjo
On Wed, 29 Feb 2012 22:28:29 +0100, Robert Clipsham  
 wrote:



On 29/02/2012 19:41, simendsjo wrote:

http://www.digitalmars.com/ctg/trace.html

Has someone made some GUI/pretty printing/dump to database or other
tools to make the profile data a bit simpler to digest?


If you're on Windows you could try:

http://h3.gd/code/xfProf/

Although I don't believe it uses the data from -profile. On linux/OS X  
you can use valgrind/kcachegrind, though it doesn't have demangling for  
D symbols (at least, last time I checked).




Nope, linux. But I bet the feature is used, so somewhere out there,  
there's some tools for making it simpler to make sense of :)


Re: GUI or more human readable -profile data?

2012-02-29 Thread Robert Clipsham

On 29/02/2012 19:41, simendsjo wrote:

http://www.digitalmars.com/ctg/trace.html

Has someone made some GUI/pretty printing/dump to database or other
tools to make the profile data a bit simpler to digest?


If you're on Windows you could try:

http://h3.gd/code/xfProf/

Although I don't believe it uses the data from -profile. On linux/OS X 
you can use valgrind/kcachegrind, though it doesn't have demangling for 
D symbols (at least, last time I checked).


--
Robert
http://octarineparrot.com/


GUI or more human readable -profile data?

2012-02-29 Thread simendsjo

http://www.digitalmars.com/ctg/trace.html

Has someone made some GUI/pretty printing/dump to database or other tools  
to make the profile data a bit simpler to digest?


Re: Profile DMD

2011-12-01 Thread Nick Sabalausky
"Timon Gehr"  wrote in message 
news:jb8iak$2ucr$1...@digitalmars.com...
> On 12/01/2011 07:42 PM, Nick Sabalausky wrote:
>> Is there an easy way to profile DMD similar to how DMD itself has
>> the -profile switch?
>>
>>
>
> Use DMC, I guess. http://www.digitalmars.com/ctg/trace.html

Ah, ok, and it looks like DMD's makefile (at least on windows) has a target 
"trace"  that includes the appropriate switches. So...

make -f win32.mak trace

...seems to do the trick.




Re: Profile DMD

2011-12-01 Thread Timon Gehr

On 12/01/2011 07:42 PM, Nick Sabalausky wrote:

Is there an easy way to profile DMD similar to how DMD itself has
the -profile switch?




Use DMC, I guess. http://www.digitalmars.com/ctg/trace.html


Profile DMD

2011-12-01 Thread Nick Sabalausky
Is there an easy way to profile DMD similar to how DMD itself has 
the -profile switch?




Benchmarking with -profile

2011-03-06 Thread Peter Lundgren
How do you guys benchmark your D code? I tried using the -profile option, but
was surprised to see wildly varying results (greater than an order of
magnitude difference in Func Time) from one run to the next.


Re: -profile and threaded code

2009-03-29 Thread David Ferenczi
BCS wrote:

> Hello BCS,
> 
>> I have a program that runs an "easily" parallelizable loop. When I run
>> it as a single thread it only takes about 10% longer than 2 threads
>> (on a dual-core). I'm trying to track down the lossed time and am
>> wondering if turning on -profile is even worth looking at. The concern
>> is that it might not be thread safe or might just skew the result so
>> much as to be useless.
>> 
> 
> Well it seems that runing threded code with -profile gives a seg-v. So I
> guess that answers that.

See last comment of Walter:
http://d.puremagic.com/issues/show_bug.cgi?id=971



Re: -profile and threaded code

2009-03-28 Thread downs
BCS wrote:
> Hello BCS,
> 
>> I have a program that runs an "easily" parallelizable loop. When I run
>> it as a single thread it only takes about 10% longer than 2 threads
>> (on a dual-core). I'm trying to track down the lossed time and am
>> wondering if turning on -profile is even worth looking at. The concern
>> is that it might not be thread safe or might just skew the result so
>> much as to be useless.
>>
> 
> Well it seems that runing threded code with -profile gives a seg-v. So I
> guess that answers that.
> 
> 

Try GDC. :)


Re: -profile and threaded code

2009-03-28 Thread BCS

Hello BCS,


I have a program that runs an "easily" parallelizable loop. When I run
it as a single thread it only takes about 10% longer than 2 threads
(on a dual-core). I'm trying to track down the lossed time and am
wondering if turning on -profile is even worth looking at. The concern
is that it might not be thread safe or might just skew the result so
much as to be useless.



Well it seems that runing threded code with -profile gives a seg-v. So I 
guess that answers that.





-profile and threaded code

2009-03-28 Thread BCS
I have a program that runs an "easily" parallelizable loop. When I run it 
as a single thread it only takes about 10% longer than 2 threads (on a dual-core). 
I'm trying to track down the lossed time and am wondering if turning on -profile 
is even worth looking at. The concern is that it might not be thread safe 
or might just skew the result so much as to be useless.