mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
context: create a Pool of BtrfsIoctlLogicalInoArgs objects
Each object contains a 16 MiB buffer, which is very heavy for some malloc implementations. Keep the objects in a Pool so that their buffers are only allocated and deallocated once in the process lifetime. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
7c764a73c8
commit
3430f16998
@ -757,6 +757,15 @@ BeesResolveAddrResult::BeesResolveAddrResult()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shared_ptr<BtrfsIoctlLogicalInoArgs>
|
||||||
|
BeesContext::logical_ino(const uint64_t logical, const bool all_refs)
|
||||||
|
{
|
||||||
|
const auto rv = m_logical_ino_pool();
|
||||||
|
rv->set_logical(logical);
|
||||||
|
rv->set_flags(all_refs ? BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET : 0);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
BeesResolveAddrResult
|
BeesResolveAddrResult
|
||||||
BeesContext::resolve_addr_uncached(BeesAddress addr)
|
BeesContext::resolve_addr_uncached(BeesAddress addr)
|
||||||
{
|
{
|
||||||
@ -768,7 +777,8 @@ BeesContext::resolve_addr_uncached(BeesAddress addr)
|
|||||||
// transaction latency, competing threads, and freeze/SIGSTOP
|
// transaction latency, competing threads, and freeze/SIGSTOP
|
||||||
// pausing the bees process.
|
// pausing the bees process.
|
||||||
|
|
||||||
BtrfsIoctlLogicalInoArgs log_ino(addr.get_physical_or_zero());
|
const auto log_ino_ptr = logical_ino(addr.get_physical_or_zero(), false);
|
||||||
|
auto &log_ino = *log_ino_ptr;
|
||||||
|
|
||||||
// Time how long this takes
|
// Time how long this takes
|
||||||
Timer resolve_timer;
|
Timer resolve_timer;
|
||||||
@ -910,6 +920,9 @@ BeesContext::start()
|
|||||||
m_tmpfile_pool.generator([=]() -> shared_ptr<BeesTempFile> {
|
m_tmpfile_pool.generator([=]() -> shared_ptr<BeesTempFile> {
|
||||||
return make_shared<BeesTempFile>(shared_from_this());
|
return make_shared<BeesTempFile>(shared_from_this());
|
||||||
});
|
});
|
||||||
|
m_logical_ino_pool.generator([]() {
|
||||||
|
return make_shared<BtrfsIoctlLogicalInoArgs>(0);
|
||||||
|
});
|
||||||
m_tmpfile_pool.checkin([](const shared_ptr<BeesTempFile> &btf) {
|
m_tmpfile_pool.checkin([](const shared_ptr<BeesTempFile> &btf) {
|
||||||
catch_all([&](){
|
catch_all([&](){
|
||||||
btf->reset();
|
btf->reset();
|
||||||
|
@ -714,6 +714,7 @@ class BeesContext : public enable_shared_from_this<BeesContext> {
|
|||||||
shared_ptr<BeesHashTable> m_hash_table;
|
shared_ptr<BeesHashTable> m_hash_table;
|
||||||
shared_ptr<BeesRoots> m_roots;
|
shared_ptr<BeesRoots> m_roots;
|
||||||
Pool<BeesTempFile> m_tmpfile_pool;
|
Pool<BeesTempFile> m_tmpfile_pool;
|
||||||
|
Pool<BtrfsIoctlLogicalInoArgs> m_logical_ino_pool;
|
||||||
|
|
||||||
LRUCache<BeesResolveAddrResult, BeesAddress> m_resolve_cache;
|
LRUCache<BeesResolveAddrResult, BeesAddress> m_resolve_cache;
|
||||||
|
|
||||||
@ -753,6 +754,8 @@ public:
|
|||||||
|
|
||||||
bool scan_forward(const BeesFileRange &bfr);
|
bool scan_forward(const BeesFileRange &bfr);
|
||||||
|
|
||||||
|
shared_ptr<BtrfsIoctlLogicalInoArgs> logical_ino(uint64_t bytenr, bool all_refs);
|
||||||
|
|
||||||
bool is_root_ro(uint64_t root);
|
bool is_root_ro(uint64_t root);
|
||||||
BeesRangePair dup_extent(const BeesFileRange &src, const shared_ptr<BeesTempFile> &tmpfile);
|
BeesRangePair dup_extent(const BeesFileRange &src, const shared_ptr<BeesTempFile> &tmpfile);
|
||||||
bool dedup(const BeesRangePair &brp);
|
bool dedup(const BeesRangePair &brp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user