Genivia / ugrep

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more
https://ugrep.com
BSD 3-Clause "New" or "Revised" License
2.59k stars 109 forks source link

Fairly slow in WSL #265

Closed rentruewang closed 1 year ago

rentruewang commented 1 year ago

I was using ugrep in wsl to grep yaml files from my github repositories, with the command ug -. -r 'pattern' and it took so long I killed it (and somehow slows down my laptop), whereas the same pattern in the silver searcher ag --hidden 'pattern' finished in 2 seconds.

My ugrep version : ugrep 3.12.1 x86_64-pc-linux-gnu +avx2 +pcre2jit +zlib +bzip2 +lzma +zstd I installed ugrep with ./build.sh --enable-pretty if that helps. Let me know if there's anything I could do to help debug this issue.

Thanks for reading.

genivia-inc commented 1 year ago

Strange report. Ugrep is tested extensively and compared to ag it runs a lot faster. There is not anything here that helps to point to a problem.

To pin down a potential problem:

Try option -P to use PCRE2 matching.

Then try -U to use non-Unicode matching.

Then try ugrep instead of ug.

These should not make much of a difference. If there is a difference, then something might be wrong with the installation.

genivia-inc commented 1 year ago

Also use option -I to skip binary files. Perhaps there are many large binary files on the search path?

rentruewang commented 1 year ago

@genivia-inc Thanks for the reply. Turned out that it was because ag automatically ignores .gitignore files, and ug has it on by default.

rentruewang commented 1 year ago

@genivia-inc I'm wondering, if I turned on --ignore-files in .ugrep, is there a way for me to undo this while using ug? For example, I may have --pretty and --ignore-files turned on, and I just wanted to disable --ignore-files.

genivia-inc commented 1 year ago

@genivia-inc I'm wondering, if I turned on --ignore-files in .ugrep, is there a way for me to undo this while using ug? For example, I may have --pretty and --ignore-files turned on, and I just wanted to disable --ignore-files.

Sure, you can use --no-ignore-files to turn it off.

Most options support --no- to disable. Which comes in handy when you enable options in a .ugrep file and sometimes you want to overrule them.

Or just use the ugrep command.

Or define a local .ugrep in the working directory where you often search. You can do this to generate it and remove the --ignore-files when defined in the .ugrep in your home directory:

ug --no-ignore-files --save-config
rentruewang commented 1 year ago

@genivia-inc Thanks for the reply! Does --no- work for all options? In that case, would you like to document it in the README? For example, --no-ignore-files I don't think is documented.

genivia-inc commented 1 year ago

I'll update the man page. It says this at the end of the long options list. I'll move it up.

rentruewang commented 1 year ago

Thanks!