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

Feature request: Save state of a Julia session #22598

Closed
TsurHerman opened this issue Jun 28, 2017 · 11 comments
Closed

Feature request: Save state of a Julia session #22598

TsurHerman opened this issue Jun 28, 2017 · 11 comments
Labels
feature Indicates new feature / enhancement requests

Comments

@TsurHerman
Copy link

The ability to save the state of a Repl'd Julia session , and to resume it in a later date.
This feature coupled with the "Reloadable Modules" feature and the cycler mode in Juno will save copious amounts of "the first call is slow" time.

@iblislin
Copy link
Member

The ability to save the state of a Repl'd Julia session , and to resume it in a later date.

Maybe JLD(https://github.com/JuliaIO/JLD.jl) can do the trick?

@TsurHerman
Copy link
Author

I don't think so , I am talking about saving the binary state of the session including loaded modules
and jitted functions.
In such a way that if I start a new Julia session using the previously saved state, then calling any previously jitted function would be instant and not "slow the first time"

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Jul 10, 2017

Why are you terminating a session if you just want to reconstitute the same session again? Why not just continue in that case? Some form of persistent compilation caching would have the same effect without being tied to session state in the same way. This seems to be an overly specific feature request – what's actually wanted is a reduction in compilation delays. This could be one way to do that, but there's not much reason to believe it's the only or best way.

@TsurHerman
Copy link
Author

When in development mode, I don't want to "reconstitute the same session again" , I just want to
reconstitute the last "good" state I was in before I accidentally broke something or went into an infinite loop waiting for a non-responsive camera(for example).

My base script that only initialize things and reads data takes 60 seconds to load the first time and only a second after that.

This Feature request would solve that.

Although it takes only a second to load when warm, it takes 60 second for the users of my Application
I would trade that for somewhat delayed loading time of Julia.

Some form of persistent compilation caching would have the same effect
See discourse conversation here

I agree completely, I just think that saving the state is easier and more achievable in the short-run
and will cover lot of the open issues , slow first-call , obfuscation, responsive debugger(based on Gallium)

When I first encountered Julia I was under the impression that this feature is already baked into the language

--output-o name Generate an object file (including system image data)
--output-ji name Generate a system image data file (.ji)
--output-bc name Generate LLVM bitcode (.bc)

But could never managed to get it to work.

And from philosophical point of view it pains me to see everything re-compiles again and again
:-)
Thank you for taking the time to answer , my real purpose was to raise awareness and to point towards
a possible solution, not necessarily the best solution.

@StefanKarpinski
Copy link
Member

Thanks for the context and explanation – that does help understand your needs here (which I'm sure are not unique). I've often wanted the ability to snapshot a running program and be able to restart the snapshot – multi-shot continuations but for programs, if you will – but it seems to be technically nearly impossible to do this because of the large amount of program state which cannot be persisted or restored across processes.

@TsurHerman
Copy link
Author

I suppose the majority of the time is spent compiling to binary, you could I presume cache that to speed things up.
The program state will be constructed normally but the compile to binary step could probably be skipped for many functions.

@mauro3
Copy link
Contributor

mauro3 commented Jul 11, 2017

A bit off-topic, but Revise.jl helps a lot with what you describe here: https://discourse.julialang.org/t/ann-higher-productivity-fewer-julia-restarts-with-revise-jl/4564

@mahiki
Copy link
Contributor

mahiki commented Dec 20, 2017

Perhaps a more limited use-case is achievable:

I often find myself having to reboot my (corporate managed) machine, for a host of reasons {mandatory security patch, wifi networking keeps dropping, finally figured out how to kill mac animations, etc.}.

I'm often halfway through something interesting in julia REPL, and I can't tie it all up before having to restart.

It would be convenient to save the imported packages, function and variable definitions, all the things I will have to reload after my machine reboots.

I'm not concerned about jit compilation or speed, just avoiding a bunch of copy paste into REPL on restart.

@Tetralux
Copy link
Contributor

Tetralux commented Dec 20, 2017

Perhaps there is a user-level answer to this? Like, writing a macro that creates a stub function which is able to change which function is called from the moment where you declare that you want to make a snapshot.
Thereby, keeping the compiled functions around but not accessible through their originally bound name -- basically, the macro has turned the function into a lambda where which lambda is called depends on whether you've made a save state or not, etc.

Probably involving global state for tracking them and atomic locks to update them, for instance.

You might then mark any function you want controlled this way with the macro-call.
Plus, of course, you have some sort of global state or whatever to control if it's turned on or not; if not, then the macro could just emit the function unmodified.

@Tetralux
Copy link
Contributor

[Added more detail to previous comment.]

@brenhinkeller brenhinkeller added the feature Indicates new feature / enhancement requests label Nov 21, 2022
@ViralBShah
Copy link
Member

This seems better to be discussed on Discourse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

No branches or pull requests

8 participants