root / xseg / peers / user / bench-xseg.h @ 955151e6
History | View | Annotate | Download (3.3 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2012 GRNET S.A. All rights reserved.
|
3 |
*
|
4 |
* Redistribution and use in source and binary forms, with or
|
5 |
* without modification, are permitted provided that the following
|
6 |
* conditions are met:
|
7 |
*
|
8 |
* 1. Redistributions of source code must retain the above
|
9 |
* copyright notice, this list of conditions and the following
|
10 |
* disclaimer.
|
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.
|
15 |
*
|
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.
|
28 |
*
|
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.
|
33 |
*/
|
34 |
|
35 |
#define MAX_ARG_LEN 10 |
36 |
//It's "bench-uint32_t" which means 16 characters at most
|
37 |
#define TARGETLEN = 16 |
38 |
|
39 |
#define TM_SANE 0 |
40 |
#define TM_ECCENTRIC 1 |
41 |
#define TM_MANIC 2 |
42 |
#define TM_PARANOID 3 |
43 |
|
44 |
/*
|
45 |
* Pattern type occupies first flag bit.
|
46 |
* If 1, it's synchronous, if 0, it's random.
|
47 |
*/
|
48 |
#define IO_SYNC 0 |
49 |
#define IO_RAND 1 |
50 |
#define PATTERN_FLAG 0 |
51 |
|
52 |
struct bench {
|
53 |
uint64_t ts; //Total I/O size
|
54 |
uint64_t os; //Object size
|
55 |
uint64_t bs; //Block size
|
56 |
uint32_t iodepth; //Num of in-flight xseg reqs
|
57 |
xport dst_port; |
58 |
xport src_port; |
59 |
uint32_t op; //xseg operation
|
60 |
uint8_t flags; |
61 |
struct timer *total_tm; //Total time for benchmark |
62 |
struct timer *get_tm; //Time for xseg_get_request |
63 |
struct timer *sub_tm; //Time for xseg_submit_request |
64 |
struct timer *rec_tm; //Time for xseg_receive_request |
65 |
}; |
66 |
|
67 |
/*
|
68 |
* Custom timespec. Made to calculate variance, where we need the square of a
|
69 |
* timespec struct. This struct should be more than enough to hold the square
|
70 |
* of the biggest timespec.
|
71 |
*/
|
72 |
struct timespec2 {
|
73 |
unsigned long tv_sec2; |
74 |
uint64_t tv_nsec2; |
75 |
}; |
76 |
|
77 |
/*
|
78 |
* struct timer fields
|
79 |
* ====================
|
80 |
* completed: number of completed requests
|
81 |
* start_time: submission time of a request
|
82 |
* sum: the sum of elapsed times of every completed request
|
83 |
* sum_sq: the sum of the squares of elapsed times
|
84 |
* insanity: benchmarking level, higher means that the request associated with
|
85 |
* this timer is more trivial.
|
86 |
*/
|
87 |
struct timer {
|
88 |
struct timespec sum;
|
89 |
struct timespec2 sum_sq;
|
90 |
struct timespec start_time;
|
91 |
uint32_t completed; |
92 |
unsigned int insanity; |
93 |
}; |
94 |
|
95 |
struct tm_result {
|
96 |
unsigned long s; |
97 |
unsigned long ms; |
98 |
unsigned long us; |
99 |
unsigned long ns; |
100 |
}; |
101 |
|
102 |
int custom_peerd_loop(void *arg); |
103 |
|
104 |
void timer_start(struct timer *sample_req); |
105 |
void timer_stop(struct timer *sample_tm, struct timespec *start); |
106 |
int init_timer(struct timer **tm, int insanity); |
107 |
|