-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: remove in-memory SerializedModuleCache #136
base: main
Are you sure you want to change the base?
Conversation
…rialized modules to filesystem into ModuleCache
@@ -118,4 +168,56 @@ mod tests { | |||
assert_eq!(*deserialized_cached_module, *module); | |||
} | |||
} | |||
|
|||
#[test] | |||
fn cache_get_from_fs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test that:
- builds module, serializes, writes to filesystem at expected path
- gets module from ModuleCache
- asserts that module now exists in deserialized in-memory path
} | ||
|
||
#[test] | ||
fn cache_save_to_memory_only() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache a module to in-memory deserialized module cache only
|
||
#[test] | ||
fn cache_test() { | ||
fn cache_save_to_memory_and_fs() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache a module to both filesystem and in-memory deserialized module caches
@@ -266,109 +231,99 @@ impl SerializedModuleCache { | |||
// instantiated with fresh stores free from state. Instance | |||
// creation is highly performant which makes caching of instances | |||
// and stores unnecessary. | |||
let module = unsafe { | |||
// | |||
// See https://github.com/wasmerio/wasmer/issues/4377 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jost-s can you confirm that this is the relevant issue?
}; | ||
self.put_item(key, Arc::new(serialized_module.clone())); | ||
// Save serialized module to filesystem cache | ||
self.add_to_filesystem_cache(key, serialized_module)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we first save to filesystem, then add to in-memory cache. Thus if the process is interrupted after saving to the filesystem, it will still be added to the in-memory cache next time it is fetched.
But this made me realize -- if the process is interrupted while saving to the filesystem and the file is corrupted then it will error every time we try to deserialize it. I made an issue to address this: #137
Resolves holochain/holochain#3536
The diff is a hard to read but I think the code is more legible. Let me know if you think of more tests that would be good to add.