spinkube / containerd-shim-spin

A ContainerD shim for running Spin Applications.
Apache License 2.0
57 stars 13 forks source link

Redundant file copies for every pod start #40

Open radu-matei opened 6 months ago

radu-matei commented 6 months ago

The startup time for a Spin application distributed as an OCI artifact is affected by several copies of the Wasm components and static assets on disk.

Since this time is spent on every pod start, my assumption is that it affects performance, in particular for applications with a higher number of components and assets.

I'd like to see if we can improve this, potentially by implementing a Spin application loader that directly uses the runwasi list of WasmLayers and skips all the copies.

jsturtevant commented 6 months ago

Another idea along these lines that I had would be to implement an In-memory cache provider that would skip the write to disk as well.

rajatjindal commented 3 months ago

Hi @jsturtevant, just trying to understand your suggestion here. are you saying to have these static assets loaded in memory and serve from there?

jsturtevant commented 3 months ago

Yes, they are already in memory via the WasmLayers struct. There is a concept of a Cache in Spin which currently reads from a specific folder, which is why we write the files to disk. I thought we might be able to create a new implementation of the cache that reads from the pre-loaded memory instead of writing to disk then reading it again. This would speed things up a bit by avoiding the IO but may not be ideal in all cases when the there are lots of files.