Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 378768 Details for
Bug 513044
app-benchmarks/piozone - Disk size is detected incorrectly and other issues
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
02-use-o_direct-to-reduce-cache.patch
02-use-o_direct-to-reduce-cache.patch (text/plain), 2.54 KB, created by
eroen
on 2014-06-12 21:34:05 UTC
(
hide
)
Description:
02-use-o_direct-to-reduce-cache.patch
Filename:
MIME Type:
Creator:
eroen
Created:
2014-06-12 21:34:05 UTC
Size:
2.54 KB
patch
obsolete
>Use O_DIRECT to reduce cache effects. > >From: eroen <eroen@occam.eroen.eu> > >Requires Linux 2.6 kernel and GNU userland. >--- > piozone.c | 33 ++++++++++++++++++++++++++++----- > 1 file changed, 28 insertions(+), 5 deletions(-) > >diff --git a/piozone.c b/piozone.c >index eaf32be..6f597b6 100644 >--- a/piozone.c >+++ b/piozone.c >@@ -12,7 +12,14 @@ > ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > */ > >+/* Compile with -D_GNU_SOURCE on compatible Linux systems to minimize */ >+/* OS caching effects by using O_DIRECT for I/O. See open(2). */ >+#ifndef _GNU_SOURCE >+#define _GNU_SOURCE >+#endif >+ > #include <stdio.h> >+#include <stdint.h> > #include <sys/types.h> > #include <unistd.h> > #include <string.h> >@@ -31,7 +38,14 @@ > #define MB ((uint64_t) 1000*KB) > #define GB ((uint64_t) 1000*MB) > >-static char iobuf[1*MiB]; >+#ifdef O_DIRECT >+#define ALIGNMENT 512 >+#else >+#define ALIGNMENT 1 >+#endif >+ >+static char iobuf[1*MiB + ALIGNMENT - 1]; >+static char *iobufalign; > static volatile stopf = 0; > static char *argv0 = "piozone"; > >@@ -75,12 +89,16 @@ bench_linear(int fd, > int count = 0; > int nr = 0; > >+ if(debug) >+ printf(" off: %llx\n", off); > lseek64(fd, off, SEEK_SET); > signal(SIGALRM, sigalrm_handler); > stopf = 0; > printf("Testing... "); >+ if(debug) >+ printf(" iobufalign: %llx, len: %llx\n", iobufalign, len); > alarm(ts); >- while (!stopf && (nr = read(fd, iobuf, len)) == len) >+ while (!stopf && (nr = read(fd, iobufalign, len)) == len) > { > print_dial(); > ++count; >@@ -124,7 +142,7 @@ bench_random(int fd, > alarm(ts); > while (!stopf && > lseek64(fd, off+((rand()&area)*MiB), SEEK_SET) != -1 && >- (nr = read(fd, iobuf, len)) == len) >+ (nr = read(fd, iobufalign, len)) == len) > { > print_dial(); > ++count; >@@ -154,7 +172,6 @@ bench_random(int fd, > uint64_t > disksize(int fd) > { >- char buf[8*KiB]; > uint64_t off, del; > > >@@ -164,7 +181,7 @@ disksize(int fd) > while (del > 8*KiB) > { > if (lseek64(fd, off+del, SEEK_SET) < 0 \ >- || read(fd, buf, 8*KiB) < 0) >+ || read(fd, iobufalign, 8*KiB) < 0) > del >>= 1; > else > off += del; >@@ -193,6 +210,8 @@ main(int argc, > int test_time = 30; /* seconds */ > int c; > >+ iobufalign = (char*)((intptr_t)iobuf + (ALIGNMENT - 1) \ >+ & ~(intptr_t)(ALIGNMENT - 1)); > > argv0 = argv[0]; > >@@ -233,7 +252,11 @@ main(int argc, > exit(1); > } > >+#ifdef O_DIRECT >+ fd = open(argv[optind], O_RDONLY|O_DIRECT); >+#else > fd = open(argv[optind], O_RDONLY); >+#endif > if (fd < 0) > { > fprintf(stderr, "%s: %s: open failed: %s\n",
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 513044
:
378748
| 378768 |
378770