mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Remove rocksdb usage from fift (#1064)
* add github action for macOS 14 (arm64, M1) * add github action (portable) for macOS 14 (arm64, M1) * rename macOS arm64 output artifact * Update libsodium on windows * Compile libsodium * Update build-windows.bat * use upgraded libsodium 1.0.20; use compiled static libsodium for Windows instead of precompiled; * revert libsodium 1.0.20; use compiled static libsodium for Windows instead of precompiled; * use upgraded libsodium 1.0.20; use compiled static libsodium for Windows instead of precompiled; * fix libsodium version 1.0.19; use compiled static libsodium for Windows instead of precompiled; * try 1.0.20 libsodium precompiled on github * try 1.0.18 libsodium precompiled on github * try windows build on win server 2019 * and use PlatformToolset=v142 * use cmake -G "Visual Studio 16 2019" * fix path to msvc 2019 on github * separate github windows build on win server 2019 and build on win server 2022 * Update assembly/native/build-windows-2019.bat add retry mechanism Co-authored-by: Dr. Awesome Doge <doge@ton.org> * add test-emulator; disable test groovy pipeline * trigger all gh actions * fix win build * call test-emulator * remove usage of rocksdb in fift-lib * put back some code for test-db * fix test-emulator * remove usage of db-path parameter in fift * some func adjustments * fix checkout of openssl in fift-func-wasm-build-ubuntu.sh * typo * improve wasm build script for quicker turn around * remove sENVIRONMENT=web,worker for funcfiftlib. will be added later. * remove sENVIRONMENT=web,worker for funcfiftlib. will be added later. * remove sENVIRONMENT=web,worker for funcfiftlib. will be added later. * minor adjustments * remove -d option in fift; optimize fift-lib usage * reduce tondb usage --------- Co-authored-by: neodiX <neodix42@ton.org> Co-authored-by: Dr. Awesome Doge <doge@ton.org> Co-authored-by: ms <dungeon666master@protonmail.com>
This commit is contained in:
parent
28f9a9b159
commit
679e6be294
12 changed files with 122 additions and 328 deletions
|
@ -43,8 +43,6 @@
|
|||
#include "vm/box.hpp"
|
||||
#include "vm/atom.h"
|
||||
|
||||
#include "vm/db/TonDb.h" // only for interpret_db_run_vm{,_parallel}
|
||||
|
||||
#include "block/block.h"
|
||||
#include "common/global-version.h"
|
||||
|
||||
|
@ -2721,114 +2719,6 @@ void interpret_vmop_dump(vm::Stack& stack) {
|
|||
stack.push_string(std::move(dump));
|
||||
}
|
||||
|
||||
void do_interpret_db_run_vm_parallel(std::ostream* stream, vm::Stack& stack, vm::TonDb* ton_db_ptr, int threads_n,
|
||||
int tasks_n) {
|
||||
if (!ton_db_ptr || !*ton_db_ptr) {
|
||||
throw vm::VmError{vm::Excno::fatal, "Ton database is not available"};
|
||||
}
|
||||
auto& ton_db = *ton_db_ptr;
|
||||
auto txn = ton_db->begin_transaction();
|
||||
auto txn_abort = td::ScopeExit() + [&] { ton_db->abort_transaction(std::move(txn)); };
|
||||
|
||||
struct Task {
|
||||
vm::Ref<vm::CellSlice> code;
|
||||
vm::SmartContractDb smart;
|
||||
td::optional<vm::SmartContractDiff> diff;
|
||||
td::unique_ptr<td::Guard> guard;
|
||||
Ref<vm::Stack> stack;
|
||||
int res{0};
|
||||
Ref<vm::Cell> data;
|
||||
std::string log;
|
||||
};
|
||||
std::vector<Task> tasks(tasks_n);
|
||||
std::vector<td::thread> threads(threads_n);
|
||||
|
||||
for (auto& task : tasks) {
|
||||
task.code = stack.pop_cellslice();
|
||||
auto smart_hash = td::serialize(stack.pop_smallint_range(1000000000));
|
||||
task.smart = txn->begin_smartcontract(smart_hash);
|
||||
task.guard = td::create_lambda_guard([&] { txn->abort_smartcontract(std::move(task.smart)); });
|
||||
auto argsn = stack.pop_smallint_range(100);
|
||||
task.stack = stack.split_top(argsn);
|
||||
}
|
||||
|
||||
std::atomic<int> next_task_i{0};
|
||||
auto run_tasks = [&] {
|
||||
while (true) {
|
||||
auto task_i = next_task_i++;
|
||||
if (task_i >= tasks_n) {
|
||||
break;
|
||||
}
|
||||
auto& task = tasks[task_i];
|
||||
auto data = task.smart->get_root();
|
||||
|
||||
StringLogger logger;
|
||||
vm::VmLog log = create_vm_log(stream ? &logger : nullptr);
|
||||
|
||||
task.res = vm::run_vm_code(task.code, task.stack, 3, &data, std::move(log));
|
||||
task.smart->set_root(data);
|
||||
task.diff = vm::SmartContractDiff(std::move(task.smart));
|
||||
task.data = std::move(data);
|
||||
task.log = std::move(logger.res);
|
||||
}
|
||||
};
|
||||
|
||||
td::Timer timer;
|
||||
for (auto& thread : threads) {
|
||||
thread = td::thread(run_tasks);
|
||||
}
|
||||
run_tasks();
|
||||
for (auto& thread : threads) {
|
||||
thread.join();
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
int id = 0;
|
||||
for (auto& task : tasks) {
|
||||
id++;
|
||||
*stream << "Task #" << id << " vm_log begin" << std::endl;
|
||||
*stream << task.log;
|
||||
*stream << "Task #" << id << " vm_log end" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(ERROR) << timer;
|
||||
timer = {};
|
||||
|
||||
for (auto& task : tasks) {
|
||||
auto retn = task.stack.write().pop_smallint_range(100, -1);
|
||||
if (retn == -1) {
|
||||
retn = task.stack->depth();
|
||||
}
|
||||
stack.push_from_stack(std::move(*task.stack), retn);
|
||||
stack.push_smallint(task.res);
|
||||
stack.push_cell(std::move(task.data));
|
||||
task.guard->dismiss();
|
||||
if (task.diff) {
|
||||
txn->commit_smartcontract(std::move(task.diff.value()));
|
||||
} else {
|
||||
txn->commit_smartcontract(std::move(task.smart));
|
||||
}
|
||||
}
|
||||
LOG(ERROR) << timer;
|
||||
timer = {};
|
||||
|
||||
txn_abort.dismiss();
|
||||
ton_db->commit_transaction(std::move(txn));
|
||||
timer = {};
|
||||
LOG(INFO) << "TonDB stats: \n" << ton_db->stats();
|
||||
}
|
||||
|
||||
void interpret_db_run_vm(IntCtx& ctx) {
|
||||
do_interpret_db_run_vm_parallel(ctx.error_stream, ctx.stack, ctx.ton_db, 0, 1);
|
||||
}
|
||||
|
||||
void interpret_db_run_vm_parallel(IntCtx& ctx) {
|
||||
auto threads_n = ctx.stack.pop_smallint_range(32, 0);
|
||||
auto tasks_n = ctx.stack.pop_smallint_range(1000000000);
|
||||
do_interpret_db_run_vm_parallel(ctx.error_stream, ctx.stack, ctx.ton_db, threads_n, tasks_n);
|
||||
}
|
||||
|
||||
void interpret_store_vm_cont(vm::Stack& stack) {
|
||||
auto vmcont = stack.pop_cont();
|
||||
auto cb = stack.pop_builder();
|
||||
|
@ -3518,8 +3408,6 @@ void init_words_vm(Dictionary& d, bool enable_debug) {
|
|||
// d.def_ctx_word("runvmcode ", std::bind(interpret_run_vm, _1, 0x40));
|
||||
// d.def_ctx_word("runvm ", std::bind(interpret_run_vm, _1, 0x45));
|
||||
d.def_ctx_word("runvmx ", std::bind(interpret_run_vm, _1, -1));
|
||||
d.def_ctx_word("dbrunvm ", interpret_db_run_vm);
|
||||
d.def_ctx_word("dbrunvm-parallel ", interpret_db_run_vm_parallel);
|
||||
d.def_stack_word("vmcont, ", interpret_store_vm_cont);
|
||||
d.def_stack_word("vmcont@ ", interpret_fetch_vm_cont);
|
||||
d.def_stack_word("(vmoplen) ", interpret_vmop_len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue