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.57k stars 109 forks source link

Faster -ABC context matching #329

Closed genivia-inc closed 9 months ago

genivia-inc commented 9 months ago

The current benchmarks show that ugrep does not yet outpaces the performance of other grep for the -ABC context matching for practical cases such as -A1, -B1 and -C1 or any (practically reasonable) context size.

With a few minor changes to the code to avoid unnecessary scanning of the input, we can improve the performance of -ABC context matching considerably, as the following new results show for MacBook Pro Intel x64 and M1 machines. For these test runs, the performance of ugrep is improved by 3x to 4x compared to the previous ugrep v4.3 performance tests. This improvement will be included with the next ugrep release cycle.

Intel x64 with AVX2: results for large text file search with context

grepping Sherlock|Holmes elapsed real time (s)

search -A1 -B1 -C1 -winA1 -winB1 -winC1
ugrep 0.03 0.02 0.03 0.04 0.03 0.04
rg 0.03 0.03 0.03 0.09 0.09 0.09
ag 0.40 0.56 0.56 0.43 0.58 0.57
ggrep 0.13 0.13 0.14 0.30 0.30 0.31

arm64: results for large text file search with context

grepping Sherlock|Holmes elapsed real time (s)

search -A1 -B1 -C1 -winA1 -winB1 -winC1
ugrep 0.02 0.02 0.02 0.04 0.04 0.04
rg 0.03 0.03 0.03 0.23 0.23 0.23
ag 0.32 0.41 0.41 0.50 0.58 0.58
ggrep 0.09 0.09 0.09 0.23 0.24 0.23
genivia-inc commented 9 months ago

Implemented in release v4.3.5.