Bad file access on the rise
Steve Grubb
sgrubb at redhat.com
Sat Jun 8 13:53:39 UTC 2013
On Saturday, June 08, 2013 09:34:22 AM Steve Grubb wrote:
> Does opening with noatime really make a measurable difference (assuming it
> worked)? I suspect not since what we have now is 2 syscalls. It would
> probably be faster to load icons without trying to set NOATIME.
Answering my own question....
#include <stdio.h>
#define __USE_GNU
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
void noatime(void)
{
int fd = open("/usr/share/icons/hicolor/48x48/apps/firefox.png", O_RDONLY|O_NOATIME);
if (fd>=0)
close(fd);
else {
fd = open("/usr/share/icons/hicolor/48x48/apps/firefox.png", O_RDONLY);
if (fd>=0)
close(fd);
}
}
void atime(void)
{
int fd = open("/usr/share/icons/hicolor/48x48/apps/firefox.png", O_RDONLY);
if (fd>=0)
close(fd);
}
int main(int argc, char *argv[])
{
int i, mode=0;
if (argc == 2 && strcmp("noatime", argv[1]) == 0)
mode = 1;
for (i=0; i<5000; i++) {
if (mode)
noatime();
else
atime();
}
return 0;
}
As a normal user:
$ time ./test noatime
real 0m12.645s
user 0m0.003s
sys 0m0.159s
$ time ./test atime
real 0m0.019s
user 0m0.002s
sys 0m0.016s
Way faster doing a normal open. As root:
# time ./test noatime
real 0m0.019s
user 0m0.000s
sys 0m0.019s
# time ./test atime
real 0m0.019s
user 0m0.001s
sys 0m0.017s
No real difference between them.
-Steve
More information about the devel
mailing list