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

Allow task interruption in groovy scripts #129

Merged
merged 15 commits into from
Nov 7, 2024
Merged

Conversation

rolnico
Copy link
Member

@rolnico rolnico commented Mar 4, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Feature

What is the current behavior?
If a task is interrupted by a user, it's handled differently depending on whether the task contains a groovy script evaluation or not:

  • If it's only a Java task, the interruption is well catched and the task is interrupted
  • If it contains a Groovy script evaluation, the Java thread stops but the groovy evaluation continues, which can cause performance issues if multiple big groovy scripts are running even when they are supposed to be interrupted.

What is the new behavior (if this is a feature change)?

  1. In the groovy CompilerConfiguration, a new ASTTransformationCustomizer on ThreadInterrupt has been added: it automatically adds a check on ThreadInterrupt in every loop (for, while) in the groovy scripts so that they stop if interrupted.
  2. Right before the script evaluation begins, a check is done on the thread interruption in order to not evaluate the script if it has already been interrupted.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Signed-off-by: Nicolas Rol <[email protected]>
Signed-off-by: Nicolas Rol <[email protected]>
@rolnico rolnico self-assigned this Mar 4, 2024
Signed-off-by: Nicolas Rol <[email protected]>
@rolnico rolnico marked this pull request as draft March 4, 2024 10:29
Copy link

sonarcloud bot commented Mar 4, 2024

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@rolnico rolnico marked this pull request as ready for review March 4, 2024 10:32
Copy link

sonarcloud bot commented Mar 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@rolnico
Copy link
Member Author

rolnico commented Mar 7, 2024

This PR will need a version of powsybl-core with powsybl/powsybl-core#2916 merged

Copy link

sonarcloud bot commented Jul 25, 2024

Copy link

sonarcloud bot commented Sep 16, 2024

# Conflicts:
#	.github/workflows/maven.yml
#	pom.xml
@rolnico rolnico marked this pull request as ready for review November 5, 2024 13:40
@rolnico rolnico requested review from olperr1 and removed request for BrunoRte November 5, 2024 13:40
Copy link

sonarcloud bot commented Nov 7, 2024

Copy link

sonarcloud bot commented Nov 7, 2024

@rolnico rolnico merged commit 3b93069 into main Nov 7, 2024
13 checks passed
@rolnico rolnico deleted the nro/task_interruption branch November 7, 2024 15:44
rolnico added a commit that referenced this pull request Nov 7, 2024
* add ThreadInterrupt check in groovy loops and right before execution + tests

Signed-off-by: Nicolas Rol <[email protected]>

* fix issues

Signed-off-by: Nicolas Rol <[email protected]>

* fix issues

Signed-off-by: Nicolas Rol <[email protected]>

* fix checkstyle issues

Signed-off-by: Nicolas Rol <[email protected]>

* Use Abstract test from powsybl-core

Signed-off-by: Nicolas Rol <[email protected]>

* modif + test on MetrixDslDataLoader

Signed-off-by: Nicolas Rol <[email protected]>

* fix issue

Signed-off-by: Nicolas Rol <[email protected]>

* Adapt to AbstractTaskInterruptionTest changes

Signed-off-by: Olivier Perrin <[email protected]>

* Temporary build powsybl-core 'nro/groovy_interruption' branch

Signed-off-by: Olivier Perrin <[email protected]>

* move addCompilationCustomizers to createCompilerConfig to be consistent with TimeSeriesDslLoader

Signed-off-by: Nicolas Rol <[email protected]>

---------

Signed-off-by: Nicolas Rol <[email protected]>
Signed-off-by: Olivier Perrin <[email protected]>
Co-authored-by: Olivier Perrin <[email protected]>
(cherry picked from commit 3b93069)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants