Skip to content

Commit

Permalink
Fix for issue esnet#1159 - allow write to file without fsync to impro…
Browse files Browse the repository at this point in the history
…ve performance
  • Loading branch information
davidBar-On committed Jun 9, 2021
1 parent 3b31c4b commit fe6167a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ struct iperf_test
int server_port;
int omit; /* duration of omit period (-O flag) */
int duration; /* total duration of test (-t flag) */
char *diskfile_name; /* -F option */
char *diskfile_name; /* -F option */
int no_fsync; /* --no_fsync option */
int affinity, server_affinity; /* -A option */
#if defined(HAVE_CPUSET_SETAFFINITY)
cpuset_t cpumask;
Expand Down
9 changes: 8 additions & 1 deletion src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
{"connect-timeout", required_argument, NULL, OPT_CONNECT_TIMEOUT},
{"idle-timeout", required_argument, NULL, OPT_IDLE_TIMEOUT},
{"rcv-timeout", required_argument, NULL, OPT_RCV_TIMEOUT},
{"no-fsync", no_argument, NULL, OPT_NO_FSYNC},
{"debug", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
Expand Down Expand Up @@ -1329,6 +1330,9 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
case 'F':
test->diskfile_name = optarg;
break;
case OPT_NO_FSYNC:
test->no_fsync = 1;
break;
case OPT_IDLE_TIMEOUT:
test->settings->idle_timeout = atoi(optarg);
if (test->settings->idle_timeout < 1 || test->settings->idle_timeout > MAX_TIME) {
Expand Down Expand Up @@ -2619,6 +2623,7 @@ iperf_defaults(struct iperf_test *testp)
testp->omit = OMIT;
testp->duration = DURATION;
testp->diskfile_name = (char*) 0;
testp->no_fsync = 0;
testp->affinity = -1;
testp->server_affinity = -1;
TAILQ_INIT(&testp->xbind_addrs);
Expand Down Expand Up @@ -4277,7 +4282,9 @@ diskfile_recv(struct iperf_stream *sp)
r = sp->rcv2(sp);
if (r > 0) {
(void) write(sp->diskfile_fd, sp->buffer, r);
(void) fsync(sp->diskfile_fd);
if (!sp->test->no_fsync) {
(void) fsync(sp->diskfile_fd);
}
}
return r;
}
Expand Down
1 change: 1 addition & 0 deletions src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef uint64_t iperf_size_t;
#define OPT_IDLE_TIMEOUT 25
#define OPT_DONT_FRAGMENT 26
#define OPT_RCV_TIMEOUT 27
#define OPT_NO_FSYNC 28

/* states */
#define TEST_START 1
Expand Down
2 changes: 2 additions & 0 deletions src/iperf_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
" -i, --interval # seconds between periodic throughput reports\n"
" -I, --pidfile file write PID file\n"
" -F, --file name xmit/recv the specified file\n"
" --no-fsync do not fsync output file after writing to it\n"
" (default is fsync after each write)\n"
#if defined(HAVE_CPU_AFFINITY)
" -A, --affinity n/n,m set CPU affinity\n"
#endif /* HAVE_CPU_AFFINITY */
Expand Down

0 comments on commit fe6167a

Please sign in to comment.