Skip to content
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

Move execution environment from State to EnsoContext #11075

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

4e6
Copy link
Contributor

@4e6 4e6 commented Sep 13, 2024

Pull Request Description

related #10719

Changelog:

  • refactor: move execution environment from State to EnsoContext

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

@4e6 4e6 added the CI: No changelog needed Do not require a changelog entry for this PR. label Sep 13, 2024
@4e6 4e6 self-assigned this Sep 13, 2024
@4e6 4e6 added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Sep 17, 2024
@4e6 4e6 added the CI: Ready to merge This PR is eligible for automatic merge label Sep 17, 2024
@mergify mergify bot merged commit 9179dff into develop Sep 17, 2024
41 of 42 checks passed
@mergify mergify bot deleted the wip/db/10719-refactor-state-execution-environment branch September 17, 2024 20:50
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was originally suggested to:

Changing the state may require

e.g. to store State as "thread local variable" - but that's something we should do anyway.

I am sad that this PR only moves Environment and not the whole State.

Anyway, this PR changes the behavior. Previously the ExecutionEnvironment was associated with a thread - now each change is shared among all Enso threads.

E.g. this is change enables unexpected side-effects. That's wrong in a functional language like Enso.

}

/**
* Enable execution context in the execution environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description is wrong.

@@ -54,7 +54,10 @@ public final class DataflowError extends AbstractTruffleException implements Ens
public static DataflowError withDefaultTrace(State state, Object payload, Node location) {
assert payload != null;
boolean attachFullStackTrace =
state == null ? true : state.currentEnvironment().hasContextEnabled("Dataflow_Stack_Trace");
state == null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we check for state? Previously we called a method on the state - e.g. the check was necessary. Now such a check is superfluous.

public ExecutionEnvironment enableExecutionEnvironment(Atom context, String environmentName) {
ExecutionEnvironment original = executionEnvironment;
if (executionEnvironment.getName().equals(environmentName)) {
executionEnvironment = executionEnvironment.withContextEnabled(context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change changes the executionEnvironment for all threads, not only for the caller. That's a change in semantics.

state == null
|| EnsoContext.get(location)
.getExecutionEnvironment()
.hasContextEnabled("Dataflow_Stack_Trace");
if (attachFullStackTrace) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a performance bug

related to code in this method. How does your change affects the benchmarks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants