[Issue 17577] 20%+ Performance degradation in std.conv.to due to 'import std.getopt'

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17577

Jon Degenhardt  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from Jon Degenhardt  ---
Likely an LDC issue, so closing in favor of the LDC issue:
https://github.com/ldc-developers/ldc/issues/2168. Can be re-opened if this
turns out to be incorrect.

--


[Issue 17577] 20%+ Performance degradation in std.conv.to due to 'import std.getopt'

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17577

--- Comment #3 from Jon Degenhardt  ---
Properly adding -inline to the DMD compiler line eliminates the degradation in
the DMD builds, at least in 2.075.0-b1. (I deleted 2.074 when updating to
beta-1.)

The updated table:

|| Without   | With  |
| Compiler   | getopt import | getopt import |
|+---+---|
| DMD 2.075.0-b1 |  5.00 |  4.98 |
| LDC 1.2|  4.27 |  6.06 |
| LDC 1.3|  3.61 |  4.63 |

--


[Issue 17577] 20%+ Performance degradation in std.conv.to due to 'import std.getopt'

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17577

--- Comment #2 from Jon Degenhardt  ---
(In reply to Vladimir Panteleev from comment #1)
> Reproducible on Linux x86_64 (11.6 / 10.6 seconds with dmd)
> 
> (In reply to Jon Degenhardt from comment #0)
> > Implication so far is that
> > something is interfering with proper inlining.
> > [...]
> >   $ ldc2 -release -O3 -boundscheck=off -singleobj use_conv_to.d
> >   $ dmd -release -O -boundscheck=off use_conv_to.d
> 
> This command line does not include -inline.

Nice catch. I'll add -inline to the DMD command lines and retry. (It doesn't
apply to the LDC command line.) Thanks!

--


[Issue 17577] 20%+ Performance degradation in std.conv.to due to 'import std.getopt'

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17577

Vladimir Panteleev  changed:

   What|Removed |Added

 CC||dlang-bugzilla@thecybershad
   ||ow.net

--- Comment #1 from Vladimir Panteleev  ---
Reproducible on Linux x86_64 (11.6 / 10.6 seconds with dmd)

(In reply to Jon Degenhardt from comment #0)
> Implication so far is that
> something is interfering with proper inlining.
> [...]
>   $ ldc2 -release -O3 -boundscheck=off -singleobj use_conv_to.d
>   $ dmd -release -O -boundscheck=off use_conv_to.d

This command line does not include -inline.

--


[Issue 17577] New: 20%+ Performance degradation in std.conv.to due to 'import std.getopt'

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17577

  Issue ID: 17577
   Summary: 20%+ Performance degradation in std.conv.to due to
'import std.getopt'
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: jrdemail2000-dl...@yahoo.com

Importing std.getopt causes a performance degradation in calls to std.conv.to.
This degradation occurs when simply importing std.getopt, it is not necessary
to use features from std.getopt. This has been observed DMD 2.074.0, DMD
2.075.0-beta1, LDC 1.2, and LDC 1.3-beta 1 and 2.

This was first encountered as a performance regression from LDC 1.2 to LDC 1.3
in several benchmarks used by the TSV Utilities library. The degradation in
these benchmarks is from 20-30%.

Narrowing down the case identified a much smaller example exhibiting the
problem. Simply importing std.getopt causes a performance degradation
converting char[] to double via std.conv.to. Implication so far is that
something is interfering with proper inlining.

An important behavior change for the smaller sample is that it affects LDC 1.2,
LDC 1.3, and DMD. In the TSV Utilities test, the degradation was seen in LDC
1.3, but not LDC 1.2. This could be due the larger size of the programs.

The LDC issue:  https://github.com/ldc-developers/ldc/issues/2168

A sample program illustrating the issue:

= use_conv_to.d ==
import std.conv : to;
import std.stdio;
import std.getopt;

void main()
{
string num = "0.108236736784";
size_t end = num.length;
double sum = 0.0;
foreach (i; 0 .. 100_000_000)
{
sum += num[0 .. end].to!double;
end = (end == num.length) ? 1 : end + 1;
}
writeln("sum: ", sum);
}
===

Here are timing differences with and without the 'import std.getopt;' line.
Times were on OS X (xcode 8.3.3), and are in seconds:

| Compiler   | Without getopt import | With getopt import |
|+---+|
| DMD 2.074.0| 12.30 |  13.02 |
| DMD 2.075.0-b1 | 12.72 |  13.19 |
| LDC 1.2|  4.27 |   6.06 |
| LDC 1.3|  3.61 |   4.63 |

Compilation lines:
  $ ldc2 -release -O3 -boundscheck=off -singleobj use_conv_to.d
  $ dmd -release -O -boundscheck=off use_conv_to.d

LDC 1.3 was based on commit 6c97a02, so it includes the fix for boundscheck=off
(https://github.com/ldc-developers/ldc/issues/2161)

It is not known if other facilities are affected, though if inlining is being
affected this seems likely.

I tried adding std.getopt to the compiler line as an additional file, but not
importing it. This did not produce the degradation, so it appears related to
import.

I tried importing a version of std.getopt with all the unit test blocks
removed. This still produced the degradation. Hypothesis was repeated parsing
of templates in the unittest blocks might causing an issue, but this does not
appear to be the case.

I tried importing a small file which did little besides import std.conv.to,
which std.getopt does. This did not produce the degradation.

--


[Issue 17576] mixin template cannot define alias

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17576

Bolpat  changed:

   What|Removed |Added

   Keywords||rejects-valid

--


[Issue 17576] New: mixin template cannot define alias

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17576

  Issue ID: 17576
   Summary: mixin template cannot define alias
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: qs.il.paperi...@gmail.com

mixin template Test(alias f)
{
import std.traits : ReturnType;
alias R = ReturnType!f;

R foo() { }
}

struct S
{
void foo(int) { }

mixin Test!foo T;
alias foo = T.foo;
}

gives me the error message "template instance std.traits.ReturnType!(foo) is
used as a type"

However, when R foo() { } is replaced with ReturnType!f foo() { } the error
message is "isCallable!(foo) is not an expression", and if one deletes the
alias for R, the error disappears.

Instead, if I precede the mixin template with "import std.traits : isCallable;"
and constrain it with "if (isCallable!f)", the error is "no property 'foo' for
type 'void'" essentially because it cannot instance isCallable!f for whatever
reason.

I suspect it is a bug in DMD. It could be in Phobos's ReturnType or isCallable.

--


[Issue 17574] Range violation in std.getopt:getopt AA parsing

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17574

hst...@quickfur.ath.cx changed:

   What|Removed |Added

 CC||hst...@quickfur.ath.cx

--


[Issue 17575] New: named mixin template error message

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17575

  Issue ID: 17575
   Summary: named mixin template error message
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: qs.il.paperi...@gmail.com

Consider

mixin template Foo() { }

void main()
{
mixin Foo F;
F.x;
}

It gives: Error: no property 'x' for type 'void'

The error message should be like: 'x' is not a member of template 'Foo!()'

--


[Issue 17574] New: Range violation in std.getopt:getopt AA parsing

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17574

  Issue ID: 17574
   Summary: Range violation in std.getopt:getopt AA parsing
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: briancsch...@gmail.com

I discovered this while trying to figure out how to include commas in argument
values:

```
import std.getopt;
import std.stdio;

void main()
{
string[string] mapping;
arraySep = ",";
string[] args = [
"testProgram",
"-m",
"a=b,c=\"d,e,f\""
];
args.getopt("m", );
writeln(mapping);
}

```

--


[Issue 17572] unrestricted union erroneously invokes postblit

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17572

--- Comment #1 from ki...@gmx.net ---
Not a bug, as the copy and postblit happens correctly when constructing the
`cast(POD!Node)val` rvalue, see
https://github.com/ldc-developers/ldc/issues/2185.

--


[Issue 17573] New: Make opCmp more flexible

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17573

  Issue ID: 17573
   Summary: Make opCmp more flexible
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: hala...@gmail.com

The way custom comparisons are currently implemented force you to always return
an integer and doesn't tell you what operation you are doing.

An example of how it can bite is that mir can't do elementwise comparisons
similar to how it does addition or multiplication since it has to return an int
for comparisons.
So a + a == [2, 2, 2] and a * a == [1, 1, 1] but you can't express a < a ==
[false, false, false].


I get the logic of only making the user create a single comparison function but
maybe a possible fix would be to check if there is an opBinary for the relevant
comparison operator before doing the usual opCmp logic.

--


[Issue 17571] Cannot create alias of __traits(getMember, ...)

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17571

Vladimir Panteleev  changed:

   What|Removed |Added

 CC||dlang-bugzilla@thecybershad
   ||ow.net

--- Comment #3 from Vladimir Panteleev  ---
It is a limitation of the current grammar. It's probably fixable by changing
the grammar, which I think would make sense.

--


[Issue 17564] std.experimental.allocator.theAllocator is null within shared static this

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17564

--- Comment #1 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/4a5d2b3b189f072e9bd0b1779a7d585e3945921b
Fix issue 17564: Eliminate "static this" for theAllocator

This switches to lazy initialization of theAllocator, so that accessing it form
within `shared static this` works as expected.

https://github.com/dlang/phobos/commit/2e0a49cd397ea1bdb993e3a9271193cf6051b8ce
Merge pull request #5519 from s-ludwig/lazy_the_allocator

Issue 17564: Eliminate "static this" for theAllocator
merged-on-behalf-of: Martin Nowak 

--


[Issue 17571] Cannot create alias of __traits(getMember, ...)

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17571

--- Comment #2 from Shachar Shemesh  ---
(In reply to Vladimir Panteleev from comment #1)
> It is a syntax issue. See:
> https://blog.thecybershadow.net/2015/04/28/the-amazing-template-that-does-
> nothing/

I'm sorry, I don't understand. Are you saying that because it is a syntax issue
it is not a bug?

Shachar

--


[Issue 17572] New: unrestricted union erroneously invokes postblit

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17572

  Issue ID: 17572
   Summary: unrestricted union erroneously invokes postblit
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: critical
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: wyr...@gmx.net

Expected Behavior:
prints 0
Observed Behavior:
prints 1

import std.stdio;

long post = 0;

struct Node
{
  uint val;

  this(this) { ++post; }
}

union POD(T)
{
  T val;
}

POD!Node g;

void Put(ref Node val)
{
  g = cast(POD!Node)val;
}

void main()
{
  auto x = Node(5);
  x.Put();
  post.writeln;
}

--


[Issue 17571] Cannot create alias of __traits(getMember, ...)

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17571

Vladimir Panteleev  changed:

   What|Removed |Added

   Hardware|x86_64  |All
Summary|Cannot create alias of  |Cannot create alias of
   |__traits(getMember  |__traits(getMember, ...)
 OS|Linux   |All

--- Comment #1 from Vladimir Panteleev  ---
It is a syntax issue. See:
https://blog.thecybershadow.net/2015/04/28/the-amazing-template-that-does-nothing/

--


[Issue 17570] Misleading error message illegal conditional function definition

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17570

Vladimir Panteleev  changed:

   What|Removed |Added

   Keywords||diagnostic
   Priority|P1  |P3
 CC||dlang-bugzilla@thecybershad
   ||ow.net
   Hardware|x86_64  |All
 OS|Linux   |All

--


[Issue 17545] [REG2.072] __traits(getAttributes, name) evaluates name to value prematurely

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17545

--- Comment #5 from Walter Bright  ---
https://github.com/dlang/dmd/pull/6949

--


[Issue 17545] [REG2.072] __traits(getAttributes, name) evaluates name to value prematurely

2017-06-29 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17545

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #4 from Walter Bright  ---
(In reply to Vladimir Panteleev from comment #3)
> Introduced in https://github.com/dlang/dmd/pull/5588

Timon Gehr notes that it was this diff that caused the issue:

https://github.com/dlang/dmd/compare/master...tgehr:fix17545

--