mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
New account storage stat for accelerator
This commit is contained in:
parent
15da5e846b
commit
928f02e6a1
14 changed files with 514 additions and 127 deletions
|
|
@ -1259,14 +1259,6 @@ bool VmStorageStat::add_storage(const CellSlice& cs) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static td::uint64 estimate_prunned_size() {
|
||||
return 41;
|
||||
}
|
||||
|
||||
static td::uint64 estimate_serialized_size(const Ref<DataCell>& cell) {
|
||||
return cell->get_serialized_size() + cell->size_refs() * 3 + 3;
|
||||
}
|
||||
|
||||
void ProofStorageStat::add_cell(const Ref<DataCell>& cell) {
|
||||
auto& status = cells_[cell->get_hash()];
|
||||
if (status == c_loaded) {
|
||||
|
|
@ -1290,4 +1282,17 @@ td::uint64 ProofStorageStat::estimate_proof_size() const {
|
|||
return proof_size_;
|
||||
}
|
||||
|
||||
ProofStorageStat::CellStatus ProofStorageStat::get_cell_status(const Cell::Hash& hash) const {
|
||||
auto it = cells_.find(hash);
|
||||
return it == cells_.end() ? c_none : it->second;
|
||||
}
|
||||
|
||||
td::uint64 ProofStorageStat::estimate_prunned_size() {
|
||||
return 41;
|
||||
}
|
||||
|
||||
td::uint64 ProofStorageStat::estimate_serialized_size(const Ref<DataCell>& cell) {
|
||||
return cell->get_serialized_size() + cell->size_refs() * 3 + 3;
|
||||
}
|
||||
|
||||
} // namespace vm
|
||||
|
|
|
|||
|
|
@ -167,11 +167,17 @@ class ProofStorageStat {
|
|||
public:
|
||||
void add_cell(const Ref<DataCell>& cell);
|
||||
td::uint64 estimate_proof_size() const;
|
||||
private:
|
||||
|
||||
enum CellStatus {
|
||||
c_none = 0, c_prunned = 1, c_loaded = 2
|
||||
};
|
||||
td::HashMap<vm::Cell::Hash, CellStatus> cells_;
|
||||
CellStatus get_cell_status(const Cell::Hash& hash) const;
|
||||
|
||||
static td::uint64 estimate_prunned_size();
|
||||
static td::uint64 estimate_serialized_size(const Ref<DataCell>& cell);
|
||||
|
||||
private:
|
||||
td::HashMap<Cell::Hash, CellStatus> cells_;
|
||||
td::uint64 proof_size_ = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ void CellUsageTree::set_use_mark_for_is_loaded(bool use_mark) {
|
|||
}
|
||||
|
||||
void CellUsageTree::on_load(NodeId node_id, const td::Ref<vm::DataCell>& cell) {
|
||||
if (nodes_[node_id].is_loaded) {
|
||||
if (ignore_loads_ || nodes_[node_id].is_loaded) {
|
||||
return;
|
||||
}
|
||||
nodes_[node_id].is_loaded = true;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ class CellUsageTree : public std::enable_shared_from_this<CellUsageTree> {
|
|||
void set_cell_load_callback(std::function<void(const td::Ref<vm::DataCell>&)> f) {
|
||||
cell_load_callback_ = std::move(f);
|
||||
}
|
||||
void set_ignore_loads(bool value) {
|
||||
ignore_loads_ = value;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Node {
|
||||
|
|
@ -80,5 +83,6 @@ class CellUsageTree : public std::enable_shared_from_this<CellUsageTree> {
|
|||
|
||||
void on_load(NodeId node_id, const td::Ref<vm::DataCell>& cell);
|
||||
NodeId create_node(NodeId parent);
|
||||
bool ignore_loads_ = false;
|
||||
};
|
||||
} // namespace vm
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "common/refcnt.hpp"
|
||||
#include "td/utils/HashMap.h"
|
||||
#include "vm/cellslice.h"
|
||||
#include "vm/stack.hpp"
|
||||
#include "vm/vmstate.h"
|
||||
|
|
@ -424,6 +425,10 @@ class VmState final : public VmStateInterface {
|
|||
}
|
||||
}
|
||||
|
||||
td::HashSet<CellHash> extract_loaded_cells() {
|
||||
return std::move(loaded_cells);
|
||||
}
|
||||
|
||||
private:
|
||||
void init_cregs(bool same_c3 = false, bool push_0 = true);
|
||||
int run_inner();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue