You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
improve start time by populating sketchbook/libraries on threads #2945
To clarify, this would involve running the population of the "Open Recent" and "Import Library..." menus on separate background threads, so that they no longer block the main thread, thereby (effectively) saving on I/O time (since the I/O now takes place in a background thread), right?
@joelmoniz it's for the methods that rebuild the sketchbook menu. It's very slow to walk the sketchbook hierarchy, looking for sketches, libraries, tools, etc. If you have dozens of sketches, or a even a single sketch that's used saveFrame() to create 1000s of files, the I/O will be extremely slow. (Even worse if your machine doesn't have an SSD.)
Ah, thank you. I'm almost done working on this, and should be able to file PR by tomorrow. Could you please clarify one small point for me? Does the sketchbook menu refer to File>Sketchbook, or to Sketch? I did some profiling, and the former does not seem to affect the start time at all, since the first time the sketchbook is actually walked searching for sketches is here, when the user actually clicks on the File>Sketchbook menu item. Tool, etc. do however, and I'll submit a PR that improves this.
Sorry, I misspoke. It's for the methods that walk the sketchbook... These are for 1) getting the list of sketches (to put in the sketchbook window, in the past this was a menu, which is what I was referring to in the previous comment), 2) getting the modes, libraries, and tools. If you have a large sketchbook, or a lot of libraries installed, all or some of these can take a very long time to load.
If it's something that's needed immediately, that can't be done on a thread, but depending on the situation, this can happen in the background. The fix isn't terribly difficult, it just requires looking at the code very closely to make sure that we're doing it in the right place and taking all the scenarios into account.
Ah, thank you. As far as I could see, the walking is done just-in-time, when the user actually opens the Sketchbook window. I've profiled the code too, and though I had several large sketches (1+ GB each), this doesn't affect start time at all (the method call doesn't even show up on the profiler). I'll look into this a little more and make sure that this is indeed so.
There is one problem I'm facing, however. The maximum amount of time seems to be taken to load up Tools, for some reason. And though they aren't required immediately, and I'm able to offload their loading onto threads, updating the Tool menu sometimes tends to cause an error to be thrown, even though I've made it a point to ensure that all swing operations have been done on the EDT (a ClassCastException stating that the Windows LAF cannot be typecast to the Nimbus LAF). I did a little debugging, and the source of the error seems to be because the Movie Maker's init() method is not called from the EDT, even though it extends the JFrame class (as a result of which lots of operations in init() need to be specifically done on the EDT, I think). Could you please let me know if my line of reasoning is correct? If so, shall I submit a PR that fixes this first?
Activity
joelmoniz commentedon Dec 18, 2014
To clarify, this would involve running the population of the "Open Recent" and "Import Library..." menus on separate background threads, so that they no longer block the main thread, thereby (effectively) saving on I/O time (since the I/O now takes place in a background thread), right?
benfry commentedon Apr 5, 2015
@joelmoniz it's for the methods that rebuild the sketchbook menu. It's very slow to walk the sketchbook hierarchy, looking for sketches, libraries, tools, etc. If you have dozens of sketches, or a even a single sketch that's used
saveFrame()to create 1000s of files, the I/O will be extremely slow. (Even worse if your machine doesn't have an SSD.)joelmoniz commentedon Jun 18, 2015
Ah, thank you. I'm almost done working on this, and should be able to file PR by tomorrow. Could you please clarify one small point for me? Does the sketchbook menu refer to File>Sketchbook, or to Sketch? I did some profiling, and the former does not seem to affect the start time at all, since the first time the sketchbook is actually walked searching for sketches is here, when the user actually clicks on the File>Sketchbook menu item. Tool, etc. do however, and I'll submit a PR that improves this.
benfry commentedon Jun 19, 2015
Sorry, I misspoke. It's for the methods that walk the sketchbook... These are for 1) getting the list of sketches (to put in the sketchbook window, in the past this was a menu, which is what I was referring to in the previous comment), 2) getting the modes, libraries, and tools. If you have a large sketchbook, or a lot of libraries installed, all or some of these can take a very long time to load.
If it's something that's needed immediately, that can't be done on a thread, but depending on the situation, this can happen in the background. The fix isn't terribly difficult, it just requires looking at the code very closely to make sure that we're doing it in the right place and taking all the scenarios into account.
joelmoniz commentedon Jun 19, 2015
Ah, thank you. As far as I could see, the walking is done just-in-time, when the user actually opens the Sketchbook window. I've profiled the code too, and though I had several large sketches (1+ GB each), this doesn't affect start time at all (the method call doesn't even show up on the profiler). I'll look into this a little more and make sure that this is indeed so.
There is one problem I'm facing, however. The maximum amount of time seems to be taken to load up Tools, for some reason. And though they aren't required immediately, and I'm able to offload their loading onto threads, updating the Tool menu sometimes tends to cause an error to be thrown, even though I've made it a point to ensure that all swing operations have been done on the EDT (a ClassCastException stating that the Windows LAF cannot be typecast to the Nimbus LAF). I did a little debugging, and the source of the error seems to be because the Movie Maker's init() method is not called from the EDT, even though it extends the JFrame class (as a result of which lots of operations in init() need to be specifically done on the EDT, I think). Could you please let me know if my line of reasoning is correct? If so, shall I submit a PR that fixes this first?
github-actions commentedon Jul 15, 2026
This issue has been automatically closed and locked.
Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.
If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at:
https://github.com/processing/processing4/issues/new/choose
Thank you for helping improve Processing.