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 logs instead of timing to determine if the package cache was hit #3967

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/wasi/src/runtime/package_loader/builtin_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl BuiltinPackageLoader {

if let Some(cached) = self.fs.lookup(hash).await? {
// Note: We want to propagate it to the in-memory cache, too
tracing::debug!("Copying from the filesystem cache to the in-memory cache",);
tracing::debug!("Copying from the filesystem cache to the in-memory cache");
self.in_memory.save(&cached, *hash);
return Ok(Some(cached));
}
Expand Down
21 changes: 13 additions & 8 deletions tests/integration/cli/tests/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,24 @@ fn run_test_caching_works_for_packages_with_versions() {

assert.stdout("hello\n");

let time = std::time::Instant::now();

let assert = Command::new(get_wasmer_path())
.arg("python/[email protected]")
.arg(format!("--mapdir=/app:{}", ASSET_PATH))
.arg("/app/test.py")
.assert()
.success();

assert.stdout("hello\n");
.env(
"RUST_LOG",
"wasmer_wasix::runtime::package_loader::builtin_loader=debug",
)
.assert();

// package should be cached
assert!(std::time::Instant::now() - time < std::time::Duration::from_secs(1));
assert
.success()
// it should have ran like normal
.stdout("hello\n")
// we hit the cache while fetching the package
.stderr(contains(
"builtin_loader: Cache hit! pkg.name=\"python\" pkg.version=0.1.0",
));
}

// FIXME: Re-enable. See https://github.com/wasmerio/wasmer/issues/3717
Expand Down