-
Notifications
You must be signed in to change notification settings - Fork 330
Refactorings in preparation for parallel visualization execution #13354
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
Conversation
Reduce lock contention by splitting context lock into a read/write one. Context lock has been slowly ignored in various jobs in favour of improved performance. It shouldn't be, as most of the time we only need a read context lock.
By default, no execution is triggered by push context request.
Most of `ExecutionService` now returns Futures that can be easier to compose and execute via threadpools.
When diagnostics are being gathered outside of ThreadManager, execution will blow up due to Truffle restrictions.
Should reduce lock contention on startup.
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.
Approval for .enso changes
When reporting error diagnostics we need to analyze the error underlying the `ExecutionException`, not the exception itself.
It now says 427, so adding +30 as a general rule. Dunno on why would increase be needed.
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 haven't tried to look at language server side of the change much
ExecutionService
changes towardsCompletionStage
seem good- possibly they could be even more reactive to avoid on/off/on switching
} | ||
return false; |
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.
Nit: the previous version with two return
statement in each if
branch felt more functional to me.
...e/runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionService.java
Show resolved
Hide resolved
return context.getThreadManager().submit(c); | ||
} | ||
|
||
private static <T> T resultOf(Future<T> future) { |
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.
Removal of resultOf
blocking call marks ExecutionService
as fully reactive (e.g. non-blocking) API. Good.
) | ||
) | ||
|
||
visualizationResultFuture.thenApply(visualizationResult => { |
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's reactive!
...ument-common/src/main/scala/org/enso/interpreter/instrument/execution/ReentrantLocking.scala
Show resolved
Hide resolved
...ment-common/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala
Show resolved
Hide resolved
public String getExceptionMessage(AbstractTruffleException panic) { | ||
var future = submitExecution(() -> computeExceptionMessage(panic)); | ||
return resultOf(future); | ||
public CompletionStage<String> getExceptionMessage(AbstractTruffleException panic) { |
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 one would very likely work better as:
CompletionStage<String> getExceptionMessage(CompletionStage<AbstractTruffleException> panic)
or something a like that being part of the reactive flow. It makes little sense to ex = toCompletableFuture().get()
and then enter again the guest code thread by getExceptionMessage(ex)
.
The same comment applies to typeOfValue
and other methods that inspect result of guest code execution.
I will address the remaining comments in follow up PRs. |
Pull Request Description
Work on reactive observers for visualizations revealed a number of blockers once one attempts to execute visualizations in parallel. This PR extracts the less controversial parts that became obvious once we opened a pandora's box, as well as a number of startup improvements:
IdMap
necessary for instrumentation at that stage)ExecutionService
to not blockHostClassLoader
thread-safeImportant Notes
Should be easier to review than #13219 that went through a number of experiments.
Some startup improvements should be visible from this change already as we reduce lock contention.
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.