-
Notifications
You must be signed in to change notification settings - Fork 654
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
[WIP] improve graph performance #1391
base: master
Are you sure you want to change the base?
Conversation
} | ||
} | ||
|
||
if (needle === '/page b.md') { |
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 need to remove this ;-)
This is amazing @pderaaij ! I am back from holidays (you know, italy + august = holiday) so will look a bit more into the PR this week |
Sharing some high level thoughts here. What do you think? Again, this was at a cursory look, I might be missing something |
Never really looked into the trie datastructure. Will do some research and fiddle around! |
I need a bit more time to figure out the right approach. Have been looking into tie data structures, but most implementation I found are immutable. A characteristic we don't want for our use case here. So, I need to find an implementation that does allow mutations. Did a quick checkout of https://rimbu.org, but couldn't find a right data structure off the bat for our use case. So, I require some more time to look around and find a solution. Ideas welcome of course. |
I got a long way tonight using https://yomguithereal.github.io/mnemonist/trie-map. Need to finish some things and get the last use cases working. Will do a new performance test when things are working. Hopefully I can finish it later this week. |
@riccardoferretti I've updated the implementation with my WIP so far. It has a little impact on performance. Compared to the earlier version, I now load the I have one remaining issue and I hope you can help. Originally, a Map holds the insertion order. TrieMap obviously does not do that. But, this means that If we can resolve this issue, all tests will be green so we can do some further testing and enhancing before shipping it. |
Based on some performance findings found #1375 I started to experiment with some improvements. I've noticed the function
listByIdentifier
being called alot by other functions. In this function, there is aforeach
loop running over all resources. A function which works fine for small notebooks, but large notebooks seems to be hit exponentionally.In this concept I've added a new state object that lists all resources for an identifier. In this case, I choose the identifier to be the file-name of the note. Using that identifier, I list all resource paths with that same identifier. Using this I can remove the
foreach
loop and just use the identifier to list a small set of resources.For the 10000 linked notes folder from this repo (https://github.com/rcvd/interconnected-markdown/tree/main/Markdown) this reduces the startup time to:
Using the current master the numbers are:
A delta of almost 25 seconds for loading the graph. Not only a performance improvement for loading the workspace, but also for some other operations that uses
listByIdentifier
directly or viafind
. This should make several UI components work better and more responsive.The downside is that it adds a new stateful object, but I don't see an other way to increase the performance of the foreach loop.
@riccardoferretti curious to your thoughts on this.