-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Project sidebar loading optimisation #686
Project sidebar loading optimisation #686
Conversation
…ss, optimised watcher assignment
In CodeEditModules/Modules/WorkspaceClient/src/Model/FileItem.swift, I have updated the |
for those interested, the number in this mock-up represents the file id of that file. When any of the folders are expanded, their child files will take the IDs of 20, 21, etc.
14 and 15 have a lower number than 16 despite being a layer lower because the watcher function relies on the order in which the FileItems are rendered in the OutlineView, and 13 was already expanded the last time I opened the workspace. These numbers are given out again when CodeEdit restarts, from top to bottom. |
I'm on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say that your solution to fix this issue impressed me. Watching only visible items is pretty clever! 🚀
Description
TL;DR, I optimised the project navigator code so that dispatch sources (AKA watchers, the thing that listens for changes within folders) are only applied to visible folders, greatly reducing the number of watchers that need to be created. This reduces the chance of bumping into the macOS file opening limit (eg. 2559 on my system).
More details: When a folder is compressed, the watcher still stays activated. This is to avoid repeatedly creating and cancelling watchers, using up a lot of RAM. In the (now rare) case that there are no more
open
calls left (meaning more than 2559 items have been opened), the icon goes fromfolder
orfolder.fill
toquestionmark.folder
to indicate that it is not being watched.startListeningToDirectory
image
property is accessed, meaning that the fileItem is being displayed in the sidebar.Related Issue
Checklist
Screenshots
example of a NextJS project (with node modules) successfully opened in CodeEdit, with enough
open
calls left to open a few tabs. Only the 13 folders visible here have watchers attached to them, making about 29 watchers in total (CodeEdit itself requires about 16 files open for miscellaneous purposes), well below the 2559 item file limit of my system.