From bf3a14a86682e4bf341eed4d6d7050ef57b1ccc2 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 2 Jul 2012 14:30:24 +0300 Subject: Dont use mmap() for anything, axe the code instead - Commit 4cb02aa928d3e41f636d0e01356c7a3cb51018ee asked to see what breaks when mmap() is used, now we know: large package support broke when enabling it. Could be fixed of course by eg adding a size cap to the fsm part as well, but just doesn't seem worth it: I fail to measure any meaningful performance improvement from mmap usage in either case, and added complexity for what is close to zero benefit just doesn't make sense... and various sources in fact note the rpm usage (read through the entire file sequentially) as one of the cases where mmap() is NOT beneficial due to mmap() high setup + teardown cost + page fault speed (or lack of thereof). --- rpmio/rpmfileutil.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'rpmio') diff --git a/rpmio/rpmfileutil.c b/rpmio/rpmfileutil.c index bb84bc1ee..6cdfe2552 100644 --- a/rpmio/rpmfileutil.c +++ b/rpmio/rpmfileutil.c @@ -13,10 +13,6 @@ #endif -#if defined(HAVE_MMAP) -#include -#endif - #include #include #include @@ -154,43 +150,9 @@ int rpmDoDigest(int algo, const char * fn,int asAscii, goto exit; } - /* file to large (32 MB), do not mmap file */ - if (fsize > (size_t) 32*1024*1024) - if (ut == URL_IS_PATH || ut == URL_IS_UNKNOWN) - ut = URL_IS_DASH; /* force fd io */ - switch(ut) { case URL_IS_PATH: case URL_IS_UNKNOWN: -#ifdef HAVE_MMAP - if (pid == 0) { - int xx; - DIGEST_CTX ctx; - void * mapped; - - if (fsize) { - mapped = mmap(NULL, fsize, PROT_READ, MAP_SHARED, fdno, 0); - if (mapped == MAP_FAILED) { - xx = close(fdno); - rc = 1; - break; - } - -#ifdef MADV_SEQUENTIAL - xx = madvise(mapped, fsize, MADV_SEQUENTIAL); -#endif - } - - ctx = rpmDigestInit(algo, RPMDIGEST_NONE); - if (fsize) - xx = rpmDigestUpdate(ctx, mapped, fsize); - xx = rpmDigestFinal(ctx, (void **)&dig, &diglen, asAscii); - if (fsize) - xx = munmap(mapped, fsize); - xx = close(fdno); - break; - } -#endif case URL_IS_HTTPS: case URL_IS_HTTP: case URL_IS_FTP: -- cgit v1.2.3