From 133aa259230f293e59b8b013f9fd2ac8b1c03b05 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sun, 15 Apr 2012 06:01:44 +0200 Subject: Use O_DIRECT mode in seqreader --- seqreader.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'seqreader.c') diff --git a/seqreader.c b/seqreader.c index 68bcdca..f2128e2 100644 --- a/seqreader.c +++ b/seqreader.c @@ -11,8 +11,10 @@ #include #include -#define BUFSIZE 65536 -#define BLOCK_SIZE 16384 +#define FASTWRITER_SYNCIO_ALIGN 512 + +#define BUFSIZE 2097152 +#define BLOCK_SIZE 2097152 #define WRITE_INTERVAL 1 @@ -29,16 +31,18 @@ int main(int argc, char *argv[]) { size_t skip; size_t run; ssize_t res; - char buffer[BUFSIZE]; + char *buffer;//[BUFSIZE]; long double mcoef = 1000000. / (1024 * 1024); + posix_memalign((void**)&buffer, FASTWRITER_SYNCIO_ALIGN, BUFSIZE); + if (argc < 2) { printf("Usage: %s [skip]\n", argv[0]); exit(0); } if (strstr(argv[1], "/dev/")) { - int fd = open(argv[1], O_RDONLY|O_NOATIME|O_LARGEFILE/*|O_DIRECT*/, 0); + int fd = open(argv[1], O_RDONLY|O_NOATIME|O_LARGEFILE|O_DIRECT, 0); if (fd < 0) { printf("Unable to open device %s\n", argv[1]); exit(1); @@ -72,6 +76,8 @@ int main(int argc, char *argv[]) { exit(-1); } + free(buffer); + return 0; } @@ -124,5 +130,7 @@ int main(int argc, char *argv[]) { } closedir(dir); } + + free(buffer); } \ No newline at end of file -- cgit v1.2.3