-
Notifications
You must be signed in to change notification settings - Fork 323
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
Run node in a different execution environment #11173
Run node in a different execution environment #11173
Conversation
3d11bac
to
169e386
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.
Use ContextThreadLocal.
engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java
Outdated
Show resolved
Hide resolved
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.
lgtm
val invalidatedExpressions = builder.result() | ||
if (invalidatedExpressions.nonEmpty) { | ||
val updates = invalidatedExpressions.collect { | ||
case expressionId if expressionId ne null => |
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.
How is the null
condition even possible?
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 remember I added this guard to fix NPE. But I don't remember exactly how the null value appears
/** | ||
* @return the root of this node. | ||
*/ | ||
public abstract RootNode getRootNode(); |
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.
No, we do not want to expose getRootNode()
. It is only used by:
EnsoContext context = EnsoContext.get(info.getRootNode());
originalExecutionEnvironment = context.getExecutionEnvironment();
and corresponding setter. Just call it getExecutionEnvironment()
and setExecutionEnvironment
.
Btw. There already is setExceptionEnvironment below why we have two ways of doing the same thing? Can you document the methods and describe different among them?
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 don't like the statefulness kept inside of the IdExecutionService
. Rather than that let the only service only suggest a change of environment by having a method like:
StringOrSomeEnvironmentType findExecutionEnvironment(Info);
and then let all the work of enabling it and especially disabling it in the IdExecutionInstrument
itself.
That will simplify the API to a single method and we can remove getRootNode and other new methods.
engine/polyglot-api/src/main/java/org/enso/polyglot/debugger/IdExecutionService.java
Outdated
Show resolved
Hide resolved
engine/polyglot-api/src/main/java/org/enso/polyglot/debugger/IdExecutionService.java
Outdated
Show resolved
Hide resolved
...runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionCallbacks.java
Outdated
Show resolved
Hide resolved
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.
The IdExecutionService
interface with single method addition looks fine. Few more comments on the engine&instrument side.
...cution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java
Outdated
Show resolved
Hide resolved
...cution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java
Outdated
Show resolved
Hide resolved
...cution/src/main/java/org/enso/interpreter/instrument/id/execution/IdExecutionInstrument.java
Outdated
Show resolved
Hide resolved
var iteration = 0 | ||
while (!isProgramStarted && iteration < 100) { | ||
val out = context.consumeOut | ||
Thread.sleep(200) |
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.
Ech. Thread.sleep
doesn't belong into programs and it is better to avoid them in tests too. Please replace with proper wait/notify
primitives:
context.waitForOut(200);
that will be notified immediately as soon as some output is delivered.
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.
The output is updated from the Enso program. How do you notify the waiting method in the test?
...runtime-instrument-common/src/main/java/org/enso/interpreter/instrument/ExecutionConfig.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/EnsoContext.java
Show resolved
Hide resolved
@@ -87,10 +88,31 @@ public final class EnsoLanguage extends TruffleLanguage<EnsoContext> { | |||
private static final LanguageReference<EnsoLanguage> REFERENCE = | |||
LanguageReference.create(EnsoLanguage.class); | |||
|
|||
private final ContextThreadLocal<ExecutionEnvironmentReference> threadExecutionEnvironment = |
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.
Why is this variable in the EnsoLanguage
and not in EnsoContext
?
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.
Context thread local references must be created during the invocation in the TruffleLanguage constructor.
Pull Request Description
close #10719
Changelog:
expressionConfigs
parameter to theexecutionContext/recompute
requestIdExecutionInstrument
allowing to run a single node in a specified execution environmentRuntimeServerTest
is becoming too bloatedImportant Notes
The updated
executionContext/recompute
request.Use cases
invalidatedExpressions
parameter.expressionConfigs
parameter with emptyexecutionEnvironment
expressionConfigs
and specify theexecutionEnvieronment
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.