July 13

On Saturday, 13 July 2024 at 01:55:16 UTC, Steven Schveighoffer wrote:

>

The -release flag is equivalent to -O -boundscheck=safeonly -inline.

What? No it's not.

It's equivalent to -check=invariant=off -check=in=off -check=out=off -check=bounds=safeonly -check=assert=off -check=switch=off (and what Nicholas pointed out).

-O and -inline are orthogonal to -release (and to each other).

(But the rest of your post makes sense with that in mind so I think that may have been what you meant?)

July 13
On 7/12/2024 10:55 PM, Steven Schveighoffer wrote:
> I think it's fair to say no "journalists" are reviewing D in print. For sure, 

In print, no, online certainly, and when they're evaluating whether to use D or not, absolutely.


> people who try to run benchmarks will at least look for the proper optimization flags, and I bet nobody is looking to remove bounds checks.

What they'll do is compare it to C and C++, neither of which does bounds checks, and on the same code C and C++ will be faster, and D will be slow, and that will be the result of the benchmark. They will not look deeper.

First impressions are very very hard to dislodge. I have a lot of experience with this.


> Let's just remove it. What it does now is fool people into thinking this is for when you want to release your library/application. If nothing else, it should be renamed to -removesafetychecks or something.

It's simply not apparent from the documentation the path to the fastest code. Nobody doing a quick benchmark is going to try -removesafetychecks.


> Note, I was wrong about the -O and -inline being implied -- you still have to put those in. -release just gets rid of all the safety checks.

Are you sure? It says in the documentation they are.

July 14
On 14/07/2024 4:44 AM, Walter Bright wrote:
>> Note, I was wrong about the -O and -inline being implied -- you still have to put those in. -release just gets rid of all the safety checks.
> 
> Are you sure? It says in the documentation they are.

Nothing is screaming that it does turn on optimizations.

https://github.com/search?q=repo%3Adlang%2Fdmd%20params.release&type=code

https://github.com/dlang/dmd/blob/9a5ce0e1efe4d395a436e2c6c1cdf7039320e0e0/compiler/src/dmd/main.d#L995
July 13
On 7/13/2024 8:28 AM, Vladimir Panteleev wrote:
> It's equivalent to `-check=invariant=off -check=in=off -check=out=off -check=bounds=safeonly -check=assert=off -check=switch=off` (and what Nicholas pointed out).
> 
> `-O` and `-inline` are orthogonal to `-release` (and to each other).


Hmm, checking the actual implementation, you're right. Someone must have changed it at some point. -release is supposed to be "fastest code". Need to fix that!
July 13

On Saturday, 13 July 2024 at 01:55:16 UTC, Steven Schveighoffer wrote:

>

The -release flag is equivalent to -O -boundscheck=safeonly -inline.

I think we should remove it. If you want no bounds checks, you should have to really want it enough to type that whole monstrosity in. It's trivial to avoid bounds checks by using .ptr[index] in @system code. In my dub projects, I rewrite the release mode to keep bounds checks for all code, it's that important.

What do you think? Deprecate for 3 versions, then remove.

-Steve

I don't really care about this, but some projects might depend on it for some reason.
Is it a problem if it just exists? Looks like a simple thing to maintain.

July 13
See my reply to Vladimir.
July 13
On 7/13/24 19:12, Kapendev wrote:
> On Saturday, 13 July 2024 at 01:55:16 UTC, Steven Schveighoffer wrote:
>> The `-release` flag is equivalent to `-O -boundscheck=safeonly -inline`.
>>
>> I think we should remove it. If you want no bounds checks, you should have to really want it enough to type that whole monstrosity in. It's trivial to avoid bounds checks by using `.ptr[index]` in `@system` code. In my dub projects, I rewrite the release mode to keep bounds checks for all code, it's that important.
>>
>> What do you think? Deprecate for 3 versions, then remove.
>>
>> -Steve
> 
> I don't really care about this, but some projects might depend on it for some reason.
> Is it a problem if it just exists? Looks like a simple thing to maintain.

It's misleading. It should not be used for creating binary releases. It also undercuts D's memory safety aspirations.
July 14
On Saturday, 13 July 2024 at 21:13:02 UTC, Timon Gehr wrote:
> On 7/13/24 19:12, Kapendev wrote:
>> On Saturday, 13 July 2024 at 01:55:16 UTC, Steven Schveighoffer wrote:
>>> The `-release` flag is equivalent to `-O -boundscheck=safeonly -inline`.
>>>
>>> I think we should remove it. If you want no bounds checks, you should have to really want it enough to type that whole monstrosity in. It's trivial to avoid bounds checks by using `.ptr[index]` in `@system` code. In my dub projects, I rewrite the release mode to keep bounds checks for all code, it's that important.
>>>
>>> What do you think? Deprecate for 3 versions, then remove.
>>>
>>> -Steve
If it's needed for benchmarks but not desired for release code, change it to -fast or something. I would hope that someone running benchmarks would at least look at the options and see that.
July 14
On Saturday, 13 July 2024 at 16:48:29 UTC, Walter Bright wrote:
> On 7/13/2024 8:28 AM, Vladimir Panteleev wrote:
>> It's equivalent to `-check=invariant=off -check=in=off -check=out=off -check=bounds=safeonly -check=assert=off -check=switch=off` (and what Nicholas pointed out).
>> 
>> `-O` and `-inline` are orthogonal to `-release` (and to each other).
>
>
> Hmm, checking the actual implementation, you're right. Someone must have changed it at some point. -release is supposed to be "fastest code". Need to fix that!

then rename it to -benchmark.
July 14
On Sun, Jul 14, 2024 at 12:52:36PM +0000, Zoadian via Digitalmars-d wrote:
> On Saturday, 13 July 2024 at 16:48:29 UTC, Walter Bright wrote:
> > On 7/13/2024 8:28 AM, Vladimir Panteleev wrote:
> > > It's equivalent to `-check=invariant=off -check=in=off -check=out=off -check=bounds=safeonly -check=assert=off -check=switch=off` (and what Nicholas pointed out).
> > > 
> > > `-O` and `-inline` are orthogonal to `-release` (and to each
> > > other).
> > 
> > 
> > Hmm, checking the actual implementation, you're right. Someone must have changed it at some point. -release is supposed to be "fastest code".  Need to fix that!
> 
> then rename it to -benchmark.

+1.  Calling it -release is misleading and breaks safety guarantees. That's very bad.

Alternatively, just redirect -release to running ldc2 instead. In almost every D program I've written, ldc2 produces an executable that runs 30-40% faster than the same program compiled by dmd (sometimes even 50%).  No amount of suppressing bounds checks is going to give you that kind of performance boost, so why break safety over marginal gains that isn't winning you any benchmarks anyway?  Just admit it and have -release run ldc2. Even with bounds checks still enabled, you get an instant 30% performance boost.  *That's* what's gonna catch attention, not some half-baked safety-breaking switch in a suboptimal optimizer that's going to lose out to C benchmarks anyway.


T

-- 
"Holy war is an oxymoron." -- Lazarus Long