News for hackers. Stuff that matters.
Re:Do You Know How Much Your Computer Can Do in a Second? by roninkoi on Thursday June 22, 2023 @04:54PM (#36438832)
What surprised me the most is how fast grepping is. It can search more bytes from memory than iterations in a simple for loop?
Re:Do You Know How Much Your Computer Can Do in a Second? by taldo on Thursday June 22, 2023 @05:19PM (#36439162)
Probably a pretty bad test of the _actual_ speed of grep. A more realistic test would have printable characters and frequent newlines. I wouldn't be surprised if all those bytes were just taking a fast-path shortcut somewhere.
Re:Do You Know How Much Your Computer Can Do in a Second? by dan-robertson on Thursday June 22, 2023 @05:49PM (#36439552)
Grep is fast. Like obviously in this case you’re ‘just’ measuring how fast you can read from a pipe, but there are plenty of ways grep could have been implemented that would have been slower. Generally, I think grep will convert queries into a form that can be searched for reasonably efficiently (eg KMP for longer strings (bit of a guess – not sure how good it is on modern hardware), obviously no backtracking for regular expressions.
Re:Do You Know How Much Your Computer Can Do in a Second? by burntsushi on Thursday June 22, 2023 @06:14PM (#36439872)
I don't think KMP has been used in any practical substring implementation in ages. At least I'm not aware of one. I believe GNU grep uses Boyer-Moore, but that's not really the key here. The key is using memchr in BM's skip loop.
Re:Do You Know How Much Your Computer Can Do in a Second? by SnowflakeOnIce on Thursday June 22, 2023 @05:50PM (#36439562)
Depending on many factors (like details of the patterns used and the input), some regex engines (like Hyperscan) can match tens of gigabytes per second per core. Shockingly fast!
Re:Do You Know How Much Your Computer Can Do in a Second? by Night_Thastus on Thursday June 22, 2023 @05:49PM (#36439548)
Especially ripgrep! All hail ripgrep!

I will never go back to not using it.

Re:Do You Know How Much Your Computer Can Do in a Second? by burntsushi on Thursday June 22, 2023 @06:12PM (#36439844)
It provided the easiest possible case to grep: a simple literal. So all grep needs to do is substring search. And in turn it's accelerated by use of memchr. And that in turn it's written in assembly using AVX2 vector instructions, courtesy of GNU libc.
Re:Do You Know How Much Your Computer Can Do in a Second? by littlestymaar on Thursday June 22, 2023 @11:30PM (#36442458)
(For those unaware, burntsushi is the author of ripgrep)
Re:Do You Know How Much Your Computer Can Do in a Second? by xeonmc on Friday June 23, 2023 @02:28AM (#36443530)
source?
Re:Do You Know How Much Your Computer Can Do in a Second? by paraselene_ on Friday June 23, 2023 @03:15AM (#36443803)
Re:Do You Know How Much Your Computer Can Do in a Second? by slyall on Thursday June 22, 2023 @07:10PM (#36440490)
The loki logging software takes advantage of how fast grepping is. Instead of have a big index that lets you locate the exact line you are looking for it has a much small index of tags.

The tags ( something like env=prod, app=auth ) will narrow things down to say 1% of the data in the time period. The software then just greps though a few Gigabytes to find the exact lines you are after.

Re:Do You Know How Much Your Computer Can Do in a Second? by nathants on Thursday June 22, 2023 @07:22PM (#36440626)
grep is the beginning, not the end. it’s a great performance baseline to meet, and then beat[1]. computers are insanely fast!

the startups using grep on aws are undercutting those doing slower things on aws.

i wonder why aws architects never talk about grep.

1. https://github.com/nathants/bsv