diff options
author | dyson <dyson@FreeBSD.org> | 1996-12-11 05:20:20 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1996-12-11 05:20:20 +0000 |
commit | b0bde11dba2bf57872a396a171bd59442af1278d (patch) | |
tree | eb334771c581fe4a67133d8aca5c32c1f3708990 | |
parent | dc23aee2ccc589a3e23f82feb999ef55a2d28ce5 (diff) | |
download | FreeBSD-src-b0bde11dba2bf57872a396a171bd59442af1278d.zip FreeBSD-src-b0bde11dba2bf57872a396a171bd59442af1278d.tar.gz |
When mmap is used, do an madvise(MADV_SEQUENTIAL) to make things
go much more quickly when file input is really done. Of course, the
fully cached case will make no difference.
-rw-r--r-- | usr.bin/cmp/regular.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/usr.bin/cmp/regular.c b/usr.bin/cmp/regular.c index 35f62d1..76f2387 100644 --- a/usr.bin/cmp/regular.c +++ b/usr.bin/cmp/regular.c @@ -74,9 +74,12 @@ c_regular(fd1, file1, skip1, len1, fd2, file2, skip2, len2) if ((p1 = (u_char *)mmap(NULL, (size_t)length, PROT_READ, 0, fd1, skip1)) == (u_char *)-1) err(ERR_EXIT, "%s", file1); + + madvise(p1, length, MADV_SEQUENTIAL); if ((p2 = (u_char *)mmap(NULL, (size_t)length, PROT_READ, 0, fd2, skip2)) == (u_char *)-1) err(ERR_EXIT, "%s", file2); + madvise(p2, length, MADV_SEQUENTIAL); dfound = 0; for (byte = line = 1; length--; ++p1, ++p2, ++byte) { |