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

Lazy path cache #90

Merged
merged 7 commits into from
Jan 19, 2024
Merged

Lazy path cache #90

merged 7 commits into from
Jan 19, 2024

Conversation

white-axe
Copy link
Collaborator

Description
This changes the path cache to only cache paths when they are accessed instead of performing a full recursive directory search as soon as a project is loaded.

Making the path cache lazy in this way is beneficial mostly to web builds but also just to people with really slow storage, because it prevents the path cache from recursively searching directories that are never used, such as the .git directory in projects that use Git for version control, or the Audio directory if the sound test window is never used. This also prevents errors if the user doesn't have permission to access some of the files in the project directory that aren't used by Luminol.

The project loading should be significantly faster in Firefox in #88 when combined with this pull request and should also be a little faster in Chromium.

The lazy path cache is implemented by, whenever the user wants to access a path, first finding the longest path in the cache that is a prefix of the desired path and then searching the filesystem for and caching the missing suffix if applicable. Since the hash table previously used by the path cache doesn't efficiently support this longest common prefix operation, I've replaced the hash table with a trie. The trie doesn't use hashing at all, so it should also be faster than the hash table.

Testing
Try loading and editing a bunch of projects as a general stress test of this new path cache and make sure there are no errors that weren't there before. You can check the Filesystem Debug window under the Debug menu in the top bar to make sure that the caching is actually lazy.

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo build --release
  • If applicable, run trunk build --release

@white-axe white-axe added the enhancement New feature or request label Jan 17, 2024
@white-axe white-axe requested a review from a team as a code owner January 17, 2024 03:45
@white-axe white-axe merged commit 437d5c8 into Astrabit-ST:dev Jan 19, 2024
5 checks passed
@white-axe white-axe deleted the lazy-path-cache branch January 19, 2024 22:51
@white-axe white-axe added performance and removed enhancement New feature or request labels Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants