-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathio_engines.hpp
95 lines (76 loc) · 3.18 KB
/
io_engines.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef __IO_ENGINES_HPP__
#define __IO_ENGINES_HPP__
#include <libaio.h>
#include "io_engine.hpp"
// Stateful engine
class io_engine_stateful_t : public io_engine_t {
public:
io_engine_stateful_t(std::vector<ticks_t> *_latencies, stream_stat_t *_stream_stat, pthread_mutex_t *_latency_mutex)
: io_engine_t(_latencies, _stream_stat, _latency_mutex)
{}
virtual void perform_read_op(off64_t offset, char *buf);
virtual void perform_write_op(off64_t offset, char *buf);
virtual void perform_trim_op(off64_t offset);
};
// Stateless engine
class io_engine_stateless_t : public io_engine_t {
public:
io_engine_stateless_t(std::vector<ticks_t> *_latencies, stream_stat_t *_stream_stat, pthread_mutex_t *_latency_mutex)
: io_engine_t(_latencies, _stream_stat, _latency_mutex)
{}
virtual void perform_read_op(off64_t offset, char *buf);
virtual void perform_write_op(off64_t offset, char *buf);
};
// PAIO engine
class io_engine_paio_t : public io_engine_t {
public:
io_engine_paio_t(std::vector<ticks_t> *_latencies, stream_stat_t *_stream_stat, pthread_mutex_t *_latency_mutex)
: io_engine_t(_latencies, _stream_stat, _latency_mutex)
{}
virtual void post_open_setup();
virtual void perform_read_op(off64_t offset, char *buf);
virtual void perform_write_op(off64_t offset, char *buf);
virtual int perform_op(char *buf, long long ops, rnd_gen_t rnd_gen);
virtual void run_benchmark();
void perform_read_op(off64_t offset, char *buf, aiocb64 *request);
void perform_write_op(off64_t offset, char *buf, aiocb64 *request);
int perform_op(char *buf, aiocb64 *request, long long ops, rnd_gen_t rnd_gen);
private:
void set_timestamp(aiocb64 *request);
aiocb64 *requests;
};
// PAIO engine
class io_engine_naio_t : public io_engine_t {
public:
io_engine_naio_t(std::vector<ticks_t> *_latencies, stream_stat_t *_stream_stat, pthread_mutex_t *_latency_mutex)
: io_engine_t(_latencies, _stream_stat, _latency_mutex)
{}
virtual void perform_read_op(off64_t offset, char *buf);
virtual void perform_write_op(off64_t offset, char *buf);
virtual int perform_op(char *buf, long long ops, rnd_gen_t rnd_gen);
virtual void run_benchmark();
void perform_read_op(off64_t offset, char *buf, iocb *request);
void perform_write_op(off64_t offset, char *buf, iocb *request);
int perform_op(char *buf, iocb *request, long long ops, rnd_gen_t rnd_gen);
private:
void set_timestamp(iocb *request);
io_context_t ctx_id;
iocb *requests;
int notification_fd;
};
// mmap engine
class io_engine_mmap_t : public io_engine_t {
public:
io_engine_mmap_t(std::vector<ticks_t> *_latencies, stream_stat_t *_stream_stat, pthread_mutex_t *_latency_mutex)
: io_engine_t(_latencies, _stream_stat, _latency_mutex)
{}
virtual int contribute_open_flags();
virtual void post_open_setup();
virtual void pre_close_teardown();
virtual void perform_read_op(off64_t offset, char *buf);
virtual void perform_write_op(off64_t offset, char *buf);
virtual void copy_io_state(io_engine_t *io_engine);
private:
void *map;
};
#endif // __IO_ENGINES_HPP__