-
Notifications
You must be signed in to change notification settings - Fork 326
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
Replace IOContexts with execution env and contexts #6171
Conversation
7bc7cce
to
009c3f2
Compare
distribution/lib/Standard/Base/0.0.0-dev/src/Errors/Common.enso
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/state/ExecutionEnvironment.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/state/ExecutionEnvironment.java
Outdated
Show resolved
Hide resolved
.../runtime/src/main/java/org/enso/interpreter/node/expression/builtin/runtime/ContextName.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Error.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
public ExecutionEnvironment withContextEnabled(Atom context) { |
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.
Shouldn't we strive for making this function working on fast path?
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.
I would have to refactor pretty much any call to map i.e. almost every line in that method, to make native image build happy. I would say that kind of defeats the purpose?
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.
What's your purpose? Is the purpose to run Enso fast? Well, in such case that's not happening as soon as somebody uses withContextEnabled
- that's always going to be slow.
refactor pretty much any call to map
Possibly using HashMap
for storage of two values (Input
, Output
) wasn't good idea to begin with?
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.
Fine, replaced by two arrays that emulate the map. The reason why I don't hardcode those in fields is that I'm trying to be generic enough in preparation for potential future Context
values.
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.
It is also a big overkill given that currently we only have Input
and Output
. So if you feel strongly about it, I could just go back to storing those in fields.
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.
I am assuming that withContextEnabled
/withContextDisabled
operations are going to be spread all around the codebase possibly included inside of .map
lambdas processing large data structures and we want to make them fast in order to avoid slowing down the rest of the interpreter. Is such assumption a false expectation? As I am seeing a disagreement and I don't understand what are its roots...
replaced by two arrays that emulate the map
The code is now less readable, but at least it doesn't need to be behind @TruffleBoundary
. However I cannot judge how well it partially evaluates without looking at IGV graphs. Btw. what do we want to see in IGV when we look at withContextEnabled
?
- when already enabled - a single field/bit check to verify the context is already enabled
- when disabled - more work - field write and switching the
State
to a new configuration (possibly also a costly allocation of the new configuration)
trying to be generic enough in preparation for potential future Context values.
Generic code can't be as fast as code that handles/speculates on fixed set of values.
... if you feel strongly ...
Maybe we could change one of our benchmarks to use withContextEnabled
few million of times and compare it to a benchmark without context manipulation? Then we all would have something measurable to know how to feel about this matter.
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.
I will file a separate ticket to investigate if this becomes a perf issue.
engine/runtime/src/test/java/org/enso/interpreter/test/ValuesGenerator.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/ContextTest.scala
Outdated
Show resolved
Hide resolved
@jdunkerley added a CLI option |
e550579
to
ad3b1bb
Compare
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/runtime/Context.java
Outdated
Show resolved
Hide resolved
.getBuiltins() | ||
.error() | ||
.makeUnimplemnted("execution environment mismatch"); | ||
throw new PanicException(error, this); |
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.
I really doubt a Panic
is what we want! I don't even understand what's the purpose of specifying environment name in the is_enabled
check. Environments are supposed to be a set of contexts. All the user wants is to take a context and check if it is currently enabled. E.g. Context.Input.is_enabled
.
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.
This isn't really specified well in the design doc. Nor is the usage of the environment name so if you feel strongly about it, probably worth bringing up with that doc's authors.
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.
At least for the moment - there is no intention to specify anything other than the current context when calling this function.
If we find a need to use this we can revisit.
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.
At least for the moment - there is no intention to specify anything other than the current context when calling this function.
Obviously! Specifying anything else makes no sense. At least I cannot envision the use-case.
I'd say: One doesn't care about the environment. One only wants to find out if a Context
is_enabled
"right now". Nothing else makes sense.
...src/main/java/org/enso/interpreter/node/expression/builtin/runtime/ContextIsEnabledNode.java
Outdated
Show resolved
Hide resolved
|
||
@BuiltinMethod( | ||
type = "Runtime", | ||
name = "current_execution_environment", |
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.
This method shall not exists from my API designer perspective as it bypasses the Context
. I assume @jdunkerley wants the method to do production/non-production property configuration, but we should offer other means for that - not this method.
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.
We agreed that Execution_Environment
is really an alias for Text
and I believe I'm following the design doc so I don't really understand the comment.
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.
I won't be using this for configuration - from the libs perspective I don't expect this to be used.
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.
There is a story about magical strings. I have a feeling the returned textual value has the potential to provide "magical" insights into something that should rather be hidden.
...I don't expect this to be used.
Personally I'd rather not expose such API, especially if there is no use-case for it.
engine/runtime/src/main/java/org/enso/interpreter/runtime/builtin/Error.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@CompilerDirectives.TruffleBoundary | ||
public ExecutionEnvironment withContextEnabled(Atom context) { |
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.
What's your purpose? Is the purpose to run Enso fast? Well, in such case that's not happening as soon as somebody uses withContextEnabled
- that's always going to be slow.
refactor pretty much any call to map
Possibly using HashMap
for storage of two values (Input
, Output
) wasn't good idea to begin with?
a667c50
to
065462d
Compare
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.
Couple of nit pics
|
||
@BuiltinMethod( | ||
type = "Runtime", | ||
name = "current_execution_environment", |
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.
I won't be using this for configuration - from the libs perspective I don't expect this to be used.
.getBuiltins() | ||
.error() | ||
.makeUnimplemnted("execution environment mismatch"); | ||
throw new PanicException(error, this); |
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.
At least for the moment - there is no intention to specify anything other than the current context when calling this function.
If we find a need to use this we can revisit.
engine/runtime/src/main/java/org/enso/interpreter/runtime/state/State.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/state/State.java
Outdated
Show resolved
Hide resolved
065462d
to
a4b267b
Compare
As per design, IOContexts controlled via type signatures are going away. They are replaced by explicit `Context.if_enabled` runtime checks that will be added to particular method implementations. `production`/`development` `IOPermissions` are replaced with `live` and `design` execution enviornment. Currently, the `live` env has a hardcoded list of allowed contexts i.e. `Input` and `Output`.
Added a fix for #6131 to allow for some testing.
Changed the default execution env to `live` since that is probably what we want for CLI anyway. Got rid of `TruffleBoundary` annotations by using straight arrays that emulate map.
7fb8813
to
9b5c12b
Compare
As per design, IOContexts controlled via type signatures are going away. They are replaced by explicit `Context.if_enabled` runtime checks that will be added to particular method implementations. `production`/`development` `IOPermissions` are replaced with `live` and `design` execution enviornment. Currently, the `live` env has a hardcoded list of allowed contexts i.e. `Input` and `Output`. # Important Notes As per design PR-55. Closes #6129. Closes #6131.
Pull Request Description
As per design, IOContexts controlled via type signatures are going away. They are replaced by explicit
Context.if_enabled
runtime checks that will be added to particular method implementations.production
/development
IOPermissions
are replaced withlive
anddesign
execution enviornment. Currently, thelive
env has a hardcoded list of allowed contexts i.e.Input
andOutput
.Important Notes
As per design PR-55. Closes #6129. Closes #6131.
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
If GUI codebase was changed, the GUI was tested when built using./run ide build
.