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

Lazily Load Files #1438

Merged
merged 6 commits into from
Oct 5, 2023
Merged

Conversation

thecoolwinter
Copy link
Collaborator

@thecoolwinter thecoolwinter commented Oct 1, 2023

Description

This PR reworks CodeEdit's file loading system. Specifically:

  • Reworks the workspace file manager to lazily load and watch directories.
  • Removes the CEWorkspaceFile.children attribute.
  • Moves all file modification, and loading code to CEWorkspaceFileManager.

In more detail:

Reworks the workspace file manager to lazily load and watch directories.

CEWorkspaceFileManager no longer loads all files recursively when initialized via the loadFiles method. In fact, that method has been removed completely. Now, all files are loaded only when needed. See the class documentation for more info on usage and implementation. This has the effect of making CodeEdit usable from large directories (such as a build directory or a user's home directory).

Removes the CEWorkspaceFile.children attribute.

Because the workspace file manager manages loading files, this class could no longer maintain a list of children without heavy dependency on a file manager. Instead of dealing with messy dependency, this attribute was removed. It has been replaced by CEWorkspaceFileManager.childrenOfFile(_:) and CEWorkspaceFileManager.getFile(_:createIfNotFound:). The combination of these two methods allow clients to fetch cached children and optionally load files from disk.

Once files have been loaded into the file manager's cache, they will immediately begin causing file system update notifications. Before that, all notifications for unloaded directories are ignored.

Moves all file modification, and loading code to CEWorkspaceFileManager.

The methods for modifying, moving, copying, renaming, duplicating, etc. have been moved out of CEWorkspaceFile and into CEWorkspaceFileManager.

Misc fixes:

  • The ProjectNavigatorViewController.copyFile actually copies the file instead of just duplicating it.
  • DirectoryEventStream
    • Default debounce duration increased to 0.1s from 0.05s.
    • Events sent to listener in batch, reducing dispatches to main to one per event group.
  • CEWorkspaceFileManager listeners now receive information about what files were updated
  • Multiple broken docc links
  • Made quick open search use a Task to prevent duplicate searches happening at the same time.

Related Issues

TL;DR @EstebanBorai found that loading projects with large directories that were not visible in the editor caused CodeEdit to hang. Lazily loading files was decided on as the best option to fix this issue.

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

No UI changes

Performance

Source Build Time To Open Workspace Percent Change
Blender source Main 745.59 ms
Blender source Lazy Load 370.72 ms -50.2%
Linux source Main 4.24 s
Linux source Lazy Load 293 ms -93%
CodeEdit source Main 432.44 ms
CodeEdit source Lazy Load 296.42 ms -31.4%

0xWDG
0xWDG previously approved these changes Oct 2, 2023
Copy link
Collaborator

@0xWDG 0xWDG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 😊

Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work as always!

I am approving but I wonder if we should rename CEWorkspaceFile because it can either represent a file or folder. Naming it file may be confusing to some people.

@austincondiff austincondiff merged commit d1a712b into CodeEditApp:main Oct 5, 2023
@thecoolwinter thecoolwinter deleted the fix/file-lazy-load branch October 6, 2023 02:43
@thecoolwinter thecoolwinter added the enhancement New feature or request label Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants