-
Notifications
You must be signed in to change notification settings - Fork 443
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
Asynchronous source code loading - Package Reloading #175
Comments
Thanks for opening this.
Interesting, did you profile it? What part of loading is causing this, is it the actual
That's the kind of complexity I want to stay very far away from. Ryven had a bunch of concurrency stuff in the past and there's good reasons it doesn't now. Loading source code shouldn't take this long, and there's tons of things to optimize before considering concurrency.
A nodes package can store any amount of static data internally, there's purposefully basically no restrictions on that. In this model, simply replacing components will get your packages into inconsistent states in no time at all. While the concept of hot reloading doesn't seem sensible to me in Ryven's unrestricted model, a "quick reload" which simply saves the project and re-launches it with the same configuration could serve a similar purpose and very much does fit into the model. From the node developer's side this simply requires them to implement their |
I did profile it. Here's a snapshot of importing the build_in library. This takes into account only getting the source of the code and the gui (only calling
I can see that, makes more sense. How would you handle potentially broken nodes? Simple try / except clause? |
Could you show a flame graph of the whole process of importing a package using a profiler?
It would be nice if Ryven doesn't terminate if a package broke. Some parts like the
Implementation wise, could look something like this (see multiprocessing) original process import multiprocessing as mp
def on_quick_reload(config, tmp_file_path):
mp.set_start_method('spawn')
q = mp.Queue()
p = mp.Process(target=quick_launch, args=(q,config, tmp_file_path))
p.start()
ret = q.get()
if ret == 'success':
sys.exit() # and switch to new window?
else:
show_error(ret) new process def quick_launch(q, config, tmp_file_path):
try:
Ryven.run(config, tmp_file_path, on_launch=lambda _: q.put('success'))
except Exception as e:
q.put(e); sys.exit() # return error to the spawning process |
Currently I don't have time for this and I don't know if and when I'll be able to. If I'll ever get to it I'll do it, though I think the above results showcase the problem. I don't think asynchronously inspecting the code will be that hard to implement and it's only for a very specific part of ryven.
Nice, will probably check it out when I have more time. |
allows to defer loading of component source codes; workaround for #175
I added an option to defer source code loading. If used, the user needs to click "load source code" for each node type they want to inspect. Decreases import time of |
Added defer source code loading in StartUpDialog for leon-thomm#175
I added the GUI part of this in the StartUpDialog in the open PR. I believe that the option should start as enabled. We want the users to start with the best user experience by opening the default version of Ryven. I can add this in the PR. I could also see the code loading immediately when the user clicks on a node. If
Depends. You could keep it open until editor reloading is implemented as well. Otherwise, notify me on how to proceed with the above and you can close the issue. |
closed in https://github.com/leon-thomm/Ryven/releases/tag/v3.5.0 with deferred loading |
This issue discusses 2 concerns:
For Source Code Loading
I'm documenting an idea for asynchronous source code loading, in case this might be interesting. First of all, some left-over code in
gui_env.py
retrieves the source code of the GUI if it exists, appends it to a list and does nothing with it. In #174 , I also added that code in the decorator function for legacy purposes, before realizing it does nothing. I believe these source code retrievals should be removed.The source code of the node and its GUIs is captured in
code_storage.register_node_type
. I noticed that this function, ifinstance.src_code_edits_enabled
is False, takes around 3-10 ms (and more) to complete, depending on the GUI code present. For example, pkg_test takes 0.7s to import, largely due to this fact. This to me is not desirable, since python scales linearly. If we have a package with 50 nodes, why should Ryven freeze for 2 or more seconds for all source codes to be loaded, when it's not really that important?My proposed solution is asynchronous source loading. Have the source loading happen on a separate thread. If someone drags a node and that node's source loading hasn't ended, it loads the source code on the spot. I do realize this might not be worth thinking that much and requires testing, but I'm documenting it here just in case.
For "Hot" Package Reloading
Is there any reason that prevents us from having package reloading? The only thing I can think of that is hard is how to handle a flow that's already been created but the package has changed. But the same thing kind of applies when simply closing and starting Ryven again. Also, this feature might benefit from asynchronous source code loading.
This is a documentation of two ideas for better QoL in Ryven. What are your thoughts?
The text was updated successfully, but these errors were encountered: