[Performance] Reduce filesystem operations in FSAL provider#6072
Merged
Conversation
* the store quickly can get out of sync with the actual * available files
* this allows us to re-use the list of all descriptors * while still keeping the most up-to-date list. This avoids * the performance impact of constantly calling * `getAllLoadedDescriptors` in the FSA `findExact` method
Member
|
Ahh, totally forgot to comment! I had a look and from the outset it looks like a bunch of decent improvements! I'll merge this as soon as 4.0 is out; with your other PRs and a few things I have on my mind we'll be able to get out a 4.0.1 quickly after, and catch a few bugs we've overlooked for 4.0 too. |
Collaborator
Author
|
sounds great. merry xmas eve to you, as well! |
* we can access the descriptor's extension, * so just test whether the query + ext is equal * to the filename
Member
|
Oh, yes, Merry Christmas! 🙈 |
nathanlesage
requested changes
Dec 26, 2025
nathanlesage
left a comment
Member
There was a problem hiding this comment.
Looks good, just one small refactor, but I appreciate the much lower disk accesses here.
Member
|
Looks good! Merci beaucoup! |
benniekiss
added a commit
to benniekiss/Zettlr
that referenced
this pull request
Dec 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR reduces several file system operations in the FSAL layer to improve performance
Improves and possibly closes #6057 and #6018
Changes
The descriptors load in thereindexFilesmethod are now cached in a_loadedDescriptorsattribute. This dramatically improves performance of thefindExactmethod, which re-computes descriptors for all loaded files on each call. Currently, thefindExactmethod is the only place where_loadedDescriptorsis used. This was causing performance issues when a file had several zkn links, and hundreds of files were opened in Zettlr.So I found that the
reindexFilesmethod does not get called often enough, so when files are added or removed,_loadedDescriptorswill quickly become out-of-sync with the actual list of available files. Instead, I re-implemented thefindExactlogic within the link provider. By still callinggetAllLoadedDescriptors, the list of available descriptors is up to date, and it can be reused across function calls, greatly reducing the performance impact.Several calls to
pathExists,isFile, andisDirwere removed because lower level functions already handled the check. Instead, they were replaced withtry...catchblocks. This also improves performance. In my ~500 file workspace, FSAL indexing currently takes about 450ms, but with this patch, it is about 250ms to reindex.Additional information
I believe_loadedDescriptorscould replacegetAllLoadedDescriptorsentirely, but I wasn't certain.I tested this in a folder of about 500 files, and I did not notice an increase in RAM usage.Tested on: macOS 26