Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Refactor building of ScillaJIT object #24

Closed
vaivaswatha opened this issue May 27, 2021 · 1 comment · Fixed by #29
Closed

Refactor building of ScillaJIT object #24

vaivaswatha opened this issue May 27, 2021 · 1 comment · Fixed by #29

Comments

@vaivaswatha
Copy link
Contributor

On release builds, creating a ScillaJIT object takes ~10ms, which an actual message execution takes < 1ms.

While one solution is to cache ScillaJIT objects, separately created for each popular contract and reuse them, it is better to see if its creation can be refactored so that multiple contracts can use the same ScillaJIT object. Note that all Scilla allocated memory is freed after each message execution / deployment anyway.

The main challenge is that different Scilla modules have same named identifiers in them, so LLJIT will have trouble resolving names when multiple of these object files are loaded.

@vaivaswatha
Copy link
Contributor Author

vaivaswatha commented Jun 11, 2021

Turned out that the culprit for ~10ms ScillaJIT objection creation time was creating the Secp256k1 context. This is now fixed by having a single global context (not thread-safe).

Also experiments revealed that the object file generated by LLVM-JIT can be linked into a shared object (.so) by using clang -shared on it. This .so can then be loaded with dlopen and functions in it invoked. This path has none of the overheads of LLVM JIT creation.

So a good solution is to generate LLVM bitcode binaries in the Scilla-LLVM compiler. Run clang -fPIC -shared on the command line on the bitcode and generate .so. These shared objects can be cached and used directly in the VM. The VM will no longer do any JIT compilation and will not have an LLVM dependence either. It will become a pure run-time library.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant