Skip to content

Orthogonal "Release optimization target" and "Runtime safety" #3225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Sep 13, 2019 · 2 comments
Closed

Orthogonal "Release optimization target" and "Runtime safety" #3225

ghost opened this issue Sep 13, 2019 · 2 comments
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@ghost
Copy link

ghost commented Sep 13, 2019

This proposal is about a more flexible and transparent alternative to existing build modes: debug, release-fast, release-small, and release-safe.

The idea is to make "optimization target" and "runtime safety" into orthogonal features.

Optimization target for the binary then becomes either "performance", "fastbuild", or "smallsize". Runtime safety is a separate concern.

Runtime safety checks would be enabled on an individual basis in each build.

in buildscript:

setBinaryOptimization(OptimizationTarget.Fastbuild);

enableCheck(RuntimeSafety.Overflow);
enableCheck(RuntimeSafety.DivideByZero);
enableCheck(RuntimeSafety.....);
//....

safetyLevel = 50; // percentage or threshold for userland runtime checks

in userland code:

//comptime evaluated!
if(getRuntimeSafetyLevel() >= 50){
	assert(....)
}

// std could offer some percentage value "constants" for standardization purposes
if(getRuntimeSafetyLevel() >= Safety.MEDIUM){
	// do safety check
}


if(getRuntimeSafetyLevel() >= Safety.HIGHEST){
	// do complex data integrity test here
	// when safety level is high, can catch bugs 
	// when safety level is lower, still serves as documentation
}

This would IMO be very transparent and understandable for the user, vs having to read about the different build modes in the docs.

Related: #978

@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Sep 16, 2019
@andrewrk andrewrk added this to the 0.6.0 milestone Sep 16, 2019
@Tetralux
Copy link
Contributor

Being able to set optimization level, debug info, debug info type, bounds checks, cast checks etc, on/off on a per-item basis could be useful. I'm not sure about percentages though.

@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Feb 10, 2020
@FlyingWombat
Copy link

Instead of enableCheck, how about disableCheck in the build-script to follow Rust's "safety by default" idea? There could also be a compiler option like --safety-off=all for disabling all safety checks for that build.

For program code, how about disabling specific checks for blocks of code with unsafe(Safety.Overflow) { ... }?

@andrewrk andrewrk closed this as completed Oct 9, 2020
@mlugg mlugg added this to Safety Aug 22, 2024
@mlugg mlugg moved this to To do in Safety Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
Status: To do
Development

No branches or pull requests

3 participants