Closed technosophos closed 2 years ago
Would it be possible just to tuck the precompiled module in a case (perhaps now the only case) of a WasmModuleSource
?
Or is it not practical to have an Engine available at the time we would need to precompile them?
We might be able to do that. I'll look tomorrow.
Thinking about this... I don't think there is any reason why we couldn't just load all of the modules once at startup. I mean, this PR could be refined to use an LRU cache so that Wagi could hold LOTS of modules. But that's not really a likely use case right now. So maybe the better approach would be to load all of the modules right at startup.
Closing in favor of #153.
This changes the way Wagi caches modules.
In this version, Wagi compiles the modules once and then caches them in memory. Each subsequent request for that module uses the cached module instead of regenerating the module.
In testing, this dropped the average page load time of Bartholomew from 560ms to 36ms. Tested with siege, too, and saw similar performance gains across both Bartholomew and Fileserver.gr
Note that what we give up here is file-based caching. So if we want to keep that, we might need to rework this a bit.
Signed-off-by: Matt Butcher matt.butcher@fermyon.com