-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathiozone.c
23031 lines (22195 loc) · 582 KB
/
iozone.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************/
/* Original Author: */
/* William Norcott ([email protected]) */
/* 4 Dunlap Drive */
/* Nashua, NH 03060 */
/* */
/************************************************************************/
/* Enhancements by: */
/* Don Capps ([email protected]) */
/* 7417 Crenshaw */
/* Plano, TX 75025 */
/* */
/************************************************************************/
/* Copyright 1991, 1992, 1994, 1998, 2000, 2001 William D. Norcott */
/************************************************************************/
/* */
/* Iozone is based on the original work done by William Norrcot. It has */
/* been enhanced so that it provides a more complete filesystem */
/* characterization. */
/* Its purpose is to provide automated filesystem characterization. */
/* Enhancements have been made by: */
/* */
/* Don Capps [email protected] */
/* */
/* Iozone can perform single stream and multi stream I/O */
/* also it now performs read, write, re-read, re-write, */
/* read backwards, read/write random, re-read record, */
/* pread, re-pread, re-pwrite, preadv, re-preadv, pwritev, */
/* stride read, and re-pwritev,mmap, POSIX async I/O, NFS */
/* cluster testing and much more. */
/* */
/* The frontend now uses getopt() and the user can control many more */
/* of the actions. */
/* */
/* */
/************************************************************************/
/************************************************************************/
/* For the beginner... */
/* */
/* 1. make linux (linux, hpux, convex, hpux_no_ansi) */
/* 2. type ./iozone -Ra */
/* */
/* Hint: Type make (it will give you a list of valid targets) */
/* */
/************************************************************************/
/* The version number */
#define THISVERSION " Version $Revision: 3.347 $"
#if defined(linux)
#define _GNU_SOURCE
#endif
/* Include for Cygnus development environment for Windows */
#if defined (Windows)
#include <Windows.h>
int errno;
#else
#if defined(linux)
#include <errno.h>
#else
extern int errno; /* imported for errors */
extern int h_errno; /* imported for errors */
#endif
#endif
#include <sys/types.h>
#include <sys/stat.h>
#if defined (__LP64__) || defined(OSF_64) || defined(__alpha__) || defined(__arch64__) || defined(_LP64) || defined(__s390x__) || defined(__AMD64__)
#define MODE "\tCompiled for 64 bit mode."
#define _64BIT_ARCH_
#else
#define MODE "\tCompiled for 32 bit mode."
#endif
#ifndef NO_THREADS
#include <pthread.h>
#endif
#if defined(HAVE_ANSIC_C) && defined(linux)
#include <stdlib.h>
#include <sys/wait.h>
#endif
#ifdef HAVE_PROTO
#include "proto.h"
#else
int atoi();
int close();
int unlink();
int main();
void record_command_line();
#if !defined(linux)
int wait();
#endif
int fsync();
void srand48();
long lrand48();
void create_list();
void Poll();
void print_header();
void Kill();
long long l_min();
long long l_max();
long long mythread_create();
int gen_new_buf();
void touch_dedup();
void init_by_array64(unsigned long long *, unsigned long long );
unsigned long long genrand64_int64(void);
#endif
#include <fcntl.h>
char *help[] = {
" Usage: iozone [-s filesize_Kb] [-r record_size_Kb] [-f [path]filename] [-h]",
" [-i test] [-E] [-p] [-a] [-A] [-z] [-Z] [-m] [-M] [-t children]",
" [-l min_number_procs] [-u max_number_procs] [-v] [-R] [-x] [-o]",
" [-d microseconds] [-F path1 path2...] [-V pattern] [-j stride]",
" [-T] [-C] [-B] [-D] [-G] [-I] [-H depth] [-k depth] [-U mount_point]",
" [-S cache_size] [-O] [-L cacheline_size] [-K] [-g maxfilesize_Kb]",
" [-n minfilesize_Kb] [-N] [-Q] [-P start_cpu] [-e] [-c] [-b Excel.xls]",
" [-J milliseconds] [-X write_telemetry_filename] [-w] [-W]",
" [-Y read_telemetry_filename] [-y minrecsize_Kb] [-q maxrecsize_Kb]",
" [-+u] [-+m cluster_filename] [-+d] [-+x multiplier] [-+p # ]",
" [-+r] [-+t] [-+X] [-+Z] [-+w percent dedupable] [-+y percent_interior_dedup]",
" [-+C percent_dedup_within]",
" ",
" -a Auto mode",
" -A Auto2 mode",
" -b Filename Create Excel worksheet file",
" -B Use mmap() files",
" -c Include close in the timing calculations",
" -C Show bytes transferred by each child in throughput testing",
" -d # Microsecond delay out of barrier",
" -D Use msync(MS_ASYNC) on mmap files",
" -e Include flush (fsync,fflush) in the timing calculations",
" -E Run extension tests",
" -f filename to use",
" -F filenames for each process/thread in throughput test",
" -g # Set maximum file size (in Kbytes) for auto mode (or #m or #g)",
" -G Use msync(MS_SYNC) on mmap files",
" -h help",
" -H # Use POSIX async I/O with # async operations",
" -i # Test to run (0=write/rewrite, 1=read/re-read, 2=random-read/write",
" 3=Read-backwards, 4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite",
" 7=fread/Re-fread, 8=random_mix, 9=pwrite/Re-pwrite, 10=pread/Re-pread",
" 11=pwritev/Re-pwritev, 12=preadv/Re-preadv)",
" -I Use VxFS VX_DIRECT, O_DIRECT,or O_DIRECTIO for all file operations",
" -j # Set stride of file accesses to (# * record size)",
" -J # milliseconds of compute cycle before each I/O operation",
" -k # Use POSIX async I/O (no bcopy) with # async operations",
" -K Create jitter in the access pattern for readers",
" -l # Lower limit on number of processes to run",
" -L # Set processor cache line size to value (in bytes)",
" -m Use multiple buffers",
" -M Report uname -a output",
" -n # Set minimum file size (in Kbytes) for auto mode (or #m or #g)",
" -N Report results in microseconds per operation",
" -o Writes are synch (O_SYNC)",
" -O Give results in ops/sec.",
" -p Purge on",
" -P # Bind processes/threads to processors, starting with this cpu",
" -q # Set maximum record size (in Kbytes) for auto mode (or #m or #g)",
" -Q Create offset/latency files",
" -r # record size in Kb",
" or -r #k .. size in Kb",
" or -r #m .. size in Mb",
" or -r #g .. size in Gb",
" -R Generate Excel report",
" -s # file size in Kb",
" or -s #k .. size in Kb",
" or -s #m .. size in Mb",
" or -s #g .. size in Gb",
" -S # Set processor cache size to value (in Kbytes)",
" -t # Number of threads or processes to use in throughput test",
" -T Use POSIX pthreads for throughput tests",
" -u # Upper limit on number of processes to run",
" -U Mount point to remount between tests",
" -v version information",
" -V # Verify data pattern write/read",
" -w Do not unlink temporary file",
" -W Lock file when reading or writing",
" -x Turn off stone-walling",
" -X filename Write telemetry file. Contains lines with (offset reclen compute_time) in ascii",
" -y # Set minimum record size (in Kbytes) for auto mode (or #m or #g)",
" -Y filename Read telemetry file. Contains lines with (offset reclen compute_time) in ascii",
" -z Used in conjunction with -a to test all possible record sizes",
" -Z Enable mixing of mmap I/O and file I/O",
" -+E Use existing non-Iozone file for read-only testing",
" -+K Sony special. Manual control of test 8.",
" -+m Cluster_filename Enable Cluster testing",
" -+d File I/O diagnostic mode. (To troubleshoot a broken file I/O subsystem)",
" -+u Enable CPU utilization output (Experimental)",
" -+x # Multiplier to use for incrementing file and record sizes",
" -+p # Percentage of mix to be reads",
" -+r Enable O_RSYNC|O_SYNC for all testing.",
" -+t Enable network performance test. Requires -+m ",
" -+n No retests selected.",
" -+k Use constant aggregate data set size.",
" -+q Delay in seconds between tests.",
" -+l Enable record locking mode.",
" -+L Enable record locking mode, with shared file.",
" -+B Sequential mixed workload.",
#if defined(O_DSYNC)
" -+D Enable O_DSYNC mode.",
#endif
#ifndef NO_MADVISE
" -+A # Enable madvise. 0 = normal, 1=random, 2=sequential",
" 3=dontneed, 4=willneed",
#endif
" -+N Do not truncate existing files on sequential writes.",
" -+S # Dedup-able data is limited to sharing within each numerically",
" identified file set",
" -+V Enable shared file. No locking.",
#if defined(Windows)
" -+U Windows Unbufferd I/O API (Very Experimental)",
#endif
" -+X Enable short circuit mode for filesystem testing ONLY",
" ALL Results are NOT valid in this mode.",
" -+Z Enable old data set compatibility mode. WARNING.. Published",
" hacks may invalidate these results and generate bogus, high",
" values for results.",
" -+w ## Percent of dedup-able data in buffers.",
" -+y ## Percent of dedup-able within & across files in buffers.",
" -+C ## Percent of dedup-able within & not across files in buffers.",
" -+H Hostname Hostname of the PIT server.",
" -+P Service Service of the PIT server.",
"" };
char *head1[] = {
" 'Iozone' Filesystem Benchmark Program",
" ",
THISVERSION,
MODE,
" ",
" Original Author: William Norcott ([email protected])",
" 4 Dunlap Drive",
" Nashua, NH 03060",
" ",
" Enhancements: Don Capps ([email protected])",
" 7417 Crenshaw",
" Plano, TX 75025",
" ",
" Copyright 1991, 1992, 1994, 1998, 1999, 2002 William D. Norcott",
" ",
" License to freely use and distribute this software is hereby granted ",
" by the author, subject to the condition that this copyright notice ",
" remains intact. The author retains the exclusive right to publish ",
" derivative works based on this work, including, but not limited to, ",
" revised versions of this work",
" ",
" Other contributors:",
" ",
" Don Capps (Network Appliance) [email protected]",
" ",
""};
/******************************************************************
INCLUDE FILES (system-dependent)
******************************************************************/
#include <sys/mman.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__DragonFly__)
#include <malloc.h>
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__DragonFly__)
#include <stdlib.h>
#include <string.h>
#endif
#if defined (__FreeBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__APPLE__) || defined(__DragonFly__)
#ifndef O_SYNC
#define O_SYNC O_FSYNC
#endif
#endif
#if defined (__FreeBSD__)
#ifndef O_RSYNC
#define O_RSYNC O_FSYNC
#endif
#endif
#if ((defined(solaris) && defined(__LP64__)) || defined(__s390x__))
/* If we are building for 64-bit Solaris, all functions that return pointers
* must be declared before they are used; otherwise the compiler will assume
* that they return ints and the top 32 bits of the pointer will be lost,
* causing segmentation faults. The following includes take care of this.
* It should be safe to add these for all other OSs too, but we're only
* doing it for Solaris now in case another OS turns out to be a special case.
*/
#include <strings.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#if ( defined(solaris) && defined(studio11) )
#include <strings.h>
#include <stdlib.h>
#endif
#if defined(OSFV5) || defined(linux)
#include <string.h>
#endif
#if defined(linux)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#ifndef MAP_FAILED
#define MAP_FAILED -1
#endif
#ifdef generic
typedef long long off64_t;
#endif
#if defined(__DragonFly__)
#define __off64_t_defined
typedef off_t off64_t;
#endif
#ifndef solaris
#ifndef off64_t
#ifndef _OFF64_T
#ifndef __AIX__
#ifndef __off64_t_defined
#ifndef SCO_Unixware_gcc
#ifndef UWIN
#ifndef __DragonFly__
//typedef long long off64_t;
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#ifdef __AIX__
#include <fcntl.h>
#endif
#ifdef VXFS
#include <sys/fs/vx_ioctl.h>
#endif
#ifdef unix
#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
#include <sys/time.h>
#endif
#include <sys/times.h>
#include <sys/file.h>
#include <sys/resource.h>
#ifndef NULL
#define NULL 0
#endif
#ifndef nolimits
#include <limits.h>
#endif
#endif
#ifdef HAVE_ANSIC_C
#define VOLATILE volatile
#else
#define VOLATILE
#endif
#include <sys/time.h>
#ifdef SHARED_MEM
#include <sys/shm.h>
#endif
#if defined(bsd4_2) && !defined(MS_SYNC)
#define MS_SYNC 0
#define MS_ASYNC 0
#endif
#if defined(bsd4_4) || defined(__DragonFly__)
#define MAP_ANONYMOUS MAP_ANON
#endif
#if defined(SCO_Unixware_gcc) || defined(solaris) || defined(UWIN) || defined(SCO)
#define MAP_FILE (0)
#endif
#if defined(IRIX) || defined(IRIX64) || defined(Windows) || defined(bsd4_2) || defined(bsd4_4) || defined(SCO) || defined(Solaris) || defined(SCO_Unixware_gcc)
long long page_size = 4096;
#define GOT_PAGESIZE 1
#elif defined(NBPG)
long long page_size = NBPG;
#define GOT_PAGESIZE 1
#elif defined(old_linux)
#include <asm/page.h>
long long page_size = PAGE_SIZE;
#define GOT_PAGESIZE 1
#elif !defined(GOT_PAGESIZE)
long long page_size = 4096; /* Used when all else fails */
#endif
#ifdef HAVE_PREAD
#ifdef HAVE_PREADV
#define PVECMAX 16
#ifdef _HPUX_SOURCE
#define PER_VECTOR_OFFSET
#include <sys/puio.h>
struct piovec piov[PVECMAX];
#else
#include <sys/uio.h>
struct iovec piov[PVECMAX];
#define piov_base iov_base
#define piov_len iov_len
#endif
#endif
#endif
#define DEDUPSEED 0x2719362
/*
* In multi thread/process throughput mode each child keeps track of
* statistics and communicates them through various flavors of
* shared memory, and via messages.
*/
struct child_stats {
long long flag; /* control space */
long long flag1; /* pad */
float walltime; /* child elapsed time */
float cputime; /* child CPU time */
float throughput; /* Throughput in either kb/sec or ops/sec */
float actual; /* Either actual kb read or # of ops performed */
} VOLATILE *child_stat;
/*
* Used for cpu time statistics.
*/
struct runtime {
float walltime;
float cputime;
float cpuutil;
};
#ifdef __convex_spp
#include <sys/cnx_ail.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
/*
* Messages the controlling process sends to children.
* Internal representation that is arch specific.
* This is used when using the network distributed mode.
*/
struct client_command {
char c_host_name[100];
char c_pit_hostname[40];
char c_pit_service[8];
char c_client_name[100];
char c_working_dir[200];
char c_file_name[200];
char c_path_dir[200];
char c_execute_name[200];
char c_write_traj_filename[200];
char c_read_traj_filename[200];
int c_oflag;
int c_mfflag;
int c_unbuffered;
int c_noretest;
int c_notruncate;
int c_read_sync;
int c_jflag;
int c_async_flag;
int c_k_flag;
int c_h_flag;
int c_mflag;
int c_pflag;
int c_stride_flag;
int c_verify;
int c_sverify;
int c_odsync;
int c_diag_v;
int c_dedup;
int c_dedup_interior;
int c_dedup_compress;
int c_dedup_mseed;
int c_Q_flag;
int c_L_flag;
int c_OPS_flag;
int c_mmapflag;
int c_mmapasflag;
int c_mmapnsflag;
int c_mmapssflag;
int c_no_copy_flag;
int c_include_close;
int c_include_flush;
int c_disrupt_flag;
int c_compute_flag;
int c_xflag;
int c_MS_flag;
int c_mmap_mix;
int c_Kplus_flag;
int c_stop_flag;
int c_w_traj_flag;
int c_r_traj_flag;
int c_direct_flag;
int c_cpuutilflag;
int c_seq_mix;
int c_client_number;
int c_command;
int c_testnum;
int c_no_unlink;
int c_no_write;
int c_file_lock;
int c_rec_lock;
int c_Kplus_readers;
int c_multiplier;
int c_share_file;
int c_pattern;
int c_version;
int c_base_time;
int c_num_child;
int c_pct_read;
int c_advise_op;
int c_advise_flag;
int c_restf;
long long c_stride;
long long c_rest_val;
long long c_delay;
long long c_purge;
long long c_fetchon;
long long c_numrecs64;
long long c_reclen;
long long c_child_flag;
long long c_delay_start;
long long c_depth;
float c_compute_time;
};
/*
* All data in this is in string format for portability in a
* hetrogeneous environment.
*
* Messages that the master will send to the clients
* over the socket. This provides neutral format
* so that heterogeneous clusters will work.
* This is used when using the network distributed mode.
* WARNING !!! This data structure MUST not be bigger
* than 1448 bytes or fragmentation will kick your butt.
*/
struct client_neutral_command {
char c_host_name[40];
char c_pit_hostname[40];
char c_pit_service[8];
char c_client_name[100];
char c_working_dir[100];
char c_file_name[100];
char c_path_dir[100];
char c_execute_name[100];
char c_write_traj_filename[100];
char c_read_traj_filename[100];
char c_oflag[2];
char c_mfflag[2];
char c_unbuffered[2];
char c_noretest[2];
char c_notruncate[2];
char c_read_sync[2];
char c_jflag[2];
char c_async_flag[2];
char c_k_flag[2];
char c_h_flag[2];
char c_mflag[2];
char c_pflag[2];
char c_stride_flag[2];
char c_verify[2];
char c_sverify[2];
char c_odsync[2];
char c_diag_v[2];
char c_dedup[4];
char c_dedup_interior[4];
char c_dedup_compress[4];
char c_dedup_mseed[4];
char c_Q_flag[2];
char c_L_flag[2];
char c_OPS_flag[2];
char c_mmapflag[2];
char c_mmapasflag[2];
char c_mmapnsflag[2];
char c_mmapssflag[2];
char c_no_copy_flag[2];
char c_include_close[2];
char c_include_flush[2];
char c_disrupt_flag[2];
char c_compute_flag[2];
char c_stop_flag[2];
char c_xflag[2];
char c_MS_flag[2];
char c_mmap_mix[2];
char c_Kplus_flag[2];
char c_w_traj_flag[2]; /* small int */
char c_r_traj_flag[2]; /* small int */
char c_direct_flag[2]; /* small int */
char c_cpuutilflag[2]; /* small int */
char c_seq_mix[2]; /* small int */
char c_stride[10]; /* small long long */
char c_rest_val[10]; /* small long long */
char c_purge[10]; /* very small long long */
char c_fetchon[10]; /* very small long long */
char c_multiplier[10]; /* small int */
char c_share_file[10]; /* small int */
char c_file_lock[10]; /* small int */
char c_rec_lock[10]; /* small int */
char c_Kplus_readers[10]; /* small int */
char c_client_number[20]; /* int */
char c_command[20]; /* int */
char c_testnum[20]; /* int */
char c_no_unlink[4]; /* int */
char c_no_write[4]; /* int */
char c_pattern[20]; /* int */
char c_version[20]; /* int */
char c_base_time[20]; /* int */
char c_num_child[20]; /* int */
char c_pct_read[6]; /* small int */
char c_advise_op[4]; /* small int */
char c_advise_flag[4]; /* small int */
char c_restf[4]; /* small int */
char c_depth[20]; /* small long long */
char c_child_flag[40]; /* small long long */
char c_delay[80]; /* long long */
char c_numrecs64[80]; /* long long */
char c_reclen[80]; /* long long */
char c_delay_start[80]; /* long long */
char c_compute_time[80]; /* float */
};
/*
* Messages the clients will send to the master.
* Internal representation on each client and the master.
* This is used when using the network distributed mode.
*/
struct master_command {
char m_host_name[100];
char m_client_name[100];
char m_stop_flag;
int m_client_number;
int m_client_error;
int m_child_port;
int m_child_async_port;
int m_command;
int m_testnum;
int m_version;
float m_throughput;
float m_cputime;
float m_walltime;
float m_actual;
long long m_child_flag;
};
/*
* Messages that the clients will send to the master
* over the socket. This provides neutral format
* so that heterogeneous clusters will work.
* This is used when using the network distributed mode.
*/
struct master_neutral_command {
char m_host_name[100];
char m_client_name[100];
char m_client_number[20]; /* int */
char m_client_error[20]; /* int */
char m_stop_flag[4]; /* char +space */
char m_child_port[20]; /* int */
char m_child_async_port[20]; /* int */
char m_command[20]; /* int */
char m_testnum[20]; /* int */
char m_version[20]; /* int */
char m_throughput[80]; /* float */
char m_cputime[80]; /* float */
char m_walltime[80]; /* float */
char m_actual[80]; /* float */
char m_child_flag[80]; /* long long */
};
/*
* Possible values for the commands sent to the master
*/
#define R_CHILD_JOIN 1
#define R_STAT_DATA 2
#define R_FLAG_DATA 3
/*
* Possible values for the master's commands sent to a client
*
* The R_FLAG_DATA is also used by the master to tell the
* client to update its flags.
*/
#define R_JOIN_ACK 4
#define R_STOP_FLAG 5
#define R_TERMINATE 6
#define R_DEATH 7
/* These are the defaults for the processor. They can be
* over written by the command line options.
*/
#define CACHE_LINE_SIZE 32
#define CACHE_SIZE ( 1024 * 1024 )
#define MEG (1024 * 1024)
/*
* For stride testing use a prime number to avoid stripe
* wrap hitting the same spindle.
*/
#define STRIDE 17
/************************************************************************/
/* */
/* DEFINED CONSTANTS */
/* */
/* Never add a comment to the end of a #define. Some compilers will */
/* choke and fail the compile. */
/************************************************************************/
/*
* Size of buffer for capturing the machine's name.
*/
#define IBUFSIZE 100
/*
* How many I/Os before a non-uniform access.
*/
#define DISRUPT 100
/*
* Set the crossover size. This is where the small transfers
* are skipped to save time. There is an option to
* disable the skipping.
*/
#define LARGE_REC 65536
/* Default number of kilobytes in file */
#define KILOBYTES 512
/* Default number of bytes in a record */
#define RECLEN 1024
/* Default size of file in bytes*/
#define FILESIZE (KILOBYTES*1024)
/* Default number of records */
#define NUMRECS FILESIZE/RECLEN
#ifdef __bsdi__
/* At 8 Meg switch to large records */
#define CROSSOVER (8*1024)
/*maximum buffer size*/
#define MAXBUFFERSIZE (8*1024*1024)
#else
/* At 16 Meg switch to large records */
#define CROSSOVER (16*1024)
/* Maximum buffer size*/
#define MAXBUFFERSIZE (16*1024*1024)
#endif
/* Maximum number of children. Threads/procs/clients */
#define MAXSTREAMS 256
/* Minimum buffer size */
#define MINBUFFERSIZE 128
/* If things ran way too fast */
#define TOOFAST 10
/* Set the maximum number of types of tests */
#define MAXTESTS 10
/* Default fill pattern for verification */
#define PATTERN get_pattern();
#define PATTERN1 0xBB
/* Used for Excel internal tables */
#define MAX_X 100
/* Used for Excel internal tables */
#define MAX_Y 512
#define USAGE "\tUsage: For usage information type iozone -h \n\n"
/* Maximum number of characters in filename */
#define MAXNAMESIZE 1000
/*
* Define the typical output that the user will see on their
* screen.
*/
#ifdef NO_PRINT_LLD
#ifdef HAVE_PREAD
#include <sys/times.h>
#if defined(HAVE_PREAD) && defined(HAVE_PREADV)
#define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld%9ld%10ld%10ld%9ld\n"
#define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s%10s%10s%9s%9s\n"
#define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
#else
#define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld\n"
#define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s\n"
#define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s\n"
#define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
#endif
#else
#define CONTROL_STRING1 "%16ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld\n"
#define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
#endif
#endif
#ifndef NO_PRINT_LLD
#ifdef HAVE_PREAD
#include <sys/times.h>
#if defined(HAVE_PREAD) && defined(HAVE_PREADV)
#define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld%9ld%10ld%10ld%9ld\n"
#define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s%10s%10s%9s%9s\n"
#define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
#else
#define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%9ld%9ld%8ld%10ld%9ld%10ld\n"
#define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s%8s%9s%7s%10s\n"
#define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
#endif
#else
#define CONTROL_STRING1 "%16lld%8ld%8ld%8ld%8ld%8ld%8ld%8ld %8ld %8ld%8ld%8ld%8ld%9ld%9ld\n"
#define CONTROL_STRING2 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING3 "%16s%8s%8s%8s%8s%10s%8s%8s%8s %8s %8s%9s%9s%8s%9s\n"
#define CONTROL_STRING4 "%16s%8s%8s%8s%8s%10s\n"
#endif
#endif
/*
For 'auto mode', these defines determine the number of iterations
to perform for both the file size and the record length.
*/
/* Start with 64 kbyte minimum file size by default */
#define KILOBYTES_START 64
/* Default maximum file size. This is 512 Mbytes */
#define KILOBYTES_END (1024*512)
/* Default starting record size */
#define RECLEN_START 4096
/* Default maximum record size */
#define RECLEN_END (MAXBUFFERSIZE)
/* Multiplier for each itteration on file and record size */
#define MULTIPLIER 2
/*
* Assign numeric values to each of the tests.
*/
#define WRITER_TEST 0
#define READER_TEST 1
#define RANDOM_RW_TEST 2
#define REVERSE_TEST 3
#define REWRITE_REC_TEST 4
#define STRIDE_READ_TEST 5
#define FWRITER_TEST 6
#define FREADER_TEST 7
#define RANDOM_MIX_TEST 8
#ifdef HAVE_PREAD
#define PWRITER_TEST 9
#define PREADER_TEST 10
#endif /* HAVE_PREAD */
#ifdef HAVE_PREADV
#define PWRITEV_TEST 11
#define PREADV_TEST 12
#endif /* HAVE_PREADV */
#define WRITER_MASK (1 << WRITER_TEST)
#define READER_MASK (1 << READER_TEST)
#define RANDOM_RW_MASK (1 << RANDOM_RW_TEST)
#define RANDOM_MIX_MASK (1 << RANDOM_MIX_TEST)
#define REVERSE_MASK (1 << REVERSE_TEST)
#define REWRITE_REC_MASK (1 << REWRITE_REC_TEST)
#define STRIDE_READ_MASK (1 << STRIDE_READ_TEST)
#define FWRITER_MASK (1 << FWRITER_TEST)
#define FREADER_MASK (1 << FREADER_TEST)
#ifdef HAVE_PREAD
#define PWRITER_MASK (1 << PWRITER_TEST)
#define PREADER_MASK (1 << PREADER_TEST)
#endif /* HAVE_PREAD */
#ifdef HAVE_PREADV
#define PWRITEV_MASK (1 << PWRITEV_TEST)
#define PREADV_MASK (1 << PREADV_TEST)
#endif /* HAVE_PREADV */
/*
* child_stat->flag values and transitions
*/
/* Parent initializes children to HOLD */
#define CHILD_STATE_HOLD 0
/* Child tells master when it's READY */
#define CHILD_STATE_READY 1
/* Parent tells child to BEGIN */
#define CHILD_STATE_BEGIN 2
/* Child tells parent that it's DONE */
#define CHILD_STATE_DONE 3
#define MERSENNE
/******************************************************************/
/* */
/* FUNCTION DECLARATIONS */
/* */
/******************************************************************/
char *initfile();
int pit_gettimeofday( struct timeval *, struct timezone *, char *, char *);
static int openSckt( const char *, const char *, unsigned int );
static void pit( int, struct timeval *);
void mmap_end();
void alloc_pbuf();
void auto_test(); /* perform automatic test series */
void show_help(); /* show development help */
static double time_so_far(); /* time since start of program */
#ifdef unix
static double utime_so_far(); /* user time */
static double stime_so_far(); /* system time */
static double clk_tck(); /* Get clocks/tick */
static double cputime_so_far();
#else
#define cputime_so_far() time_so_far()
#endif
static double time_so_far1(); /* time since start of program */
void get_resolution();
void get_rusage_resolution();
void signal_handler(); /* clean up if user interrupts us */
void begin(); /* The main worker in the app */
void fetchit(); /* Prime on chip cache */
void purgeit(); /* Purge on chip cache */
void throughput_test(); /* Multi process throughput */
void multi_throughput_test(); /* Multi process throughput */
void prepage(); /* Pre-fault user buffer */
void get_date();
int get_pattern(); /* Set pattern based on version */
#ifdef HAVE_ANSIC_C
float do_compute(float); /* compute cycle simulation */
#else
float do_compute(); /* compute cycle simulation */
#endif
void write_perf_test(); /* write/rewrite test */
void fwrite_perf_test(); /* fwrite/refwrite test */
void fread_perf_test(); /* fread/refread test */
void read_perf_test(); /* read/reread test */
void mix_perf_test(); /* read/reread test */
void random_perf_test(); /* random read/write test */
void reverse_perf_test(); /* reverse read test */
void rewriterec_perf_test(); /* rewrite record test */
void read_stride_perf_test(); /* read with stride test */
#ifdef HAVE_PREAD
void pread_perf_test(); /* pread/re-pread test */
void pwrite_perf_test(); /* pwrite/re-pwrite test */
#endif /* HAVE_PREAD */
#ifdef HAVE_PREADV
void preadv_perf_test(); /* preadv/re-preadv test */
void pwritev_perf_test(); /* pwritev/re-pwritev test */
#endif /* HAVE_PREADV */
void store_dvalue(); /* Store doubles array */
void dump_excel();
void dump_throughput();
int sp_start_child_send();
int sp_start_master_listen();
#ifdef HAVE_ANSIC_C
#if defined (HAVE_PREAD) && defined(_LARGEFILE64_SOURCE)
ssize_t pwrite64();
ssize_t pread64();
#endif
#if !defined(linux)
char *getenv();
char *inet_ntoa();
int system();
#endif
void my_nap();
int thread_exit();
#ifdef ASYNC_IO