4 ms·
Searching at several times memory bandwidth is definitely possible on reasonably modern hardware: http://www.codeproject.com/Articles/250566/Fastest-strstr-lik
by userbinator 10y ago
Searching at several times memory bandwidth is definitely possible on reasonably modern hardware:
http://www.codeproject.com/Articles/250566/Fastest-strstr-like-function-in-C http://www.codeproject.com/Articles/250566/Fastest-strstr-li...
The trick is that the CPU isn't actually reading all those bytes, as the longer the string is to be sought, the more bytes can be skipped over if the last character doesn't match.
I wouldn't call this "brute force" though - it's nowhere near as complex as indexing, but what I consider "brute force" is more like strcmp() in a loop.
- Everlag 10y agoThe fastest data to search through is always the data you ignore.
- zurn 10y agoYour needles (search terms) need to be quite long if you want to save on memory traffic: cache lines are 64-128 bytes and random access to standard DRAM is slower than sequential access. It can help if your data is in-cache though. (Or if you have an unusual system where memory is faster than what CPU can keep up with).
- qb45 10y agoThe high cost of random access to DRAM comes from jumping between rows (blocks of consecutive few -to- few tens of kB). If you read sequentially with gaps, you only have to open each row at most once. So it's like normal sequential reading, except that you may end up skipping few rows here and there and you may end up not transferring some parts of the rows you opened. So the time to completion can only be shorter, even if average throughput is lower.