l3kn / org-fc

Spaced Repetition System for Emacs org-mode
https://www.leonrische.me/fc/index.html
GNU General Public License v3.0
259 stars 31 forks source link

perf: switch conditionally to ripgrep or fd #78

Open ja0nz opened 2 years ago

ja0nz commented 2 years ago

resolves l3kn/org-fc#69

l3kn commented 1 year ago

Thanks for this!

At first I couldn't see the benefit because on my org-fc-directories (still containing thousands of files) the difference in runtime was so small. Trying it on my whole home directory, fd is much faster.

I think the greatest improvement is limiting the search to files actually containing flashcards. With the -exec flag of find, we might be able to avoid the extra xargs and I assume fd has something similar.

The commands will need some work though, so their results are exactly the same. (For example, the current rg command also finds org archive files).

I'll try to rewrite them and then do some end-to-end indexer benchmarks.

l3kn commented 1 year ago

After a lot of experimentation, these three commands seem to behave exactly the same regarding hidden files, hidden directories and upper/lower case '.org' extensions.

As expected, rg is significantly faster than find. I have benchmarked these on my home directory and the subdirectory I use for org files:

What's odd here is that fd is slower than find in one of the cases. -e org is made redundant by the latter glob pattern but it appears to reduce the runtime.

I think it's safe to assume that anyone who has installed fd would be fine installing rg as well, so until we can find a fd command that is faster than find in all cases, I'll only add rg as an alternative.