txgraph: expose memory usage estimate function (feature)
This commit is contained in:
1 parent
7680bb8fd4
commit
04c808ac4c
3 files changed
+39
No files matched your search
@@ -629,6 +629,8 @@ public:
|
||||
std::unique_ptr<BlockBuilder> GetBlockBuilder() noexcept final;
|
||||
std::pair<std::vector<Ref*>, FeePerWeight> GetWorstMainChunk() noexcept final;
|
||||
|
||||
size_t GetMainMemoryUsage() noexcept final;
|
||||
|
||||
void SanityCheck() const final;
|
||||
};
|
||||
|
||||
@@ -2980,6 +2982,21 @@ std::vector<TxGraph::Ref*> TxGraphImpl::Trim() noexcept
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t TxGraphImpl::GetMainMemoryUsage() noexcept
|
||||
{
|
||||
// Make sure splits/merges are applied, as memory usage may not be representative otherwise.
|
||||
SplitAll(/*up_to_level=*/0);
|
||||
ApplyDependencies(/*level=*/0);
|
||||
// Compute memory usage
|
||||
size_t usage = /* From clusters */
|
||||
m_main_clusterset.m_cluster_usage +
|
||||
/* From Entry objects. */
|
||||
sizeof(Entry) * m_main_clusterset.m_txcount +
|
||||
/* From the chunk index. */
|
||||
memusage::DynamicUsage(m_main_chunkindex);
|
||||
return usage;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TxGraph::Ref::~Ref()
|
||||
|
||||
Reference in new issue
Block a user