News for hackers. Stuff that matters.
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.
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.
Re:look(1): lines beginning with given string by mtdewcmu on Sunday December 13, 2015 @02:07PM (#10727420)
At some point the cost of scanning a long file will overcome the cost of doing log(n) seeks. On short files, it really doesn't matter what you do, searching will be fast regardless.