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

Killing and reusing Julia consoles #1586

Closed
DillonJ opened this issue Oct 26, 2021 · 8 comments
Closed

Killing and reusing Julia consoles #1586

DillonJ opened this issue Oct 26, 2021 · 8 comments
Assignees
Labels
Milestone

Comments

@DillonJ
Copy link
Contributor

DillonJ commented Oct 26, 2021

When I run a workflow with multiple SpineOpt scenarios executed in parallel, when each execution completes, each console remains open and holding a lot of stuff in memory. In my case, around 6GB per console. There are a number of issues here:

  • I can't see a way to kill the consoles once the executions are complete - I only have interrupt and restart. Typing exit() into the console doesn't appear to work. Restart works to clear the memory but a fresh Julia session remains open and I can't see how to close it.
  • It should be possible to somehow, perhaps optionally, automatically kill a console when the execution is complete - maybe I can simply do this by having an exit statement at the end of the SpineOpt tool script. This will free up the memory for use by the remaining executions.
  • I have a project with 8 SpineOpt scenarios. I am running them 4 at a time. When the first 4 complete, I have 4 Julia consoles each of which could be used to "Hot start" my next scenario runs... but instead, my second 4 will all open in new julia consoles and need to be compiled. It would be nice if the consoles could be reused
@manuelma
Copy link
Collaborator

Thank you for this!
I like the idea of killing consoles, should be easy even on windows.
About using the same console on a different 'run', we need to do it as a user option as I think you suggest, because in general we want to support interactive results inspection post-run.

@jkiviluo
Copy link
Member

Similar issue: spine-tools/spine-engine#20

There is also the related issue of controlling the parallelization better. Max. number, and even more refined control, has been discussed before, but it seems we need a proper issue for it.

@soininen
Copy link
Contributor

There is also the related issue of controlling the parallelization better.

Indeed, and this can be disscussed under spine-tools/spine-engine#35

@soininen soininen self-assigned this Nov 9, 2021
@soininen soininen added this to the V0.7 milestone Nov 9, 2021
soininen added a commit to spine-tools/spine-engine that referenced this issue Nov 15, 2021
It is now possible to limit the number of persistent processes that run
simultaneously. The useful 'lifetime' of a persistent process is
between the instantiation of PersistentExecutionManager and the end of
PersistentExecutionManagerBase.run_until_complete(). After that the
process may be killed by Engine if the process limit has been reached.

We use semaphores to keep count on running persistent processes. This
commit also replaces the hand-written semaphore implementation for
ReturningProcess by Python's standard Semaphore class.

Re #35, spine-tools/Spine-Toolbox#1586
soininen added a commit that referenced this issue Nov 15, 2021
Engine may now kill the processes that run Python/Julia interpreters for
persistent consoles. This commit makes PersistentConsoleWidget issue a
warning in this case instead of getting stuck if user tries to use a
dead console.

Also, this adds widgets to control engine's maximum number of persistent
processes to Toolbox settings.

Re #1586, spine-tools/spine-engine#35
@soininen
Copy link
Contributor

It is now possible to control the number of console processes. The setting can be found in Toolbox settings under the Engine tab. Spine Engine will start killing random console processes that have finished execution when the limit is reached. This means that you'll still get the execution output in the console window but post-execution debugging is impossible as the Python/Julia interpreter connected to the window is dead.

@manuelma
Copy link
Collaborator

Nice job! But I think it would also be useful to create a context menu action to just kill a console. I think this issue is more about that, killing specific consoles that hog a lot of memory.

@soininen
Copy link
Contributor

Indeed. I wasn't planning on closing this issue yet.

On that note, it is currently possible to free most of the console's memory by restarting it as stated in the Description. This makes me wonder how useful a close option actually is. It is not difficult to implement, though, as I had it implemented for a few hours last week ;) I had to take it down, however, as it was interfering with something else I was working at that moment.

@manuelma
Copy link
Collaborator

You're right. I think it's mostly for users' piece of mind, and it's so easy to implement that why not?

soininen added a commit to spine-tools/spine-engine that referenced this issue Mar 15, 2023
soininen added a commit to spine-tools/spine-engine that referenced this issue Mar 15, 2023
soininen added a commit that referenced this issue Mar 15, 2023
soininen added a commit that referenced this issue Mar 15, 2023
Added an action to the console context menu that kills the console process.
A killed console refuses to take any input but can be restored by
restarting.

Re #1586
soininen added a commit to spine-tools/spine-items that referenced this issue Mar 15, 2023
Tool project item now has an option that, when set, kills persistent
console processes after execution is finished.

Re spine-tools/Spine-Toolbox#1586
soininen added a commit that referenced this issue Mar 15, 2023
Added an action to the console context menu that kills the console process.
A killed console refuses to take any input but can be restored by
restarting.

Re #1586
soininen added a commit to spine-tools/spine-engine that referenced this issue Mar 15, 2023
soininen added a commit that referenced this issue Mar 15, 2023
Added an action to the console context menu that kills the console process.
A killed console refuses to take any input but can be restored by
restarting.

Re #1586
soininen added a commit to spine-tools/spine-items that referenced this issue Mar 15, 2023
Tool project item now has an option that, when set, kills persistent
console processes after execution is finished.

Re spine-tools/Spine-Toolbox#1586
soininen added a commit to spine-tools/spine-items that referenced this issue Mar 15, 2023
Tool project item now has an option that, when set, kills persistent
console processes after execution is finished.

Re spine-tools/Spine-Toolbox#1586
soininen added a commit to spine-tools/spine-engine that referenced this issue Mar 15, 2023
soininen added a commit that referenced this issue Mar 15, 2023
Added an action to the console context menu that kills the console process.
A killed console refuses to take any input but can be restored by
restarting.

Re #1586
soininen added a commit that referenced this issue Mar 15, 2023
Added an action to the console context menu that kills the console process.
A killed console refuses to take any input but can be restored by
restarting.

Re #1586
soininen added a commit to spine-tools/spine-items that referenced this issue Mar 15, 2023
Tool project item now has an option that, when set, kills persistent
console processes after execution is finished.

Re spine-tools/Spine-Toolbox#1586
@soininen
Copy link
Contributor

soininen commented Mar 15, 2023

Now we have:

  • possibility to kill the console process from the console's right-click context menu; restarting the console will restore the it
  • option to kill the console process after execution finishes in Tool's properties tab

Reusing the console processes has already been possible by setting the "Group id" in Tool properties tab.

I believe we are done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants