Motr  M0
net_test.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include <stdio.h>
23 #include <math.h> /* sqrt */
24 
25 #include "motr/init.h"
26 
27 #include "desim/sim.h"
28 #include "desim/storage.h"
29 #include "desim/chs.h"
30 #include "desim/net.h"
31 #include "desim/client.h"
32 #include "desim/elevator.h"
33 
39 static struct net_conf net = {
40  .nc_frag_size = 4*1024,
41  .nc_rpc_size = 1024,
42  .nc_rpc_delay_min = 1000, /* microsecond */
43  .nc_rpc_delay_max = 5000,
44  .nc_frag_delay_min = 100,
45  .nc_frag_delay_max = 1000,
46  .nc_rate_min = 750000000,
47  .nc_rate_max = 1000000000, /* 1GB/sec QDR Infiniband */
48  .nc_nob_max = ~0UL,
49  .nc_msg_max = ~0UL
50 };
51 
52 static struct net_srv srv = {
53  .ns_nr_threads = 64,
54  .ns_nr_devices = 1,
55  .ns_pre_bulk_min = 0,
56  .ns_pre_bulk_max = 1000
57 };
58 
59 static struct client_conf client = {
60  .cc_nr_clients = 0,
61  .cc_nr_threads = 0,
62  .cc_total = 100*1024*1024,
63  .cc_count = 1024*1024,
64  .cc_opt_count = 1024*1024,
65  .cc_inflight_max = 8,
66  .cc_delay_min = 0,
67  .cc_delay_max = 1000000, /* millisecond */
68  .cc_cache_max = ~0UL,
69  .cc_dirty_max = 32*1024*1024,
70  .cc_net = &net,
71  .cc_srv = &srv
72 };
73 
74 static struct chs_conf ST31000640SS = { /* Barracuda ES.2 */
75  .cc_storage = {
76  .sc_sector_size = 512,
77  },
78  .cc_heads = 4*2, /* sginfo */
79  .cc_cylinders = 153352, /* sginfo */
80  .cc_track_skew = 160, /* sginfo */
81  .cc_cylinder_skew = 76, /* sginfo */
82  .cc_sectors_min = 1220, /* sginfo */
83  .cc_sectors_max = 1800, /* guess */
84  .cc_cyl_in_zone = 48080, /* sginfo */
85 
86  .cc_seek_avg = 8500000, /* data sheet */
87  .cc_seek_track_to_track = 800000, /* data sheet */
88  .cc_seek_full_stroke = 16000000, /* guess */
89  .cc_write_settle = 500000, /* guess */
90  .cc_head_switch = 500000, /* guess */
91  .cc_command_latency = 0, /* unknown */
92 
93  .cc_rps = 7200/60
94 };
95 
96 struct chs_dev disc;
97 
98 static void workload_init(struct sim *s, int argc, char **argv)
99 {
101  net_init(&net);
102  net_srv_init(s, &srv);
105  client_init(s, &client);
106 }
107 
108 static void workload_fini(void)
109 {
111  net_srv_fini(&srv);
112  net_fini(&net);
113  elevator_fini(&srv.ns_el[0]);
114  chs_dev_fini(&disc);
116 }
117 
118 int main(int argc, char **argv)
119 {
120  struct sim s;
121  unsigned clients = atoi(argv[1]);
122  unsigned threads = atoi(argv[2]);
123  unsigned long long filesize;
124 
125  int result;
126 
127  result = m0_init(NULL);
128  if (result == 0) {
129  client.cc_nr_clients = clients;
130  client.cc_nr_threads = threads;
131  srv.ns_file_size = filesize = threads * client.cc_total;
132  sim_init(&s);
133  workload_init(&s, argc, argv);
134  sim_run(&s);
135  cnt_dump_all();
136  workload_fini();
137  sim_log(&s, SLL_WARN, "%5i %5i %10.2f\n", clients, threads,
138  1000.0 * filesize * clients / s.ss_bolt);
139  sim_fini(&s);
140  m0_fini();
141  }
142  return result;
143 }
144 
147 /*
148  * Local variables:
149  * c-indentation-style: "K&R"
150  * c-basic-offset: 8
151  * tab-width: 8
152  * fill-column: 80
153  * scroll-step: 1
154  * End:
155  */
Definition: sim.h:152
M0_INTERNAL void sim_init(struct sim *state)
Definition: sim.c:106
static struct chs_conf ST31000640SS
Definition: net_test.c:74
struct elevator * ns_el
Definition: net.h:65
#define NULL
Definition: misc.h:38
unsigned sc_sector_size
Definition: storage.h:39
struct chs_dev disc
Definition: net_test.c:96
void m0_fini(void)
Definition: init.c:318
M0_INTERNAL void chs_dev_fini(struct chs_dev *dev)
Definition: chs.c:147
M0_INTERNAL void chs_conf_fini(struct chs_conf *conf)
Definition: chs.c:123
M0_INTERNAL void elevator_init(struct elevator *el, struct storage_dev *dev)
Definition: elevator.c:77
Definition: sim.h:285
Definition: net.h:57
M0_INTERNAL void sim_log(struct sim *s, enum sim_log_level level, const char *format,...)
Definition: sim.c:527
Definition: chs.h:41
M0_INTERNAL void client_init(struct sim *s, struct client_conf *conf)
Definition: client.c:148
static struct net_conf net
Definition: net_test.c:39
int m0_init(struct m0 *instance)
Definition: init.c:310
Definition: net.h:39
M0_INTERNAL void sim_run(struct sim *state)
Definition: sim.c:129
M0_INTERNAL void chs_conf_init(struct chs_conf *conf)
Definition: chs.c:43
Definition: client.h:37
Definition: chs.h:76
int main(int argc, char **argv)
Test server for m0console.
Definition: dump.c:195
M0_INTERNAL void net_srv_init(struct sim *s, struct net_srv *srv)
Definition: net.c:101
M0_INTERNAL void net_init(struct net_conf *net)
Definition: net.c:129
struct storage_conf cc_storage
Definition: chs.h:42
M0_INTERNAL void elevator_fini(struct elevator *el)
Definition: elevator.c:87
M0_INTERNAL void cnt_dump_all(void)
Definition: cnt.c:74
static void workload_fini(void)
Definition: net_test.c:108
M0_INTERNAL void chs_dev_init(struct chs_dev *dev, struct sim *sim, struct chs_conf *conf)
Definition: chs.c:129
unsigned nc_frag_size
Definition: net.h:40
unsigned long long ns_file_size
Definition: net.h:66
static void workload_init(struct sim *s, int argc, char **argv)
Definition: net_test.c:98
static char clients[NTCS_NODES_MAX *NTCS_NODE_ADDR_MAX]
Definition: client_server.c:62
struct storage_dev cd_storage
Definition: chs.h:77
M0_INTERNAL void client_fini(struct client_conf *conf)
Definition: client.c:177
unsigned ns_nr_threads
Definition: net.h:58
M0_INTERNAL void sim_fini(struct sim *state)
Definition: sim.c:116
M0_INTERNAL void net_srv_fini(struct net_srv *srv)
Definition: net.c:110
static struct m0_addb2_source * s
Definition: consumer.c:39
static struct net_srv srv
Definition: net_test.c:52
M0_INTERNAL void net_fini(struct net_conf *net)
Definition: net.c:136