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

Reschedule guest code execution into dedicated thread pool #12613

Merged
merged 33 commits into from
Mar 28, 2025

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Mar 24, 2025

Pull Request Description

Enso is using Truffle threads and especially those that allow execution of guest code too much. A lot of other code is running in such threads. However those threads are subject to special control and support from Truffle framework (for example execution of safepoints).

Let's reduce the usage of those Truffle threads to a minimum. Leave the other threads "normal".

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,
  • Unit tests have been written where possible.

@JaroslavTulach JaroslavTulach self-assigned this Mar 24, 2025
@JaroslavTulach JaroslavTulach marked this pull request as draft March 24, 2025 10:38
@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Mar 24, 2025
@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/GuestCodeExecutor12500 branch from e3b2be8 to b591593 Compare March 25, 2025 09:14
@JaroslavTulach
Copy link
Member Author

There are three remaining failures in RuntimeAsynchCommandTest.

The rest of the JVM tests seems to be green.

mergify bot pushed a commit that referenced this pull request Mar 25, 2025
- based on experiments made in #12613 that are by themselves motivated by #12500
- `TruffleLogger` shall **only be used** in the interpreter running _guest code_
- most of the code in `runtime-instrument-xyz` projects is **not** running a _guest code_
- most of the code in these instruments schedules runs of _guest code_
- thus using `TruffleLogger` isn't appropriate and it yields exception when it cannot find `EnsoContext` around
- let's make the code ready for _context_ **not being around**
- let's use SLF4J instead of `TruffleLogger`
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Mar 26, 2025

There are three remaining failures in RuntimeAsynchCommandTest.

It flies!

@@ -794,33 +792,36 @@ public boolean isGlobalSuggestionsEnabled() {

/** The job parallelism or 1 */
public int getJobParallelism() {
var n = getOption(RuntimeOptions.JOB_PARALLELISM_KEY);
var base = n == null ? 1 : n.intValue();
var optimal = Math.round(base * 0.5);
Copy link
Member Author

Choose a reason for hiding this comment

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

@JaroslavTulach
Copy link
Member Author

@JaroslavTulach JaroslavTulach marked this pull request as ready for review March 27, 2025 16:03
@JaroslavTulach JaroslavTulach added this to the 2025-Q2 Release milestone Mar 27, 2025
override def contextModifiers: Option[Context#Builder => Context#Builder] =
Some(b => {
b.allowCreateThread(true)
.option(RuntimeOptions.JOB_PARALLELISM, "" + parallelism)
Copy link
Member Author

Choose a reason for hiding this comment

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

  • this test no longer allocates its own new Thread, but it relies on builtin JOB_PARALLELISM
  • this could help a lot with - Improve visualizations feedback via cache observables and safepoints #10525
  • enough to increase value of JOB_PARALLELISM (default remains 1)
  • schedule visualization computations as getThreadManager.submit
  • and they will be executed in parallel to regular computation

}
return null;
});
resultOf(pending);
Copy link
Member Author

Choose a reason for hiding this comment

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

@JaroslavTulach JaroslavTulach merged commit e5d28e1 into develop Mar 28, 2025
71 of 72 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/GuestCodeExecutor12500 branch March 28, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants