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 #define MAX_ARG_LEN 10
38 #define TM_ECCENTRIC 1
43 * Pattern type occupies first flag bit.
44 * If 1, it's synchronous, if 0, it's random.
46 #define PATTERN_FLAG 0
47 #define IO_SEQ 0 << PATTERN_FLAG
48 #define IO_RAND 1 << PATTERN_FLAG
51 * FIXME: The following are variables and definitions used to name objects and
52 * seed the lfsr. They can be handled more elegantly (e.g. be a member of a
56 #define TARGETLEN (IDLEN + 17)
57 extern char global_id[IDLEN];
58 extern uint64_t global_seed;
61 uint64_t to; //Total number of objects (not for read/write)
62 uint64_t ts; //Total I/O size
63 uint64_t os; //Object size
64 uint64_t bs; //Block size
65 uint64_t max_requests; //Max number of requests for a benchmark
66 uint32_t iodepth; //Num of in-flight xseg reqs
70 uint32_t op; //xseg operation
74 struct timer *total_tm; //Total time for benchmark
75 struct timer *get_tm; //Time for xseg_get_request
76 struct timer *sub_tm; //Time for xseg_submit_request
77 struct timer *rec_tm; //Time for xseg_receive_request
81 * Custom timespec. Made to calculate variance, where we need the square of a
82 * timespec struct. This struct should be more than enough to hold the square
83 * of the biggest timespec.
86 unsigned long tv_sec2;
92 * ====================
93 * completed: number of completed requests
94 * start_time: submission time of a request
95 * sum: the sum of elapsed times of every completed request
96 * sum_sq: the sum of the squares of elapsed times
97 * insanity: benchmarking level, higher means that the request associated with
98 * this timer is more trivial.
102 struct timespec2 sum_sq;
103 struct timespec start_time;
105 unsigned int insanity;
119 //hash of data (heavy)
124 int custom_peerd_loop(void *arg);
126 void timer_start(struct bench *prefs, struct timer *sample_req);
127 void timer_stop(struct bench *prefs, struct timer *sample_tm,
128 struct timespec *start);
129 int init_timer(struct timer **tm, int insanity);
130 uint64_t str2num(char *str);
131 int read_op(char *op);
132 int read_pattern(char *pattern);
133 void print_res(struct tm_result res, char *type);
134 void separate_by_order(struct timespec src, struct tm_result *res);
135 void create_target(struct bench *prefs, struct xseg_request *req,
137 void create_chunk(struct bench *prefs, struct xseg_request *req,
139 uint64_t determine_next(struct bench *prefs);
141 int read_insanity(char *insanity);
154 int lfsr_init(struct lfsr *lfsr, uint64_t size, uint64_t seed);
157 * This loop generates each time a new pseudo-random number. However, if it's
158 * bigger than what we want, we discard it and generate the next one.
160 static inline uint64_t lfsr_next(struct lfsr *lfsr)
163 lfsr->state = (lfsr->state >> 1) ^
164 (((lfsr->state & 1UL) - 1UL) & lfsr->xnormask);
165 } while (lfsr->state > lfsr->limit);