[swift-dev] deprecating -Ounchecked
Erik Eckstein
eeckstein at apple.com
Fri Nov 3 10:31:29 CDT 2017
> On Nov 2, 2017, at 8:50 PM, Chris Lattner <clattner at nondot.org> wrote:
>
>
>> On Nov 2, 2017, at 9:52 AM, Erik Eckstein via swift-dev <swift-dev at swift.org> wrote:
>>
>> Hi,
>>
>> I’d like to propose to deprecate the -Ounchecked swift optimization mode.
>>
>> The -Ounchecked mode actually contradicts one of the main goals of swift: to be a safe language.
>> In the past we didn’t see lot of significant performance differences compared to -O (there were some improvements but also some regressions).
>> Also, we want to reduce the effort of maintaining too many different optimization modes, especially because we recently added -Osize.
>>
>> Deprecating would mean that we map -Ounchecked to -O.
>>
>> If you have any comments or concerns, please let me know
>
> What’s the motivation for this? What problem does it solve?
There are several issues:
First, Ounchecked does not come for free. To really support this mode we would have to constantly track performance metrics for this, investigate performance/codesize regressions, etc. This is a lot of effort.
So if we replace Ounchecked with an option -unsafe-remove-checks (similar to -assume-single-threaded), as Johannes suggested, this is more like a “at your own risk” thing (regarding performance). For example, it might happen that users see perf regressions from one release to another, using this option.
The second thing is, IMO, that -Ounchecked suggests that it’s just another choice like -O. But I think we should encourage people to not use Ounchecked. I think it’s fine if experienced developers, who know what they are doing, use -unsafe-remove-checks, but we should not promote this mode in a prominent place like in the -O namespace. This is just my personal opinion and I’m sure some people have other opinions on this.
The third issue is that we now have -Osize. The -unsafe-remove-checks would be orthogonal to -O and -Osize.
BTW, we should rename -O to -Ospeed for consistency (keeping -O as an alias for -Ospeed).
>
> Swift isn’t a "strict safety at all costs” language. It is a pragmatic language which aims to give people tools to solve problems. One of the nice things about -Ounchecked is that it provides an easy way to get a data point about the cost of runtime checks.
>
> -Chris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20171103/0a72514a/attachment.html>
More information about the swift-dev
mailing list