-
Notifications
You must be signed in to change notification settings - Fork 33
SC: Implement EOSVM-OC support for sync calls #1378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| int64_t(*call_func)(uint64_t, uint64_t, uint32_t) = (int64_t(*)(uint64_t, uint64_t, uint32_t))(cb->running_code_base + *code.call_offset); | ||
| call_func(context.get_sender().to_uint64_t(), context.get_receiver().to_uint64_t(), static_cast<uint32_t>(static_cast<eosio::chain::sync_call_context&>(context).data.size())); | ||
| } else { | ||
| status = eosio::chain::execution_status::receiver_not_support_sync_call; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to check sync_call entry point signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo we ought to not need to. The validity of the sync_call export doesn't need to be tracked and checked by each individual wasm runtime in a bespoke way -- we ought to be able to that in a single common location.
Unfortunately it seems we cannot use the instantiation cache as is, since OC can bypass that.
We could use the code index but perhaps that is considered improper. (that said, the code index already tracks non-protocol aspects of code like a reference count!)
I don't have other ideas at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an issue #1392
…which start 4 nodes (controllers) in a single test process
…uce memory usage by 8 nodes to 6 nodes so tests can be run
SC: save & restore GS register to allow nested EOS VM OC executors
| : cc(data_dir, eosvmoc_config, db), exec(cc), mem(wasm_constraints::maximum_linear_memory/wasm_constraints::wasm_page_size) { | ||
| : cc(data_dir, eosvmoc_config, db) { | ||
| for (auto i = 0; i < 4; ++i) { | ||
| exec.emplace_back(std::make_unique<eosvmoc::executor>(cc)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally every executor in a thread shares the same resources. Not really sure best approach -- an executor could expose a clone() call to return a new executor sharing the same resources, or maybe there needs to be more refactoring such as a class that holds executor's resources that is just passed to a non-member execute() call (having trouble coming up with names for these things off hand).
I don't think we need to do this executor improvement immediately though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an improvement issue for this #1394
| thread_local std::unique_ptr<eosvmoc::memory> eosvmoc_runtime::mem_thread_local{}; | ||
| thread_local std::vector<std::unique_ptr<eosvmoc::executor>> eosvmoc_runtime::exec_thread_local{}; | ||
| thread_local std::vector<std::unique_ptr<eosvmoc::memory>> eosvmoc_runtime::mem_thread_local{}; | ||
| thread_local uint32_t eosvmoc_runtime::ro_thread_index = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need the final stack approach before considering ready for review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to make the wasm allocator pool as a templated class and use it here. Will retarget this PR on
#1346 to get it going.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
unittests/sync_call_tests.cpp
Outdated
| BOOST_REQUIRE_NO_THROW(t.push_action("caller"_n, "callwithinpt"_n, "caller"_n, mvo()("input", 3))); | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to get the memory situation handled before ready for full review.
Currently the main thread memory is created with full 528 slices, and the RO thread memories are created with 10 slices.
For the simplest approach to get it floating, I'd suggest maybe just making every sync call use memory with a single slice.
Ideally we do something more complex where shallow sync calls get more slices than deeper sync calls (under the premise that shallow calls are more frequent). But we'd need to work out the math on this first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with a single slice for now. Created an issue #1393.
| size_t code_begin; | ||
| eosvmoc_optional_offset_or_import_t start; | ||
| unsigned apply_offset; | ||
| std::optional<unsigned> call_offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might cause a problem for existing code caches that may or may not be properly handled on start up. Changing the code_descriptor layout probably requires indicating something higher up (like at the header) that the format has been changed and the cache must be destroyed and recreated at start up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the new version of current_codegen_version (line 48 below) be sufficient?
| static constexpr uint8_t current_codegen_version = 3; |
spring/libraries/chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp
Lines 343 to 347 in d60ed85
| if(cd.codegen_version != current_codegen_version) { | |
| allocator->deallocate(code_mapping + cd.code_begin); | |
| allocator->deallocate(code_mapping + cd.initdata_begin); | |
| continue; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I don't believe that will help. The serialized format of code_descriptor has changed, and it isn't versioned. I think you need to change
| static constexpr uint64_t header_id = 0x32434f4d56534f45ULL; //"EOSVMOC2" little endian |
So that the cache file is completely removed and recreated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I missed that.
…ting code cache will be destroyed and recreated at startup
| static constexpr size_t header_size = 512u; | ||
| static constexpr size_t total_header_size = header_offset + header_size; | ||
| static constexpr uint64_t header_id = 0x32434f4d56534f45ULL; //"EOSVMOC2" little endian | ||
| static constexpr uint64_t header_id = 0x33434f4d56534f45ULL; //"EOSVMOC2" little endian |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the comment too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that.
This PR implements
EOSVM-OCsupport for sync calls. It unifiesapply()anddo_sync_call()into a singleexecute(), and in turn unifyingEOSVM/EOSVM-JITandEOSOCprocessing, making code simpler. Considerable refactoring is performed as a result.In OC implementation itself, most changes are around
sync_callentry point handling.Resolves #1043.