Re:look(1): lines beginning with given string
by mtdewcmu on Sunday December 13, 2015 @03:26AM
(#10725767)
You don't need to know the number of the line you're looking at. You jump to the middle of the file, and you compare the nearest line to the search pattern. Then you recurse on the top or bottom half.
[ Parent
| on HN ]
Re:look(1): lines beginning with given string
by userbinator on Sunday December 13, 2015 @12:23PM
(#10726980)
That still requires random seeking; it's not so bad on SSDs, but abysmal on rotating disks, and most of the filesystem and OS caching code is optimised for linear forward reads, so things like prefetching are not going to help at all.