2 * Copyright 2012 GRNET S.A. All rights reserved.
4 * Redistribution and use in source and binary forms, with or
5 * without modification, are permitted provided that the following
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
29 * The views and conclusions contained in the software and
30 * documentation are those of the authors and should not be
31 * interpreted as representing official policies, either expressed
32 * or implied, of GRNET S.A.
35 #include <bench-lfsr.h>
37 #define MAX_ARG_LEN 10
40 #define TM_ECCENTRIC 1
45 * Pattern type occupies first flag bit.
46 * If 1, it's synchronous, if 0, it's random.
48 #define PATTERN_FLAG 0
49 #define IO_SEQ 0 << PATTERN_FLAG
50 #define IO_RAND 1 << PATTERN_FLAG
53 * Verify mode occupies second flag bit.
54 * If 1, it uses metadata for verification, if 0, it's off.
57 #define VERIFY_NO 0 << VERIFY_FLAG
58 #define VERIFY_META 1 << VERIFY_FLAG
61 * The benchark ID (IDLEN) is global for the test, calculated once and is a
62 * string of the following form: {"bench-" + 9-digit number + "\0"}.
63 * The target string (TARGETLEN) is per object, concatenated with the string
64 * above and is of the following form: {"-" +16-digit number + "\0"}.
67 #define TARGETLEN (IDLEN + 17)
68 extern char global_id[IDLEN];
71 uint64_t to; //Total number of objects (not for read/write)
72 uint64_t ts; //Total I/O size
73 uint64_t os; //Object size
74 uint64_t bs; //Block size
75 uint64_t max_requests; //Max number of requests for a benchmark
76 uint32_t iodepth; //Num of in-flight xseg reqs
80 uint32_t op; //xseg operation
83 struct bench_lfsr *lfsr;
84 struct timer *total_tm; //Total time for benchmark
85 struct timer *get_tm; //Time for xseg_get_request
86 struct timer *sub_tm; //Time for xseg_submit_request
87 struct timer *rec_tm; //Time for xseg_receive_request
91 * Custom timespec. Made to calculate variance, where we need the square of a
92 * timespec struct. This struct should be more than enough to hold the square
93 * of the biggest timespec.
96 unsigned long tv_sec2;
101 * struct timer fields
102 * ====================
103 * completed: number of completed requests
104 * start_time: submission time of a request
105 * sum: the sum of elapsed times of every completed request
106 * sum_sq: the sum of the squares of elapsed times
107 * insanity: benchmarking level, higher means that the request associated with
108 * this timer is more trivial.
112 struct timespec2 sum_sq;
113 struct timespec start_time;
127 char obj_name[TARGETLEN];
131 //hash of data (heavy)
135 int custom_peerd_loop(void *arg);
137 void timer_start(struct bench *prefs, struct timer *sample_req);
138 void timer_stop(struct bench *prefs, struct timer *sample_tm,
139 struct timespec *start);
140 int init_timer(struct timer **tm, int insanity);
141 uint64_t str2num(char *str);
142 int read_op(char *op);
143 int read_pattern(char *pattern);
144 int read_insanity(char *insanity);
145 int read_verify(char *insanity);
146 void print_res(struct bench *prefs, struct timer *tm, char *type);
147 void print_stats(struct bench *prefs);
148 void create_target(struct bench *prefs, struct xseg_request *req,
150 void create_chunk(struct bench *prefs, struct xseg_request *req,
152 uint64_t determine_next(struct bench *prefs);
153 void create_id(unsigned long seed);