May 25, 2022
On Wednesday, 25 May 2022 at 18:56:03 UTC, Walter Bright wrote:
> Back in the olden daze, I've seen magazine compiler benchmark articles trash various compilers for poor runtime performance.

I read a Raymond Chen thing not too long ago saying the reason they didn't do seconds on the Windows 95 clock is that swapping in a couple more pages each second hurt their benchmark performance. And since it wasn't that important to users, it got axed.

> So I'm leery of not being able to turn off the runtime checks to get max performance.

I'm not against being able to do it - you have -boundscheck, and -check, and similar on the compiler switch, and you have .ptr in the language itself - my problem is putting it in the routine-sounding -release switch that people aren't fully educated on.

If you know exactly what is happening and understand why it is happening, do it.

But if you're just copying -release because "I want a release build" or because someone told you "you can win the benchmark if you use this" without realizing that it opens you back up to potentially serious problems, that's no good.

> Besides, it provides a way of accurately measuring how much the runtime checks are costing.

Sure, use -boundscheck=off for that.
May 25, 2022
On Wednesday, 25 May 2022 at 16:17:06 UTC, Siarhei Siamashka wrote:
> I think that a much better idea is to migrate more code

You're right, we're not on the same page.

I am talking about the D language we have today, with code we have today, making decisions in the here-and-now.

You're talking about a fantasy.

> Regarding the name of this topic. If the '-release' switch removal idea gains traction, it will be a strong reason for me to quit.

lol you can still use -boundscheck=safeonly -check=none to get the same result. -release is just a shorthand for those.

(of course, if you want maximum performance, you want to use gdc -O instead of any of this other stuff)
May 25, 2022

On Wednesday, 25 May 2022 at 18:56:03 UTC, Walter Bright wrote:

>

On 5/24/2022 4:26 AM, Adam D Ruppe wrote:

>

It is a terrible switch that does random bad things.

Back in the olden daze, I've seen magazine compiler benchmark articles trash various compilers for poor runtime performance. It nearly always boiled down to the journalist not using the right switches for release builds.

At present this concern is not addressable by a single switch. Imagine the confusion if a performance reviewer did not choose ldc/gdc, did not avail his/herself of -Ox options, did not employ LTO, did not enable target arch specific optimization, ...

>

So I'm leery of not being able to turn off the runtime checks to get max performance.

Besides, it provides a way of accurately measuring how much the runtime checks are costing.

Yes, it enables that measurement but, as others have noted, it would be strange (if not outright foolish) to actually release code compiled with "-release".

I think there would be little concern if "-release" had been named "-removeAllSafetyChecks".

May 25, 2022
On Wed, May 25, 2022 at 07:25:43PM +0000, Adam D Ruppe via Digitalmars-d wrote:
> On Wednesday, 25 May 2022 at 16:17:06 UTC, Siarhei Siamashka wrote:
[...]
> > Regarding the name of this topic. If the '-release' switch removal idea gains traction, it will be a strong reason for me to quit.
> 
> lol you can still use -boundscheck=safeonly -check=none to get the same result. -release is just a shorthand for those.
> 
> (of course, if you want maximum performance, you want to use gdc -O instead of any of this other stuff)

FWIW, after the first year or so of using D, I stopped using -release. These days, I just use `ldc2 -O2` which gives me better performance than any silly bounds-check-removing nonsense like -release.  We're not living in the 70's anymore; the few nanoseconds you save by skipping a lousy bounds check is just not worth the nightmare of a buffer overflow exploit on a customer production environment.


T

-- 
Be in denial for long enough, and one day you'll deny yourself of things you wish you hadn't.
May 25, 2022
On Wednesday, 25 May 2022 at 19:37:19 UTC, H. S. Teoh wrote:
> On Wed, May 25, 2022 at 07:25:43PM +0000, Adam D Ruppe via Digitalmars-d wrote:
>> On Wednesday, 25 May 2022 at 16:17:06 UTC, Siarhei Siamashka wrote:
> [...]
>
> FWIW, after the first year or so of using D, I stopped using -release. These days, I just use `ldc2 -O2` which gives me better performance than any silly bounds-check-removing nonsense like -release.  We're not living in the 70's anymore; the few nanoseconds you save by skipping a lousy bounds check is just not worth the nightmare of a buffer overflow exploit on a customer production environment.
>
>
> T

Even in the 60's leaving out bounds checking was considered a dumb idea, naturally the C school of thought took another path.


> Many years later we asked our customers whether they wished us to provide an option to switch off these checks in the interests of efficiency on production runs. Unanimously, they urged us not to--they already knew how frequently subscript errors occur on production runs where failure to detect them could be disastrous. I note with fear and horror that even in 1980, language designers and users have not learned this lesson. In any respectable branch of engineering, failure to observe such elementary precautions would have long been against the law.

C.A.R Hoare on his 1980 Turing award speech.
May 25, 2022
On 5/25/2022 12:19 PM, H. S. Teoh wrote:
> I wouldn't be against an explicit switch to disable bounds checks for
> when you want to measure this.  But it should not be the default
> behaviour of -release.

It isn't. To turn off bounds check, you'll need -noboundscheck

-release just turns off asserts.
May 25, 2022
On Wednesday, 25 May 2022 at 21:47:38 UTC, Walter Bright wrote:
> On 5/25/2022 12:19 PM, H. S. Teoh wrote:
>> I wouldn't be against an explicit switch to disable bounds checks for
>> when you want to measure this.  But it should not be the default
>> behaviour of -release.
>
> It isn't. To turn off bounds check, you'll need -noboundscheck
>
> -release just turns off asserts.

Exactly what competitive programmers do for better performance.
Flags for Codeforces for example:

dmd -L/STACK:268435456 -version=ONLINE_JUDGE -O -release -inline -noboundscheck {file}
May 25, 2022
On Wednesday, 25 May 2022 at 21:47:38 UTC, Walter Bright wrote:
> On 5/25/2022 12:19 PM, H. S. Teoh wrote:
>> I wouldn't be against an explicit switch to disable bounds checks for
>> when you want to measure this.  But it should not be the default
>> behaviour of -release.
>
> It isn't. To turn off bounds check, you'll need -noboundscheck
>
> -release just turns off asserts.

Hhh? You mean that's all -release does? Just turn off asserts? Nothing else (whatsoever)?
May 25, 2022
On Wednesday, 25 May 2022 at 23:16:35 UTC, forkit wrote:
> On Wednesday, 25 May 2022 at 21:47:38 UTC, Walter Bright wrote:
>> On 5/25/2022 12:19 PM, H. S. Teoh wrote:
>>> I wouldn't be against an explicit switch to disable bounds checks for
>>> when you want to measure this.  But it should not be the default
>>> behaviour of -release.
>>
>> It isn't. To turn off bounds check, you'll need -noboundscheck
>>
>> -release just turns off asserts.
>
> Hhh? You mean that's all -release does? Just turn off asserts? Nothing else (whatsoever)?

https://d.godbolt.org/z/MjPe35Maz

release does turn off bounds checking.
May 26, 2022

On Wednesday, 25 May 2022 at 23:34:30 UTC, max haughton wrote:

>

https://d.godbolt.org/z/MjPe35Maz

release does turn off bounds checking.

But it does not turn off bounds checking if you add "@safe:" at the top of your source file. This is a very important detail! In release builds we have safety in @safe code and full performance in @trusted/@system code (which needs much more careful review as a safeguard against bugs). In debug builds we still have bounds checks in the @trusted/@system code too, which is useful for testing/debugging.