-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Pre-generate runtime metadata, remove from runtime binary? #10057
Description
Following on from #8615, the size of the metadata has increased (because of all the type information). Here are some benchmarks I did during the PR:
#8370 (comment)
#8615 (comment)
#8615 (comment)
There was some discussion #8370 (comment) (/cc @tomusdrw, @apopiak, @bkchr, @dvdplm) about whether it would be worth pre-generating the metadata and storing it somewhere other than in the runtime binary. For the purposes of getting the PR done sooner rather than later, we decided we could handle the larger binary size in the short term.
One solution would be to generate the metadata during build time, which might involve:
- only include metadata when building with
std - compile with
stdand then invoke agenerate_metadatafunction - encode and (optionally) compress the metadata
- calculate the hash of the encoded metadata
- store the hash of the metadata in the runtime wasm, and store the metadata itself somewhere else.
I'm not intimately familiar with the existing build process, but I believe this workflow is not possible for the existing dev chain runtime where the wasm bytes are embedded directly into a constant for the std build.
One alternative might be to include the metadata only in the std build and have the node only allow the state_getMetadata query when running a native runtime, and then do some caching there. Although I think I heard that native runtimes might be deprecated in the future.
So the open questions here are:
- Is it possible to pre-generate the metadata during the build process? (@bkchr)
- Where should we store the metadata once it has been pre-generated?
Linking to #10056, which can be solved by this.