diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2012-11-29 02:45:06 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2012-11-29 02:45:06 +0100 |
commit | 5df9c1947bd102309ee93c6354dcad1352218e7b (patch) | |
tree | 307bd94387cf2ee27eec9399ddda77f581e6a945 | |
parent | 40330dd43d9fccac396e61ec0fb5df32b6530b57 (diff) | |
download | fwbench-5df9c1947bd102309ee93c6354dcad1352218e7b.tar.gz fwbench-5df9c1947bd102309ee93c6354dcad1352218e7b.tar.bz2 fwbench-5df9c1947bd102309ee93c6354dcad1352218e7b.tar.xz fwbench-5df9c1947bd102309ee93c6354dcad1352218e7b.zip |
Better directory mode in seqreader
-rw-r--r--[-rwxr-xr-x] | fsbench.sh | 0 | ||||
-rw-r--r-- | seqreader.c | 77 |
2 files changed, 55 insertions, 22 deletions
diff --git a/fsbench.sh b/fsbench.sh index a76126b..a76126b 100755..100644 --- a/fsbench.sh +++ b/fsbench.sh diff --git a/seqreader.c b/seqreader.c index ba4db51..55a7370 100644 --- a/seqreader.c +++ b/seqreader.c @@ -18,6 +18,7 @@ #define SYNC_MODE #define AIO_MODE 2 +//#define FS_SYNC_MODE #define EXTRA_BUFFERS 2 #define WRITE_INTERVAL 1 @@ -38,7 +39,7 @@ #ifdef AIO_MODE # define BUFSIZE (BLOCK_SIZE * (AIO_MODE + EXTRA_BUFFERS)) #else /* AIO_MODE */ -# define BUFSIZE BLOCK_SIZE +# define BUFSIZE (1024 * RAID_STRIP_SIZE * RAID_DISKS) #endif /* AIO_MODE */ @@ -47,7 +48,7 @@ int main(int argc, char *argv[]) { size_t SKIP = 1; DIR *dir; struct dirent *ent; - struct timeval start, tv; + struct timeval start, fstart, tv; size_t us; size_t files = 0; size_t total_size = 0; @@ -58,7 +59,7 @@ int main(int argc, char *argv[]) { size_t ready; ssize_t res; size_t max_size = (size_t)-1; - char *buffer;//[BUFSIZE]; + char *buffer; long double mcoef = 1000000. / (1024 * 1024); int flags = O_RDONLY|O_NOATIME|O_LARGEFILE; @@ -74,11 +75,6 @@ int main(int argc, char *argv[]) { struct io_event ev[AIO_MODE]; #endif /* AIO_MODE */ -#ifdef SYNC_MODE - flags |= O_DIRECT; -#endif - - printf("Used buffer: %i MB, Block: %i KB\n", BUFSIZE / 1024 / 1024, BLOCK_SIZE/1024); posix_memalign((void**)&buffer, FASTWRITER_SYNCIO_ALIGN, BUFSIZE); @@ -93,6 +89,13 @@ int main(int argc, char *argv[]) { max_size *= 1024 * 1024 * 1024; } +#ifdef SYNC_MODE + flags |= O_DIRECT; +#endif + + printf("Used buffer: %i MB, Block: %i KB\n", BUFSIZE / 1024 / 1024, BLOCK_SIZE/1024); + + int fd = open(argv[1], flags, 0); if (fd < 0) { printf("Unable to open device %s\n", argv[1]); @@ -219,6 +222,10 @@ int main(int argc, char *argv[]) { return 0; } +#ifdef FS_SYNC_MODE + flags |= O_DIRECT; +#endif /* FS_SYNC_MODE */ + chdir(argv[1]); if (argc > 2) { @@ -239,38 +246,55 @@ int main(int argc, char *argv[]) { if (stat(ent->d_name, &st)) continue; if (!S_ISREG(st.st_mode)) continue; + int size = st.st_blksize; + #ifdef F_MODE FILE *f = fopen(ent->d_name, "r"); if (!f) continue; #else int fd = open(ent->d_name, flags, 0); if (fd < 0) continue; + +# ifdef FS_SYNC_MODE + if (size < BLOCK_SIZE) size = BLOCK_SIZE; +# endif /* FS_SYNC_MODE */ #endif - - int size = st.st_blksize; + + if (!files) + printf("Reading %s, Block: %i KB\n", ent->d_name, size / 1024); if (size > BUFSIZE) { printf("Buffer too small\n"); exit(1); } + size_t last_file_write = 0; + size_t last_file_size = 0; + size_t file_size = 0; + gettimeofday(&fstart, NULL); #ifdef F_MODE while (!feof(f)) { - err = fread(buffer, 1, size, f); - if (err < 0) break; - } + ssize_t ret = fread(buffer, 1, size, f); #else -# ifdef SYNC_MODE - if (size < BLOCK_SIZE) size = BLOCK_SIZE; -# endif - err = read(fd, buffer, size); - while (err > 0) { - err = read(fd, buffer, size); - } + while (1) { + ssize_t ret = read(fd, buffer, size); #endif + if (ret <= 0) break; + + file_size += ret; - if (err < 0) { + gettimeofday(&tv, NULL); + us = (tv.tv_sec - fstart.tv_sec) * 1000000 + (tv.tv_usec - fstart.tv_usec); + + if ((us - last_file_write) > WRITE_INTERVAL * 1000000) { + printf("Reading: %s (%lu GB), Measured speed: %zu MB/s, Current speed: %zu MB/s\n", ent->d_name, file_size / 1024 / 1024 / 1024, (size_t)(mcoef * file_size / us), (size_t)(mcoef * (file_size - last_file_size) / (us - last_file_write))); + last_file_write = us; + last_file_size = file_size; + } + } + + if (!file_size) { printf("Read failed\n"); exit(1); } @@ -286,9 +310,18 @@ int main(int argc, char *argv[]) { gettimeofday(&tv, NULL); us = (tv.tv_sec - start.tv_sec) * 1000000 + (tv.tv_usec - start.tv_usec); - printf("Reading: %s (%lu MB), Read: %lu files (%lu GB), Measured speed: %zu MB/s\n", ent->d_name, st.st_size/1024/1024, files, total_size / 1024 / 1024 / 1024, (size_t)(mcoef * total_size / us)); + if ((us - last_write) > WRITE_INTERVAL * 1000000) { + last_write = us; + printf("Read: %lu files (%lu GB) at %zu MB/s", files, total_size / 1024 / 1024 / 1024, (size_t)(mcoef * total_size / us)); + + us = (tv.tv_sec - fstart.tv_sec) * 1000000 + (tv.tv_usec - fstart.tv_usec); + printf(", Last: %s (%lu MB) at %zu MB/s\n", ent->d_name, st.st_size/1024/1024, (size_t)(mcoef * file_size / us)); + } } closedir(dir); + + us = (tv.tv_sec - start.tv_sec) * 1000000 + (tv.tv_usec - start.tv_usec); + printf("Total: %lu files (%lu GB) at %zu MB/s\n", files, total_size / 1024 / 1024 / 1024, (size_t)(mcoef * total_size / us)); } free(buffer); |