Zero  0.1.0
tpcb_env.h
Go to the documentation of this file.
1 /* -*- mode:C++; c-basic-offset:4 -*-
2  Shore-kits -- Benchmark implementations for Shore-MT
3 
4  Copyright (c) 2007-2009
5  Data Intensive Applications and Systems Labaratory (DIAS)
6  Ecole Polytechnique Federale de Lausanne
7 
8  All Rights Reserved.
9 
10  Permission to use, copy, modify and distribute this software and
11  its documentation is hereby granted, provided that both the
12  copyright notice and this permission notice appear in all copies of
13  the software, derivative works or modified versions, and any
14  portions thereof, and that both notices appear in supporting
15  documentation.
16 
17  This code is distributed in the hope that it will be useful, but
18  WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS
20  DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
21  RESULTING FROM THE USE OF THIS SOFTWARE.
22 */
23 
33 #ifndef __TPCB_ENV_H
34 #define __TPCB_ENV_H
35 
36 #include "sm_vas.h"
37 
38 #include "tpcb_input.h"
39 
40 #include "shore_env.h"
41 #include "trx_worker.h"
42 
43 #include "tpcb_schema_man.h"
44 
45 #include <map>
46 
47 using std::map;
48 
49 namespace tpcb {
50 
51 /********************************************************************
52  *
53  * ShoreTPCBEnv Stats
54  *
55  * Shore TPC-B Database transaction statistics
56  *
57  ********************************************************************/
58 
61 
63 
65 
67 
69 
71 
73 
75 
76  uint mbench_mix;
77 
79  acct_update += rhs.acct_update;
80 
81  mbench_insert_only += rhs.mbench_insert_only;
82  mbench_delete_only += rhs.mbench_delete_only;
83  mbench_probe_only += rhs.mbench_probe_only;
84  mbench_insert_delete += rhs.mbench_insert_delete;
85  mbench_insert_probe += rhs.mbench_insert_probe;
86  mbench_delete_probe += rhs.mbench_delete_probe;
87  mbench_mix += rhs.mbench_mix;
88 
89  return (*this);
90  }
91 
93  acct_update -= rhs.acct_update;
94 
95  mbench_insert_only -= rhs.mbench_insert_only;
96  mbench_delete_only -= rhs.mbench_delete_only;
97  mbench_probe_only -= rhs.mbench_probe_only;
98  mbench_insert_delete -= rhs.mbench_insert_delete;
99  mbench_insert_probe -= rhs.mbench_insert_probe;
100  mbench_delete_probe -= rhs.mbench_delete_probe;
101  mbench_mix -= rhs.mbench_mix;
102 
103  return (*this);
104  }
105 
106  uint total() const {
107  return (acct_update +
108  mbench_insert_only + mbench_delete_only + mbench_probe_only +
109  mbench_insert_delete + mbench_insert_probe + mbench_delete_probe + mbench_mix);
110  }
111  }; // EOF: ShoreTPCBTrxCount
112 
113 
116 
118 
120 
122  attempted += other.attempted;
123  failed += other.failed;
124  deadlocked += other.deadlocked;
125  return (*this);
126  }
127 
129  attempted -= other.attempted;
130  failed -= other.failed;
131  deadlocked -= other.deadlocked;
132  return (*this);
133  }
134  }; // EOF: ShoreTPCBTrxStats
135 
136 
137 
138 /********************************************************************
139  *
140  * ShoreTPCBEnv
141  *
142  * Shore TPC-B Database.
143  *
144  ********************************************************************/
145 
146  class ShoreTPCBEnv : public ShoreEnv {
147  public:
148 
149  typedef std::map<pthread_t, ShoreTPCBTrxStats*> statmap_t;
150 
151  class table_builder_t;
152 class table_creator_t;
153 class fid_loader_t;
154 
155  public:
156 
157  ShoreTPCBEnv(boost::program_options::variables_map vm);
158 
159  virtual ~ShoreTPCBEnv();
160 
161 
162  // DB INTERFACE
163 
164  virtual int set(envVarMap* /* vars */) {
165  return (0); /* do nothing */ };
166 
167  virtual int open() {
168  return (0); /* do nothing */ };
169 
170  virtual int pause() {
171  return (0); /* do nothing */ };
172 
173  virtual int resume() {
174  return (0); /* do nothing */ };
175 
176  virtual w_rc_t newrun() {
177  return (RCOK); /* do nothing */ };
178 
179  virtual int post_init();
180 
181  virtual w_rc_t load_schema();
182 
183  virtual w_rc_t load_and_register_fids();
184 
185  virtual int conf();
186 
187  virtual int start();
188 
189  virtual int stop();
190 
191  virtual int info() const;
192 
193  virtual int statistics();
194 
195  int dump();
196 
197  virtual void print_throughput(const double iQueriedSF,
198  const int iSpread,
199  const int iNumOfThreads,
200  const double delay);
201 
202 
203  // Public methods //
204 
205  // --- operations over tables --- //
206  w_rc_t create_tables();
207 
208  w_rc_t load_data();
209 
210  w_rc_t warmup();
211 
212  w_rc_t check_consistency();
213 
214  // TPCB Tables
216 
218 
220 
222 
223  // --- kit baseline trxs --- //
224 
225  w_rc_t run_one_xct(Request* prequest);
226 
227  // Transactions
229 
230  // Microbenchmarks
232 
234 
236 
238 
240 
242 
244 
245  // Database population
247 
248  // for thread-local stats
249  virtual void env_thread_init();
250 
251  virtual void env_thread_fini();
252 
253  // stat map
254  statmap_t _statmap;
255 
256  // snapshot taken at the beginning of each experiment
258 
259  virtual void reset_stats();
260 
261  ShoreTPCBTrxStats _get_stats();
262 
263  // set load imbalance and time to apply it
264  void set_skew(int area, int load, int start_imbalance, int skew_type, bool shifting);
265 
266  void start_load_imbalance();
267 
268  void reset_skew();
269 
270  //print the current tables into files
271  w_rc_t db_print(int lines);
272 
273  //fetch the pages of the current tables and their indexes into the buffer pool
274  w_rc_t db_fetch();
275  }; // EOF ShoreTPCBEnv
276 
277 
278 }; // namespace
279 
280 #endif // __TPCB_ENV_H
Definition: tpcb_schema_man.h:69
virtual w_rc_t newrun()
Definition: tpcb_env.h:176
uint mbench_mix
Definition: tpcb_env.h:76
ShoreTPCBTrxStats & operator-=(ShoreTPCBTrxStats const &other)
Definition: tpcb_env.h:128
uint mbench_insert_probe
Definition: tpcb_env.h:72
const w_rc_t RCOK
Definition: w_rc.h:239
ShoreTPCBTrxStats & operator+=(ShoreTPCBTrxStats const &other)
Definition: tpcb_env.h:121
virtual int open()
Definition: tpcb_env.h:167
virtual int resume()
Definition: tpcb_env.h:173
std::map< pthread_t, ShoreTPCBTrxStats * > statmap_t
Definition: tpcb_env.h:149
uint mbench_delete_only
Definition: tpcb_env.h:66
Definition: reqs.h:278
Definition: tpcb_env.h:114
ShoreTPCBTrxCount failed
Definition: tpcb_env.h:117
uint mbench_insert_delete
Definition: tpcb_env.h:70
: Definition of a Shore environment (database)
ShoreTPCBTrxCount attempted
Definition: tpcb_env.h:115
: Wrapper for the worker threads in Baseline (specialization of the Shore workers) ...
uint populate_db
Definition: tpcb_env.h:62
virtual int pause()
Definition: tpcb_env.h:170
ShoreTPCBTrxStats _last_stats
Definition: tpcb_env.h:257
uint total() const
Definition: tpcb_env.h:106
uint mbench_insert_only
Definition: tpcb_env.h:64
Definition: tpcb_env.h:59
Definition: tpcb_env.cpp:307
history_man_impl * history_man
Definition: tpcb_env.h:221
Definition: tpcb_schema_man.h:130
Declaration of the (common) inputs for the TPC-C trxs.
uint mbench_delete_probe
Definition: tpcb_env.h:74
ShoreTPCBTrxCount & operator+=(ShoreTPCBTrxCount const &rhs)
Definition: tpcb_env.h:78
Return code for most functions and methods.
Definition: w_rc.h:87
account_man_impl * account_man
Definition: tpcb_env.h:219
branch_man_impl * branch_man
Definition: tpcb_env.h:215
map< string, string > envVarMap
Definition: shore_env.h:245
uint acct_update
Definition: tpcb_env.h:60
ShoreTPCBTrxCount deadlocked
Definition: tpcb_env.h:119
Definition: tpcb_env.cpp:251
Definition: tpcb_schema_man.h:91
#define DECLARE_TRX(trxlid)
Definition: shore_env.h:63
: Declaration of the TPC-B table managers
teller_man_impl * teller_man
Definition: tpcb_env.h:217
Definition: tpcb_schema_man.h:43
statmap_t _statmap
Definition: tpcb_env.h:254
Definition: shore_env.h:349
Definition: tpcb_env.h:146
Definition: tpcb_client.cpp:33
ShoreTPCBTrxCount & operator-=(ShoreTPCBTrxCount const &rhs)
Definition: tpcb_env.h:92
uint mbench_probe_only
Definition: tpcb_env.h:68