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

CPU usage on file rename #286

Closed
harveyr opened this issue Feb 27, 2021 · 4 comments
Closed

CPU usage on file rename #286

harveyr opened this issue Feb 27, 2021 · 4 comments

Comments

@harveyr
Copy link

harveyr commented Feb 27, 2021

Hello!

The link-update process after a file rename is very CPU intensive. On my laptop, all 8 cores are ~100% consumed for 10 or 15 seconds. I have a little under 1700 files in my knowledge base, amounting to about 44,000 lines.

I won't pretend to know what the ideal solution is. As a workaround, I wrote a rename script that uses ripgrep to find all files that have references to the renamed file. This works more or less instantaneously. Here's the current state of that script, in case it's helpful: https://gist.github.com/harveyr/bac46beecd711ce374fa2829a0f4716b

Perhaps Memo could use more efficient search tools if they're available on the system? I'm actually pretty happy with my workaround, so I won't be offended if this isn't a priority.

Otherwise, I'm quite happy with Memo and I really appreciate your work on it! 👏

@svsool
Copy link
Owner

svsool commented Mar 11, 2021

Hi, @harveyr!

That's right, linear sequential scanning isn't that fast. Rigrep could be used to speed it up. Another approach is to use indexing with workers or LSP, but it would require a good part of Memo re-architectured. So far, it served me well without indexing complexity in place, so probably using something like rigrep would be more preferable.

I might take a look at some point but open to contributions as well.

@jowitte
Copy link

jowitte commented Oct 25, 2021

+1 I currently get "The extension 'Markdown Memo' took a very long time to complete its last operation and it has prevented other extensions from running." and some link updates are not performed. I really love Memo, but as I'm renaming a lot, changing my workflow to use a separate rename script is not really an option.

It would perhaps be an option to "steal" from https:/fabiospampinato/vscode-todo-plus, since they provide an option to use ag or rg to perform similar functionality. As I'm not the most advanced developer (to say the least) I would be super-happy to get this, since Markdown Memo is my weapon of choice no. 1 ;-)

@svsool
Copy link
Owner

svsool commented Jan 8, 2022

Hi 👋 , ripgrep (shipped with vscode binary) should be used in the latest version of Memo. Please update from Marketplace!

The difference on 2k files test workspace (1 file with ref to rename, the rest are mock files with some content and other refs) is roughly the following:

  • Before (it takes ~10 seconds on 2k files test workspace for rename pop-up to appear)

Rename on a big workspace before

  • After (rename pop-up appears more or less instantly)

Rename on a big workspace after

The more files containing the ref the slower renaming process will be, but files not containing the ref should be now filtered away by rigrep and rigrep performance seems much better for that size of workspace.

@svsool svsool closed this as completed Jan 8, 2022
@jowitte
Copy link

jowitte commented Jan 8, 2022

Awesome, thanks! Kudos...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants