1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2009 Sage Weil <sage@newdream.net>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_OBJ_BENCHER_H
16 #define CEPH_OBJ_BENCHER_H
18 #include "common/ceph_context.h"
19 #include "common/Formatter.h"
22 struct bench_interval_data
{
23 double min_bandwidth
= DBL_MAX
;
24 double max_bandwidth
= 0;
25 int min_iops
= INT_MAX
;
29 struct bench_history
{
30 vector
<double> bandwidth
;
31 vector
<double> latency
;
36 bool done
; //is the benchmark is done
37 uint64_t object_size
; //the size of the objects
38 uint64_t op_size
; // the size of the read/write ops
40 // same as object_size for write tests
41 int in_flight
; //number of reads/writes being waited on
47 struct bench_interval_data idata
; // data that is updated by time intervals and not by events
48 struct bench_history history
; // data history, used to calculate stddev
49 utime_t cur_latency
; //latency of last completed transaction
50 utime_t start_time
; //start time for benchmark
51 char *object_contents
; //pointer to the contents written to each object
54 const int OP_WRITE
= 1;
55 const int OP_SEQ_READ
= 2;
56 const int OP_RAND_READ
= 3;
58 // Object is composed of <oid,namespace>
59 typedef std::pair
<std::string
, std::string
> Object
;
63 Formatter
*formatter
= NULL
;
64 ostream
*outstream
= NULL
;
70 static void *status_printer(void *bencher
);
72 struct bench_data data
;
74 int fetch_bench_metadata(const std::string
& metadata_file
, uint64_t* op_size
,
75 uint64_t* object_size
, int* num_objects
, int* prevPid
);
77 int write_bench(int secondsToRun
, int concurrentios
, const string
& run_name_meta
, unsigned max_objects
);
78 int seq_read_bench(int secondsToRun
, int num_objects
, int concurrentios
, int writePid
, bool no_verify
=false);
79 int rand_read_bench(int secondsToRun
, int num_objects
, int concurrentios
, int writePid
, bool no_verify
=false);
81 int clean_up(int num_objects
, int prevPid
, int concurrentios
);
82 bool more_objects_matching_prefix(const std::string
& prefix
, std::list
<Object
>* name
);
84 virtual int completions_init(int concurrentios
) = 0;
85 virtual void completions_done() = 0;
87 virtual int create_completion(int i
, void (*cb
)(void *, void*), void *arg
) = 0;
88 virtual void release_completion(int slot
) = 0;
90 virtual bool completion_is_done(int slot
) = 0;
91 virtual int completion_wait(int slot
) = 0;
92 virtual int completion_ret(int slot
) = 0;
94 virtual int aio_read(const std::string
& oid
, int slot
, bufferlist
*pbl
, size_t len
, size_t offset
) = 0;
95 virtual int aio_write(const std::string
& oid
, int slot
, bufferlist
& bl
, size_t len
, size_t offset
) = 0;
96 virtual int aio_remove(const std::string
& oid
, int slot
) = 0;
97 virtual int sync_read(const std::string
& oid
, bufferlist
& bl
, size_t len
) = 0;
98 virtual int sync_write(const std::string
& oid
, bufferlist
& bl
, size_t len
) = 0;
99 virtual int sync_remove(const std::string
& oid
) = 0;
101 virtual bool get_objects(std::list
< std::pair
<std::string
, std::string
> >* objects
, int num
) = 0;
102 virtual void set_namespace(const std::string
&) {}
104 ostream
& out(ostream
& os
);
105 ostream
& out(ostream
& os
, utime_t
& t
);
107 explicit ObjBencher(CephContext
*cct_
) : show_time(false), cct(cct_
), lock("ObjBencher::lock") {}
108 virtual ~ObjBencher() {}
110 int operation
, int secondsToRun
,
111 int concurrentios
, uint64_t op_size
, uint64_t object_size
, unsigned max_objects
,
112 bool cleanup
, bool hints
, const std::string
& run_name
, bool no_verify
=false);
113 int clean_up(const std::string
& prefix
, int concurrentios
, const std::string
& run_name
);
115 void set_show_time(bool dt
) {
118 void set_formatter(Formatter
*f
) {
121 void set_outstream(ostream
& os
) {
124 int clean_up_slow(const std::string
& prefix
, int concurrentios
);