1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

serialize boc with bfs (with multiget)

This commit is contained in:
Marat S 2025-02-12 19:08:57 +00:00
parent 3c245c6146
commit fbb9954391
14 changed files with 448 additions and 122 deletions

View file

@ -273,8 +273,38 @@ class CachedCellDbReader : public vm::CellDbReader {
}
return parent_->load_cell(hash);
}
td::Result<std::vector<Ref<vm::DataCell>>> load_bulk(td::Span<td::Slice> hashes) override {
total_reqs_ += hashes.size();
if (!cache_) {
++bulk_reqs_;
return parent_->load_bulk(hashes);
}
std::vector<td::Slice> missing_hashes;
std::vector<size_t> missing_indices;
std::vector<td::Ref<vm::DataCell>> res(hashes.size());
for (size_t i = 0; i < hashes.size(); i++) {
auto it = cache_->find(hashes[i]);
if (it != cache_->end()) {
++cached_reqs_;
TRY_RESULT(loaded_cell, (*it)->load_cell());
res[i] = loaded_cell.data_cell;
continue;
}
missing_hashes.push_back(hashes[i]);
missing_indices.push_back(i);
}
if (missing_hashes.empty()) {
return std::move(res);
}
TRY_RESULT(missing_cells, parent_->load_bulk(missing_hashes));
for (size_t i = 0; i < missing_indices.size(); i++) {
res[missing_indices[i]] = missing_cells[i];
}
return res;
};
void print_stats() const {
LOG(WARNING) << "CachedCellDbReader stats : " << total_reqs_ << " reads, " << cached_reqs_ << " cached";
LOG(WARNING) << "CachedCellDbReader stats : " << total_reqs_ << " reads, " << cached_reqs_ << " cached, "
<< bulk_reqs_ << " bulk reqs";
}
private:
std::shared_ptr<vm::CellDbReader> parent_;
@ -282,6 +312,7 @@ class CachedCellDbReader : public vm::CellDbReader {
td::uint64 total_reqs_ = 0;
td::uint64 cached_reqs_ = 0;
td::uint64 bulk_reqs_ = 0;
};
void AsyncStateSerializer::PreviousStateCache::prepare_cache(ShardIdFull shard) {