15
15
16
16
using namespace ::dfly::tiering::literals;
17
17
18
- ABSL_FLAG (bool , backing_file_direct, false , " If true uses O_DIRECT to open backing files" );
18
+ ABSL_FLAG (bool , backing_file_direct, true , " If true uses O_DIRECT to open backing files" );
19
19
20
20
ABSL_FLAG (uint64_t , registered_buffer_size, 512_KB,
21
21
" Size of registered buffer for IoUring fixed read/writes" );
@@ -39,16 +39,6 @@ void DestroyTmpBuf(UringBuf buf) {
39
39
::operator delete[] (buf.bytes .data (), std::align_val_t (kPageSize ));
40
40
}
41
41
42
- UringBuf PrepareBuf (size_t size) {
43
- DCHECK_EQ (ProactorBase::me ()->GetKind (), ProactorBase::IOURING);
44
- auto * up = static_cast <UringProactor*>(ProactorBase::me ());
45
-
46
- if (auto borrowed = up->RequestBuffer (size); borrowed)
47
- return *borrowed;
48
- else
49
- return AllocateTmpBuf (size);
50
- }
51
-
52
42
void ReturnBuf (UringBuf buf) {
53
43
DCHECK_EQ (ProactorBase::me ()->GetKind (), ProactorBase::IOURING);
54
44
auto * up = static_cast <UringProactor*>(ProactorBase::me ());
@@ -103,6 +93,8 @@ std::error_code DiskStorage::Open(std::string_view path) {
103
93
104
94
void DiskStorage::Close () {
105
95
using namespace std ::chrono_literals;
96
+
97
+ // TODO: to fix this polling.
106
98
while (pending_ops_ > 0 || grow_pending_)
107
99
util::ThisFiber::SleepFor (10ms);
108
100
@@ -175,7 +167,7 @@ std::error_code DiskStorage::Stash(io::Bytes bytes, StashCb cb) {
175
167
}
176
168
177
169
DiskStorage::Stats DiskStorage::GetStats () const {
178
- return {alloc_.allocated_bytes (), alloc_.capacity ()};
170
+ return {alloc_.allocated_bytes (), alloc_.capacity (), heap_buf_alloc_cnt_, reg_buf_alloc_cnt_ };
179
171
}
180
172
181
173
std::error_code DiskStorage::Grow (off_t grow_size) {
@@ -196,4 +188,16 @@ std::error_code DiskStorage::Grow(off_t grow_size) {
196
188
return {};
197
189
}
198
190
191
+ UringBuf DiskStorage::PrepareBuf (size_t size) {
192
+ DCHECK_EQ (ProactorBase::me ()->GetKind (), ProactorBase::IOURING);
193
+ auto * up = static_cast <UringProactor*>(ProactorBase::me ());
194
+
195
+ if (auto borrowed = up->RequestBuffer (size); borrowed) {
196
+ ++reg_buf_alloc_cnt_;
197
+ return *borrowed;
198
+ }
199
+ ++heap_buf_alloc_cnt_;
200
+ return AllocateTmpBuf (size);
201
+ }
202
+
199
203
} // namespace dfly::tiering
0 commit comments