Skip to content
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

Module caching initial concept issue #169

Closed
damip opened this issue Nov 22, 2022 · 1 comment
Closed

Module caching initial concept issue #169

damip opened this issue Nov 22, 2022 · 1 comment
Assignees

Comments

@damip
Copy link
Member

damip commented Nov 22, 2022

Wasmer compilation takes time. We can improve things by saving the compiled modules in cache.

Let's make a finite-size cache of compiled Wasmer modules indexed by the bytecode hash:

  • as Module objects when in RAM => they are ready to be instantiated
  • in the future, if the RAM storage is not enough, also store as Serialized Modules on disk => they can then be deserialized, added to RAM cache, instantiated and executed

When a block containing uncached bytecodes needs to be exectued, threads should be launched to compile them all in parallel, put them in cache, and instanciate + execute them as they become ready.
When new bytecode is inserted/changed in the ledger, a separate thread should be launched to cache it as well, in order to be ready for its future execution.

Isn't hashing the bytecode too long ? => 127µs for 500kilobytes, 25µs for 100kilobytes
Improvement idea: in the bytecode field of the ledger, store the following:

  • a varint u32 VM version/variant number
  • the hash of the version + bytecode (to be updated every time the bytecode changes)
  • the actual bytecode

That way, the module hash is readily available.

@AurelienFT AurelienFT assigned AurelienFT and Eitu33 and unassigned AurelienFT Dec 27, 2022
@Eitu33 Eitu33 changed the title Module caching Module caching initial concept issue Feb 1, 2023
@AurelienFT
Copy link
Contributor

Closing as it's the first version the second version and his design can be found in massalabs/massa#3488

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

No branches or pull requests

3 participants