Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mattyg
Copy link
Member

@mattyg mattyg commented Dec 24, 2024

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.

@@ -118,4 +168,56 @@ mod tests {
assert_eq!(*deserialized_cached_module, *module);
}
}

#[test]
fn cache_get_from_fs() {
Copy link
Member Author

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() {
Copy link
Member Author

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() {
Copy link
Member Author

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
Copy link
Member Author

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?

@mattyg mattyg requested a review from a team December 24, 2024 20:13
};
self.put_item(key, Arc::new(serialized_module.clone()));
// Save serialized module to filesystem cache
self.add_to_filesystem_cache(key, serialized_module)?;
Copy link
Member Author

@mattyg mattyg Dec 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Wasmer] Remove serialized module cache
1 participant