eosvm 执行引擎三种模式

区块链WebAssembly执行的强大组件三重奏

 

  • EOS VM解释器是一个WebAssembly解释器,提供了极快的解析/加载,确定性和高效的时限执行。从头开始设计解释器,使我们能够为将来对智能合约的调试支持腾出空间。
  • EOS VM即时(JIT)编译器是WebAssembly编译器,它采用WASM并即时生成本机代码。与WABT,Binaryen和EOS VM解释器之类的解释器相比,该体系结构能够非常快速地执行WASM智能合约,并提供显着的性能优势。这种JIT解决方案的绝对速度使我们能够在区块链上使用它,而无需其他解决方案进行较长的区块编译时间。
  • EOS VM优化编译器是EOS VM的第三个组件,它使用了利用多遍编译架构的专用编译器框架(LLVM)。通过优化编译器生成的本机代码通常比在WABT,Binaryen,EOS VM解释器和EOS VM JIT中执行的相同代码快一个数量级。最重要的是,它甚至比现有的WAVM引擎还要快,但是与WAVM不同,它可以利用我们的分层设计在区块链上安全使用。

极快的执行力

 

我们针对不同组件的基准测试在我们的测试环境中实现了以下性能增强:

1、EOS力学基准来自EOSIO社区编写的基准,并在AWS z1d.metal实例上运行。 2、重播基准测试比较了EOSIO系统提供的重播功能以在指定的WASM引擎上完成相同的重播并在AWS z1d.metal实例上执行所需的时间。

以上性能基准显示了各种EOS VM组件的相对优势。 EOSIO 2.0将EOS VM JIT作为大多数智能合约执行的一线编译器,而EOS VM Optimized Compiler尝试在后台编译相同的智能合约,并将其部署以在链上以极快的速度随后执行。这种分层架构使EOSIO 2.0能够利用快速启动和优化的智能合约代码编译功能。

EOS VM及其组件也可以高度自定义,因此开发人员可以以适合其所需功能的特定方式实现其各个方面。通过参考GitHub上的EOS VM存储库了解更多信息。

 

EOS VM: New High Performance WASM Runtimes (#7974, #7975)

Three new WASM runtimes are available in this release: EOS VM Interpreter, EOS VM Just In Time Compiler (JIT), and EOS VM Optimized Compiler.

EOS VM Interpreter is a low latency interpreter and is included to enable future support for smart contract debuggers. EOS VM JIT is a low latency single pass compiler for x86_64 platforms. To use EOS VM Interpreter or EOS VM JIT, set the wasm-runtime to either eos-vm or eos-vm-jit respectively

EOS VM Optimized Compiler is a high performance WASM tier-up runtime available on the x86_64 Linux platform that works in conjunction with the configured baseline runtime (such as EOS VM JIT). When enabled via eos-vm-oc-enable, actions on a contract are initially dispatched to the baseline runtime while EOS VM Optimized Compiler does an optimized compilation in the background. Up to the configured eos-vm-oc-compile-threads compilations can be ongoing simultaneously. Once the background compilation is complete, actions on that contract will then be run with the optimized compiled code from then on. This optimized compile can take a handful of seconds but since it is performed in the background it does not cause delays. Optimized compilations are also saved to a new data file (code_cache.bin in the data directory) so when restarting nodeos there is no need to recompile previously compiled contracts.

None of the EOS VM runtimes require a replay nor activation of any consensus protocol upgrades. They can be switched between (including enabling and disabling EOS VM Optimized Compiler) at will.

At this time, block producers should consider all running EOS VM JIT as the WASM runtime on their block producing nodes. Other non-producing nodes should feel free to use the faster EOS VM Optimized Compiler runtime instead.

posted @ 2021-12-21 15:54  元几科技  阅读(135)  评论(0编辑  收藏  举报