mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated fift/func
This commit is contained in:
parent
b6f6788532
commit
d41ce55305
31 changed files with 717 additions and 66 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "td/db/RocksDb.h"
|
||||
|
||||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/table.h"
|
||||
#include "rocksdb/statistics.h"
|
||||
#include "rocksdb/write_batch.h"
|
||||
#include "rocksdb/utilities/optimistic_transaction_db.h"
|
||||
|
@ -63,6 +64,13 @@ Result<RocksDb> RocksDb::open(std::string path) {
|
|||
auto statistics = rocksdb::CreateDBStatistics();
|
||||
{
|
||||
rocksdb::Options options;
|
||||
|
||||
static auto cache = rocksdb::NewLRUCache(1 << 30);
|
||||
|
||||
rocksdb::BlockBasedTableOptions table_options;
|
||||
table_options.block_cache = cache;
|
||||
options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(table_options));
|
||||
|
||||
options.manual_wal_flush = true;
|
||||
options.create_if_missing = true;
|
||||
options.max_background_compactions = 4;
|
||||
|
@ -82,6 +90,10 @@ std::unique_ptr<KeyValueReader> RocksDb::snapshot() {
|
|||
}
|
||||
|
||||
std::string RocksDb::stats() const {
|
||||
std::string out;
|
||||
db_->GetProperty("rocksdb.stats", &out);
|
||||
//db_->GetProperty("rocksdb.cur-size-all-mem-tables", &out);
|
||||
return out;
|
||||
return statistics_->ToString();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ class RocksDb : public KeyValue {
|
|||
RocksDb &operator=(RocksDb &&);
|
||||
~RocksDb();
|
||||
|
||||
std::shared_ptr<rocksdb::OptimisticTransactionDB> raw_db() const {
|
||||
return db_;
|
||||
};
|
||||
|
||||
private:
|
||||
std::shared_ptr<rocksdb::OptimisticTransactionDB> db_;
|
||||
std::shared_ptr<rocksdb::Statistics> statistics_;
|
||||
|
|
|
@ -679,7 +679,7 @@ TEST(Buffers, CyclicBufferSimple) {
|
|||
auto data = td::rand_string('a', 'z', 100001);
|
||||
td::Slice write_slice = data;
|
||||
td::Slice read_slice = data;
|
||||
for (size_t i = 1; (int)i < options.count; i++) {
|
||||
for (size_t i = 1; i < options.count; i++) {
|
||||
ASSERT_EQ((i - 1) * options.chunk_size, reader.reader_size());
|
||||
ASSERT_EQ((i - 1) * options.chunk_size, writer.writer_size());
|
||||
auto slice = writer.prepare_write();
|
||||
|
|
|
@ -170,7 +170,11 @@ TEST(KeyValue, Bench) {
|
|||
TEST(KeyValue, Stress) {
|
||||
return;
|
||||
td::Slice db_name = "testdb";
|
||||
td::RocksDb::destroy(db_name).ignore();
|
||||
size_t N = 20;
|
||||
auto db_name_i = [&](size_t i) { return PSTRING() << db_name << i; };
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
td::RocksDb::destroy(db_name_i(i)).ignore();
|
||||
}
|
||||
|
||||
td::actor::Scheduler scheduler({6});
|
||||
auto watcher = td::create_shared_destructor([] { td::actor::SchedulerContext::get()->stop(); });
|
||||
|
@ -186,9 +190,13 @@ TEST(KeyValue, Stress) {
|
|||
void tear_down() override {
|
||||
}
|
||||
void loop() override {
|
||||
if (stat_at_.is_in_past()) {
|
||||
stat_at_ = td::Timestamp::in(10);
|
||||
LOG(ERROR) << db_->stats();
|
||||
}
|
||||
if (!kv_) {
|
||||
kv_ = td::KeyValueAsync<td::UInt128, td::BufferSlice>(
|
||||
std::make_unique<td::RocksDb>(td::RocksDb::open(db_name_).move_as_ok()));
|
||||
db_ = std::make_shared<td::RocksDb>(td::RocksDb::open(db_name_).move_as_ok());
|
||||
kv_ = td::KeyValueAsync<td::UInt128, td::BufferSlice>(db_);
|
||||
set_start_at_ = td::Timestamp::now();
|
||||
}
|
||||
if (next_set_ && next_set_.is_in_past()) {
|
||||
|
@ -207,6 +215,7 @@ TEST(KeyValue, Stress) {
|
|||
|
||||
private:
|
||||
std::shared_ptr<td::Destructor> watcher_;
|
||||
std::shared_ptr<td::RocksDb> db_;
|
||||
td::optional<td::KeyValueAsync<td::UInt128, td::BufferSlice>> kv_;
|
||||
std::string db_name_;
|
||||
int left_cnt_ = 1000000000;
|
||||
|
@ -214,6 +223,7 @@ TEST(KeyValue, Stress) {
|
|||
td::Timestamp next_set_ = td::Timestamp::now();
|
||||
td::Timestamp set_start_at_;
|
||||
td::Timestamp set_finish_at_;
|
||||
td::Timestamp stat_at_ = td::Timestamp::in(10);
|
||||
|
||||
void do_set() {
|
||||
td::UInt128 key = td::UInt128::zero();
|
||||
|
@ -236,8 +246,10 @@ TEST(KeyValue, Stress) {
|
|||
}
|
||||
}
|
||||
};
|
||||
scheduler.run_in_context([watcher = std::move(watcher), &db_name]() mutable {
|
||||
td::actor::create_actor<Worker>("Worker", watcher, db_name.str()).release();
|
||||
scheduler.run_in_context([watcher = std::move(watcher), &db_name_i, &N]() mutable {
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
td::actor::create_actor<Worker>("Worker", watcher, db_name_i(i)).release();
|
||||
}
|
||||
watcher.reset();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue