5 ms·
I also highly recommend plocate as an alternative to locate. It's much faster and accepts all the same flags as locate. https://plocate.sesse.net/ https://ploc
by cf 5y ago
I also highly recommend plocate as an alternative to locate. It's much faster and accepts all the same flags as locate.
https://plocate.sesse.net/ https://plocate.sesse.net/
- Blikkentrekker 5y agolocate is, for whatever reason, tragically slow. The database format it uses is nonsensical and completely optimized for size on very outdated assumptions. I use an implementation I have written in the shell itself whose database format is nothing more than every file path on the system separated by null bytes, that is simply grepped to find files; the speed difference is absurd. —— — time locate */meme.png /storage/home/user/pictures/macro/meme.png real 0m0.885s user 0m0.806s sys 0m0.010s —— — time greplocate /meme.png$ /storage/home/user/pictures/macro/meme.png real 0m0.089s user 0m0.079s sys 0m0.011s This implementation is highly naïve and simplistic, and offloads all the searching to GNU Grep, yet outperforms the actual `locate` command by an order of magnitude.
- tambourine_man 5y agoNice. I do something similar. Why null byte instead of new line?
- Asooka 5y agoPresumably to support filenames with newlines in them.
- tambourine_man 5y agoYeah but… gee
- Blikkentrekker 5y agoWhy take the risk? I'm fairly certain I have no files with newlines on my system but I see no reason to take the risk.
- gnubison 5y agoUnrelated, but can I ask about your prompt?
- Blikkentrekker 5y agoThey are simply em-dashes, if an error should occur, they are replaced with numbers to indicate the error code; they are also color-coded to indicate when I'm not for instance in an SSH session by changing to another color: —— — true —— — false —— 1 sh -c 'exit 120' 120 sh -c 'exit 20' — 20 It doesn't show the colors here of course.
- Sesse__ 5y agoAnd plocate is yet orders of magnitude faster than GNU grep. :-) And updates its database faster. You don't specify which locate you're using, but mlocate and BSD locate are basically obsolete by now. (Disclosure: I'm the author of plocate.)
- cf 5y agoI'm a huge fan and use your program basically daily. I don't know why it's not the default in most systems.
- Sesse__ 5y agoThank you! It's becoming the default now, slowly (e.g., it will be the default in Debian and Ubuntu from the next releases, and Fedora is in a process to make it replace mlocate right now). It's just a tad too new, only about a year since 1.0.0. :-)