forked from haubenmi/navigating-cloud-oltp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteBlockDeviceArchitecture.cpp
More file actions
59 lines (53 loc) · 3.38 KB
/
RemoteBlockDeviceArchitecture.cpp
File metadata and controls
59 lines (53 loc) · 3.38 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
52
53
54
55
56
57
58
59
#include "RemoteBlockDeviceArchitecture.hpp"
#include "infra/Math.hpp"
//--------------------------------------------------------------------------------
using namespace std;
using namespace infra;
//--------------------------------------------------------------------------------
RemoteBlockDevice::RemoteBlockDevice(Parameter p, Primary prim, EBSAllotment ebs) : Architecture{p, prim, ArchType::RemoteBlockDevice}, pageService{parameter, primary, ebs, Rate::zero, Rate::zero}, log{parameter, primary, ebs} {
// Updates
Rate cpuUpdates = primary.n.cpu.getOps(parameter.cpuCost);
auto pageWritesPerUpdate = primary.probEvictDirtyPageFromCache();
auto logWritesPerUpdate = parameter.groupCommit ? ((parameter.getAriesLogRecordSize() * 1.0) / EBS::maxIopSize) : divRoundUp(parameter.getAriesLogRecordSize(), EBS::maxIopSize);
auto writesPerUpdate = pageWritesPerUpdate + logWritesPerUpdate;
auto readsPerUpdate = primary.probCacheMiss();
auto totalIOPS = ebs.iops;
double ebsScale = writesPerUpdate + readsPerUpdate; // > 1.0
updates = vmin(cpuUpdates, totalIOPS / ebsScale, parameter.requiredUpdateOps);
// Lookups
Rate cpuLookups = cpuUpdates - updates;
auto writesPerLookup = primary.probEvictDirtyPageFromCache();
auto readsPerLookup = primary.probCacheMiss();
auto remainingIops = totalIOPS - updates * ebsScale;
lookups = vmin(cpuLookups, remainingIops / (readsPerLookup + writesPerLookup), parameter.requiredLookupOps);
primary.logVolume = updates.rate * parameter.getAriesLogRecordSize();
commitLatency = EBS::writeLatency;
opLatency = Latency::combine({{primary.probCacheMiss(), EBS::readLatency}, {primary.probCacheHit(), Memory::readLatency}});
}
//--------------------------------------------------------------------------------
Durability RemoteBlockDevice::getDurability() const { return log.getDurability(); }
//--------------------------------------------------------------------------------
unique_ptr<RemoteBlockDevice> RemoteBlockDevice::assemble(const Parameter& p2, Node n, EBS::Type t) {
auto p = p2;
assert(p.indexOnlyTables);
p.walIncludesUndo = true;
Primary primary{p, n};
// Create an EBS device that fits both the database and the log
auto size = p.getDataSize() + p.getRequiredAriesLogStorage();
auto pageWrites = p.requiredOps() * primary.probEvictDirtyPageFromCache();
auto pageReads = p.requiredOps() * primary.probCacheMiss();
auto logWrites = p.requiredUpdateOps * (p.groupCommit ? (p.getAriesLogRecordSize() * 1.0) / EBS::maxIopSize : divRoundUp(p.getAriesLogRecordSize(), EBS::maxIopSize));
auto requiredIOPS = pageWrites + pageReads + logWrites;
auto requiredBandwidth = (pageWrites + pageReads).nextInt() * p.pageSize + p.requiredUpdateOps.rate * p.getAriesLogRecordSize();
auto ebs = primary.addEBSCapacity(t, size, requiredIOPS, requiredBandwidth, max(p.pageSize, p.tupleSize));
if (!ebs) return {};
assert(size <= ebs->size);
if (p.requiredOps() > primary.n.cpu.getOps(p.cpuCost)) return {};
return make_unique<RemoteBlockDevice>(p, primary, *ebs);
}
//--------------------------------------------------------------------------------
FailoverTime RemoteBlockDevice::getFailoverTime() const {
// Cache warmup
return Node::nodeSpinupTime + FailoverTime{1.0 * primary.dataInCache() / std::max(pageService.ebs.bandwidth,10ul)};
}
//--------------------------------------------------------------------------------