Stream: wasmtime

Topic: refactoring module caching logic


view this post on Zulip Yury Delendik (Jul 22 2020 at 22:24):

Since we can extract compilation artifacts, we can use them for caching. Opened https://github.com/bytecodealliance/wasmtime/pull/2065 for feedback. This replaces existing per-compiler caching logic.

Currently, it is a responsibility of the compiler to do caching. Moving this logic to the CompiledModule level. This allows early access to all compilation artifacts without analyzing the wasm file...

view this post on Zulip Yury Delendik (Jul 22 2020 at 22:26):

@Alex Crichton I noticed it is stepping on https://github.com/bytecodealliance/wasmtime/pull/2059 a little, I think it makes sense to wait for your PR to land first

This commit is a change to cranelift-wasm to validate each function body as it is translated. Additionally top-level module translation functions will perform module validation. This commit builds ...

view this post on Zulip Alex Crichton (Jul 22 2020 at 22:33):

Nice! I'm fine landing in whatever order, it'll be nice to use the same caching logic!

view this post on Zulip Yury Delendik (Jul 23 2020 at 14:33):

by "caching logic", I assume, you mean the stuff coded in crates/environ/src/cache and not what it stored in cache entry?

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:01):

uh, basically what's stored

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:01):

where now we don't have two ways to serialize and two different deserialization phases

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:02):

/me is confused a little

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:03):

let's setup a call or something to talk about plans

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:08):

so we are saving only code (and some compilation leftovers) in the cache

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:09):

I'm proposing to save everything/ In addition to above, that includes transformed DWARF, Module, data.

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:10):

So serialize, theoretically will equal to cache save

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:10):

oh yeah that makes sense to me

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:10):

At this moment it is not

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:11):

I was looking at the cache stuff recently and I'm really happy to move it higher up

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:11):

it makes a lot more sense to just hash the entire wasm blob

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:11):

rather than trying to hash lots of individual pices after parsing

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:12):

okay, so I just want to make sure I'm on right track with the PR

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:12):

oh I think you definitely are

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:12):

I looked it over last night and it looked near-perfect to me

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:12):

I remember I had a minor comment somewhere but I gotta read it again to figure out where

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:12):

some people may argue that there is no need to save everything since we provide some (meta)data in wasm bytes

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:13):

oh?

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:13):

e.g. we could restore Module for wasm bytes by re-parsing it, so its data

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:14):

but I'm thinking it is additional effort in validation

view this post on Zulip Yury Delendik (Jul 23 2020 at 15:16):

anyway there are plenty of optimizations that can be done

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:22):

@Yury Delendik sorry I'm not sure I'm understanding what you're saying

view this post on Zulip Alex Crichton (Jul 23 2020 at 15:22):

but it's ok, I'm still thinking the current PR is what we want

view this post on Zulip Till Schneidereit (Jul 23 2020 at 16:54):

we could restore Module for wasm bytes by re-parsing it, so its data
I think we really shouldn't require reparsing the wasm file. There are scenarios in which you'd want to delete the input file after compilation, and directly use the hash to identify the cache entry


Last updated: Dec 23 2024 at 14:03 UTC