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

Use SyncLruCache instead of cached for in-memory cache #5714

Closed
5 tasks
matklad opened this issue Dec 8, 2021 · 3 comments
Closed
5 tasks

Use SyncLruCache instead of cached for in-memory cache #5714

matklad opened this issue Dec 8, 2021 · 3 comments
Labels
C-housekeeping Category: Refactoring, cleanups, code quality T-contract-runtime Team: issues relevant to the contract runtime team

Comments

@matklad
Copy link
Contributor

matklad commented Dec 8, 2021

In #5259, we've started to replace usages of cached crate with lru, which has nicer, smaller API and is faster. We should use that to implement our global in-memory cache:

#[cfg(not(feature = "no_cache"))]
cached_key! {
MODULES: SizedCache<CryptoHash, Result<Result<wasmer::Module, CompilationError>, CacheError>>
= SizedCache::with_size(CACHE_SIZE);
Key = {
key
};
fn memcache_compile_module_cached_wasmer2(
key: CryptoHash,
wasm_code: &[u8],
config: &VMConfig,
cache: Option<&dyn CompiledContractCache>,
store: &wasmer::Store
) -> Result<Result<wasmer::Module, CompilationError>, CacheError> = {
compile_module_cached_wasmer2_impl(key, wasm_code, config, cache, store)
}
}

Steps:

@matklad matklad added C-housekeeping Category: Refactoring, cleanups, code quality T-contract-runtime Team: issues relevant to the contract runtime team labels Dec 8, 2021
@matklad
Copy link
Contributor Author

matklad commented Dec 15, 2021

Mostly fixed by #5512, except the "change caching logic to not cache catastrophic errors." bit

@pmnoxx
Copy link
Contributor

pmnoxx commented Dec 20, 2021

@matklad Resolves 3 #5907

  • Remove Clone bound from CacheError

What is the Clone that you are referring to

  • ``
  • Add underlying io::Error to the CacheError

Which io::error?

@matklad
Copy link
Contributor Author

matklad commented Dec 20, 2021

will be fixed by #5856

@matklad matklad closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-housekeeping Category: Refactoring, cleanups, code quality T-contract-runtime Team: issues relevant to the contract runtime team
Projects
None yet
Development

No branches or pull requests

2 participants