-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontention_manager.h
More file actions
51 lines (36 loc) · 1.2 KB
/
contention_manager.h
File metadata and controls
51 lines (36 loc) · 1.2 KB
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
#ifndef VHANDLE_BATCHAPPENDER_H
#define VHANDLE_BATCHAPPENDER_H
#include "vhandle.h"
namespace felis {
struct VersionBufferHandle {
uint8_t *prealloc_ptr;
long pos;
void Append(VHandle *handle, uint64_t sid, uint64_t epoch_nr, bool is_ondemand_split);
void FlushIntoNoLock(VHandle *handle, uint64_t epoch_nr, unsigned int end);
};
struct VersionBufferHead;
class ContentionManager {
friend class VersionBufferHead;
std::array<VersionBufferHead *, NodeConfiguration::kMaxNrThreads> buffer_heads;
size_t est_split;
public:
ContentionManager();
VersionBufferHandle GetOrInstall(VHandle *handle);
void FinalizeFlush(uint64_t epoch_nr);
void Reset();
int GetRowContentionAffinity(VHandle *row) const;
size_t estimated_splits() const { return est_split; }
static size_t g_prealloc_count;
private:
static size_t BinPack(VHandle **knapsacks, unsigned int nr_knapsack, int label, size_t limit);
static void PackLeftOver(VHandle **knapsacks, unsigned int nr_knapsack, int label);
};
}
namespace util {
template <> struct InstanceInit<felis::ContentionManager> {
static constexpr bool kHasInstance = true;
static inline felis::ContentionManager *instance;
InstanceInit();
};
}
#endif