0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-20 03:43:47 +02:00

Revert "ircd::db::database::env: Reduce file size system calls with cache pattern."

This reverts commit 671120415f.
This commit is contained in:
Jason Volk 2022-06-23 13:27:49 -07:00
parent 7918605d72
commit 4bf297e5e7
2 changed files with 5 additions and 35 deletions

View file

@ -1344,8 +1344,6 @@ noexcept try
}; };
#endif #endif
assert(logical_size == -1UL || logical_size == fs::size(fd));
fd = fs::fd{}; fd = fs::fd{};
return Status::OK(); return Status::OK();
} }
@ -1615,7 +1613,6 @@ noexcept try
wopts.nodelay = nodelay; wopts.nodelay = nodelay;
wopts.interruptible = false; wopts.interruptible = false;
fs::truncate(fd, size, wopts); fs::truncate(fd, size, wopts);
logical_size = size;
return Status::OK(); return Status::OK();
} }
catch(const std::system_error &e) catch(const std::system_error &e)
@ -1667,9 +1664,6 @@ noexcept try
}; };
#endif #endif
if(likely(logical_size != -1UL) && offset + length > logical_size)
logical_size = -1UL;
if(opts.direct) if(opts.direct)
return Status::OK(); return Status::OK();
@ -1734,14 +1728,7 @@ noexcept try
data(s), size(s) data(s), size(s)
}; };
const const_buffer appended fs::append(fd, buf, wopts);
{
fs::append(fd, buf, wopts)
};
if(likely(logical_size != -1UL))
logical_size += size(appended);
return Status::OK(); return Status::OK();
} }
catch(const std::system_error &e) catch(const std::system_error &e)
@ -1807,19 +1794,7 @@ noexcept try
data(s), size(s) data(s), size(s)
}; };
const const_buffer appended fs::append(fd, buf, wopts);
{
fs::append(fd, buf, wopts)
};
const auto append_break
{
offset + size(appended)
};
if(likely(logical_size != -1UL) && append_break > logical_size)
logical_size = append_break;
return Status::OK(); return Status::OK();
} }
catch(const std::system_error &e) catch(const std::system_error &e)
@ -2063,18 +2038,14 @@ noexcept try
#ifdef RB_DEBUG_DB_ENV #ifdef RB_DEBUG_DB_ENV
log::debug log::debug
{ {
log, "[%s] wfile:%p fd:%d get file size; cached:%zd", log, "[%s] wfile:%p fd:%d get file size",
d.name, d.name,
this, this,
int(fd), int(fd)
logical_size,
}; };
#endif #endif
if(logical_size == -1UL) return fs::size(fd);
logical_size = fs::size(fd);
return logical_size;
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {

View file

@ -227,7 +227,6 @@ ircd::db::database::env::writable_file
bool nodelay {false}; bool nodelay {false};
WriteLifeTimeHint hint {WriteLifeTimeHint::WLTH_NOT_SET}; WriteLifeTimeHint hint {WriteLifeTimeHint::WLTH_NOT_SET};
fs::fd fd; fs::fd fd;
size_t logical_size {-1UL};
size_t preallocation_block_size {0}; size_t preallocation_block_size {0};
ssize_t preallocation_last_block {-1}; ssize_t preallocation_last_block {-1};