-
-
Notifications
You must be signed in to change notification settings - Fork 241
Allow configuring safety level through environment variables #1278
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
base: master
Are you sure you want to change the base?
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1278 |
What if we call this The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the pull request! 👍
Please see my comment #1046 (comment) and subsequent response by @TitanNano, where we detailed quite a bit of the design.
Some feedback:
-
My first impression is that I'd rather not have this configured via environment variables, that's rather brittle and easy to silently get wrong (e.g. someone sets the environment variable for Godot, not for rustc). Instead, it should be a Cargo feature. While features are technically additive, we already do a similar thing with
api-4-2
etc.- I know it can be slightly annoying since you can't easily enable a feature only in the Release config. But this isn't really easier with env vars.
-
Safety profiles should be named, not magic numbers. It's not obvious whether "0" means "no safety" or "no performance". An option is to use the term
checks
, but it could also be something else.- The individual levels could be called
fast-unsafe
,balanced
andparanoid
. (To be discussed) - Cargo feature would then be
checks-fast-unsafe
. - Conditional compilation would be
#[cfg(checks_at_least = "balanced")]
. Let's avoidnot
if possible.
- The individual levels could be called
I think including chosen safety profile in preamble would be good idea as well (something along the lines of "Initialize godot-rust (API v4.4.stable.official, runtime v4.4.stable.official) fast-unsafe/balanced/slow-safe mode"?). Lines 288 to 293 in 0dde85e
There are some validity checks which would be nice to cover, albeit I wouldn't sweat too much about it – we can cover them later 😄. One such example is the gdext/godot-core/src/obj/gd.rs Lines 1078 to 1087 in aaf3ed5
(I'll underline – I don't think we should sweat to cover all (or even the aforementioned one) the cases, we should just make an issue for tracking them) |
Yeah, I'd suggest not to add more specific checks in this PR, to get the basic mechanism working first 🙂 As for defaults, it should be:
While it means the user won't get max performance per default, it's better if they don't risk UB by default. But if we go for Cargo feature, we need to find a way how they can opt in... I could imagine that in Debug mode, many would still want to keep paranoid or balanced checks, while Release builds should have fast performance. It's unfortunately not that easy to specify Cargo features based on the build profile... |
793ac8b
to
99e3534
Compare
779c043
to
ddc5b76
Compare
99e3534
to
37b86cd
Compare
37b86cd
to
12a3cce
Compare
Hm, 6 new Cargo features is quite a lot, although I see the dilemma. What would the alternatives be? |
Addresses #1276.
Allow configuring safety level through
GDEXT_SAFETY_LEVEL_DEBUG
andGDEXT_SAFETY_LEVEL_RELEASE
environment variables. Not sure if it can be implemented as ExtensionLibrary function. Also implemented as Cargo features may be annoying.debug_assertions
(RTTI, backtrace, Array elements validation)(Correct me if I missed anything).