Hermes  0.9.5-beta
Hierarchical Distributed I/O Buffering System
buffer_organizer.h
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Distributed under BSD 3-Clause license. *
3  * Copyright by The HDF Group. *
4  * Copyright by the Illinois Institute of Technology. *
5  * All rights reserved. *
6  * *
7  * This file is part of Hermes. The full Hermes copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the top directory. If you do not *
10  * have access to the file, you may request a copy from help@hdfgroup.org. *
11  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 
13 #ifndef HERMES_BUFFER_ORGANIZER_H_
14 #define HERMES_BUFFER_ORGANIZER_H_
15 
16 #include "thread_pool.h"
17 
18 namespace hermes {
19 
21 using BoMoveList = std::vector<std::pair<BufferID, std::vector<BufferID>>>;
22 
24 enum class BoOperation {
25  kMove,
26  kCopy,
27  kDelete,
28 
29  kCount
30 };
31 
33 enum class BoPriority {
34  kLow,
35  kHigh,
36 
37  kCount
38 };
39 
43 union BoArgs {
45  struct {
50  struct {
51  BufferID src;
52  TargetID dest;
55  struct {
56  BufferID src;
58 };
59 
63 struct BoTask {
66 };
67 
71 struct BufferInfo {
74  size_t size;
75 };
76 
78 bool operator==(const BufferInfo &lhs, const BufferInfo &rhs);
79 
86  explicit BufferOrganizer(int num_threads);
87 };
88 
91  BlobID blob_id, const std::string &filename,
92  u64 offset);
94 bool EnqueueFlushingTask(RpcContext *rpc, BlobID blob_id,
95  const std::string &filename, u64 offset);
96 
97 void BoMove(SharedMemoryContext *context, RpcContext *rpc,
98  const BoMoveList &moves, BlobID blob_id, BucketID bucket_id,
99  const std::string &internal_blob_name);
100 void FlushBlob(SharedMemoryContext *context, RpcContext *rpc, BlobID blob_id,
101  const std::string &filename, u64 offset, bool async = false);
106  const std::string &vbkt_name);
109  const std::string &vbkt_name);
112  const std::string &vbkt_name);
115  const std::string &vbkt_name);
118  VBucketID id);
121  const std::string &internal_blob_name,
122  BucketID bucket_id, f32 epsilon,
123  f32 explicit_importance_score);
125 void OrganizeBlob(SharedMemoryContext *context, RpcContext *rpc,
126  BucketID bucket_id, const std::string &blob_name, f32 epsilon,
127  f32 importance_score = -1);
130  DeviceID devices_id);
131 
133 std::vector<BufferInfo> GetBufferInfo(SharedMemoryContext *context,
134  RpcContext *rpc,
135  const std::vector<BufferID> &buffer_ids);
138  const std::vector<BufferInfo> &buffer_info);
141  const BoMoveList &moves, BlobID blob_id,
142  BucketID bucket_id,
143  const std::string &internal_blob_name,
144  BoPriority priority);
146 void EnqueueBoMove(RpcContext *rpc, const BoMoveList &moves, BlobID blob_id,
147  BucketID bucket_id, const std::string &internal_name,
148  BoPriority priority);
151  ViolationInfo info);
154  RpcContext *rpc, ViolationInfo info);
155 } // namespace hermes
156 
157 #endif // HERMES_BUFFER_ORGANIZER_H_
Definition: thread_pool.h:26
Definition: adapter_utils.cc:35
BoPriority
Definition: buffer_organizer.h:33
void LocalDecrementFlushCount(SharedMemoryContext *context, const std::string &vbkt_name)
Definition: buffer_organizer.cc:793
float f32
Definition: hermes_types.h:48
std::vector< std::pair< BufferID, std::vector< BufferID > >> BoMoveList
Definition: buffer_organizer.h:21
bool LocalEnqueueFlushingTask(SharedMemoryContext *context, RpcContext *rpc, BlobID blob_id, const std::string &filename, u64 offset)
Definition: buffer_organizer.cc:728
void BoMove(SharedMemoryContext *context, RpcContext *rpc, const BoMoveList &moves, BlobID blob_id, BucketID bucket_id, const std::string &internal_blob_name)
Definition: buffer_organizer.cc:195
void FlushBlob(SharedMemoryContext *context, RpcContext *rpc, BlobID blob_id, const std::string &filename, u64 offset, bool async)
Definition: buffer_organizer.cc:667
void AwaitAsyncFlushingTasks(SharedMemoryContext *context, RpcContext *rpc, VBucketID id)
Definition: buffer_organizer.cc:824
void EnqueueBoMove(RpcContext *rpc, const BoMoveList &moves, BlobID blob_id, BucketID bucket_id, const std::string &internal_name, BoPriority priority)
Definition: buffer_organizer.cc:172
void LocalEnforceCapacityThresholds(SharedMemoryContext *context, RpcContext *rpc, ViolationInfo info)
Definition: buffer_organizer.cc:452
void LocalIncrementFlushCount(SharedMemoryContext *context, const std::string &vbkt_name)
Definition: buffer_organizer.cc:788
bool EnqueueFlushingTask(RpcContext *rpc, BlobID blob_id, const std::string &filename, u64 offset)
Definition: buffer_organizer.cc:720
u16 DeviceID
Definition: hermes_types.h:51
void OrganizeDevice(SharedMemoryContext *context, RpcContext *rpc, DeviceID devices_id)
void IncrementFlushCount(SharedMemoryContext *context, RpcContext *rpc, const std::string &vbkt_name)
Definition: buffer_organizer.cc:798
bool operator==(const BufferInfo &lhs, const BufferInfo &rhs)
Definition: buffer_organizer.cc:27
void EnforceCapacityThresholds(SharedMemoryContext *context, RpcContext *rpc, ViolationInfo info)
Definition: buffer_organizer.cc:442
void LocalEnqueueBoMove(SharedMemoryContext *context, RpcContext *rpc, const BoMoveList &moves, BlobID blob_id, BucketID bucket_id, const std::string &internal_blob_name, BoPriority priority)
Definition: buffer_organizer.cc:179
void LocalShutdownBufferOrganizer(SharedMemoryContext *context)
Definition: buffer_organizer.cc:661
BufferInfo GetBufferInfo(SharedMemoryContext *context, RpcContext *rpc, BufferID buffer_id)
Definition: buffer_organizer.cc:59
void DecrementFlushCount(SharedMemoryContext *context, RpcContext *rpc, const std::string &vbkt_name)
Definition: buffer_organizer.cc:811
uint64_t u64
Definition: hermes_types.h:43
f32 ComputeBlobAccessScore(SharedMemoryContext *context, const std::vector< BufferInfo > &buffer_info)
Definition: buffer_organizer.cc:107
void OrganizeBlob(SharedMemoryContext *context, RpcContext *rpc, BucketID bucket_id, const std::string &blob_name, f32 epsilon, f32 importance_score)
Definition: buffer_organizer.cc:426
void LocalOrganizeBlob(SharedMemoryContext *context, RpcContext *rpc, const std::string &internal_blob_name, BucketID bucket_id, f32 epsilon, f32 explicit_importance_score)
Definition: buffer_organizer.cc:316
BoOperation
Definition: buffer_organizer.h:24
Definition: buffer_organizer.h:63
BoOperation op
Definition: buffer_organizer.h:64
BoArgs args
Definition: buffer_organizer.h:65
Definition: buffer_organizer.h:71
size_t size
Definition: buffer_organizer.h:74
BufferID id
Definition: buffer_organizer.h:72
f32 bandwidth_mbps
Definition: buffer_organizer.h:73
Definition: buffer_organizer.h:83
BufferOrganizer(int num_threads)
Definition: buffer_organizer.cc:24
ThreadPool pool
Definition: buffer_organizer.h:84
Definition: rpc.h:43
Definition: buffer_pool.h:273
Definition: metadata_management.h:72
Definition: hermes_types.h:405
Definition: buffer_organizer.h:43
BufferID src
Definition: buffer_organizer.h:46
struct hermes::BoArgs::@1 copy_args
struct hermes::BoArgs::@2 delete_args
struct hermes::BoArgs::@0 move_args
TargetID dest
Definition: buffer_organizer.h:47
Definition: hermes_types.h:358
Definition: buffer_pool.h:93
Definition: hermes_types.h:198
Definition: hermes_types.h:388