-
Notifications
You must be signed in to change notification settings - Fork 665
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
[RESEARCH] Performance of Foam in large projects #1375
Comments
For now, I am doing some tests and research with https://github.com/github/docs. A relatively large project with many markdown files that I can use for research. |
Just came across https://github.com/rcvd/interconnected-markdown/tree/main/Markdown. This contains not only many notes, but also highly linked. Great for researching the performance of Foam |
Some initial investigation points to the function The function is defined as: public listByIdentifier(identifier: string): Resource[] {
const needle = normalize('/' + identifier);
const mdNeedle =
getExtension(needle) !== this.defaultExtension
? needle + this.defaultExtension
: undefined;
const resources: Resource[] = [];
for (const key of this._resources.keys()) {
if (key.endsWith(mdNeedle) || key.endsWith(needle)) {
resources.push(this._resources.get(normalize(key)));
}
}
return resources.sort(Resource.sortByPath);
} For my test repo the I will do some experiments with optimising the for loop in this area and see if that boosts performance. |
I am interested in this. I have a graph of aproximately 3k notes and 8k links. I also have some Python scripts I am using to make community detection over the graph. It results in around 50~100 or more communities. On the visualization, everything shows no problem. The problem arises if I want to explore only one community or a couple of them. The community of each note is saved at it's type so I can take out communities in the FOAM viz. If I only want to show one community of around 50 notes, it shows but then the physics break, the force directed approach can't handle it for some reason. If I try to select two communities, the moment I select the second one, the physics break and the links dissapear. I don't know what the reason might be but maybe the nodes not shown are still loaded and the physics engine tries to calculate anyways? whatever it is, the most types existing on the graph, the worse the performance gets. I've been thinking several solutions to this for some time and I've though a couple:
I can share some plots I've made but using python. Not that we should change the viz, but the physics engine of the plots I mention is less realistic and more aimed towards aesthetics not physical realism. I know that D3.js has a lot of options for visualization and that FOAM uses force-graph, which in turn uses D3, but I've never personally used it. Anyway I will gladly help to research this. |
I've been looking at the initial workspace loading time. At first sight, not much to be gained in this area. Most time is spent in reading the files from the datastore. Perhaps the parser could be made more efficient in the end, but don't see an opportunity here in short term. |
Second this. Long story short, it is so extremely terrible, I have no choice but to change to Dendron and see, if it works with that framework, at least. Whenever I want to write any document, the editor has too extreme lags. This extension makes it unusable. |
To make this "research" succeed, one has to strip the whole project from all advanced features. I would personally start with only letting it generate files from templates. Then, proceed with enabling single features inside the same huge repository of files and directories. Then, once a specific feature is added and performance starts to degrade, we know the culprit. Maybe it's also due to a set of features, as a whole. |
Nice, good timing. Yesterday, I was trying to figure out how to quickly build the extension locally with the most recent commits, but then my limited time ran out. I will check out the update today! |
I just used it in production and it is not unbearably slow anymore, it is only very slow now. Lot of lags still continue to bother the author, however, it is manageable to some degree. |
Could you elaborate which actions are slow? Would help me to look to dive into specifics. Is the project publicly available? Perhaps I can open it on my machine and do some research. |
Typing is super slow. Typing anything, anywhere in the project. It does not matter. My gut tells me, that it constantly scans all text for links/highlights or whatever feature needs to scan all text. I'm additionally 95% sure, that it gets worse with very large markdown files, again pointing at the scanning idea. That said, I just wish, there were a lot of feature flags. For me, the most important feature is to create notes from templates. So, I'd be already happy, when I could just strip down the extension to this basic feature, of allowing me to generate new notes from a template. With only this feature enabled, there shouldn't be any way to slow down anything, as it's only a one-shot feature, which never requires any kind of consistent or frequent document scanning. I would go as far as saying, that a stripped down extension like that could easily be published as a separate extension.
It's my private knowledge base. You would look into my brain, if you would see it. However, I'm pretty sure, if you continue to test with those huge projects you already had mentioned, you should be able to roughly replicate what I'm going through. Here is some further data, in case it helps.
If you have any further questions, that would help you fix this performance hell, I would be glad to be of assistance. |
Let me elaborate a tiny bit on what "slow" means. It's like packet loss. |
Thanks for the info. I'll use it to have a look at things later this week. To be honest, I am not sure that it is some continuous scanning process. Especially as Foam builds the graph on load and after that it uses file watchers to monitor changes. But, I might be missing something here. Just wanted to check if you see anything strange in CPU usage? For example, the symptoms mentioned in #1161. |
@theAkito I will take that as a win for now :) glad to hear that @pderaaij 's work made quite an improvement. But you are right that there is also some live parsing we do on the document itself, see Regarding your point on feature flags, I understand what you mean, but I am not planning to implement that just yet. Thanks for sharing your thoughts and pointing things out to us! |
Diving into the issue brought me to
This is not very performant in large workspaces and that causes the delay. It seems Will tinker about a solution here.. |
Small update report incoming. Keep going and please reduce more overhead in whatever the extension does! |
This sounds like what I initially expected to be the culprit. My initial debugging step was to disable all completion methods, as it seemed like it hung the most and the hardest, whenever it tried to give me a 100 useless suggestions, I neither needed nor wanted in that particular case. However, after disabling all auto-completions known to me, it did not help. Maybe this type of completion isn't even configurable via settings... |
Could you do a little check for me? Just open a fresh vscode session. After Foam is loaded, open a note and hover over a wikilink. I would expect this would show a tooltip quickly. |
One workaround for this would be to implement some type of cache, so it iterates only on certain occasions, which should be configurable via settings. |
Yes, although I would debate the term |
Thanks for testing. It helps me to validate my hypothesis. My current hypothesis is that the problem is the collection of resources in I want to see if we can improve this. |
I just used it in production twice, today. First, a document, which started at 79 lines and grew to 510 lines @ 20535 characters over 3 hours. Second, a document which grew from ~30 mostly empty lines to 82 lines @ 3068 characters. Both times, the lags were much worse, right from the beginning. At some point, I wanted to disable the Foam extension to work around the problem, as I needed quick response, however I did not manage to find the extension within the few seconds I had time to do it. I cannot explain, why the performance got worse. The only thing I can think of, is that, as far as I remember, Visual Studio Code was already on and idling for about 10 hours, before I started to write those documents. For next time, I can specifically make sure to restart Visual Studio Code, before using it in production, just to make sure. Maybe, I will find a way to test again soon, however I won't use it in production until next week, so the real life test will have to wait. The types of lags were very familiar. Pressing Enter and Backspace were especially lagging heavily. Sometimes, I typed a word like "word", but it typed it as "wrod" or something, because some characters are apparently delayed in such laggy situations. That said, I have only minimal word completion enabled. I can only tab-complete Markdown snippets. No completion for files or anything requiring to traverse through any hierarchy are enabled. |
Used it in production with a fresh Visual Studio Code instance, for only ~15 minutes. Performance seemed, as it was before this patch, however the timespan to test was too short, to give a clear view on the situation. |
After some fiddling, it feels the problem concerns around I am fiddling around a bit with the settings of _debounce. That helps in my test case, but I am not too certain about the mechanics of _debounce to understand if this makes sense. This is what I have:
I need to do some follow-up research, but perhaps @riccardoferretti has ideas or thoughts. |
Interestingly, I was able to recreate the lagging problems in the |
Describe the bug
Various users reported performance issues with large notes or projects with many notes. This issue serves as a collection of those reports. It acts as the documentation of ongoing research on performance.
Small Reproducible Example
No response
Steps to Reproduce the Bug or Issue
..
Expected behavior
We want to optimise the performance of Foam, even in large projects.
Screenshots or Videos
No response
Operating System Version
All OS
Visual Studio Code Version
Latest at least
Additional context
No response
The text was updated successfully, but these errors were encountered: