summaryrefslogtreecommitdiff
path: root/cli/cache
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-11-18 15:09:28 -0500
committerGitHub <noreply@github.com>2024-11-18 20:09:28 +0000
commitdd4570ed85888d9659a2eec98437dbd6de4a5799 (patch)
tree0880f06e3b0f51267ad6e1619941dcc07c5c14c6 /cli/cache
parent3ba464dbc40dd2d6bd3f7a1912aa8f0fad95058f (diff)
perf(compile): code cache (#26528)
Adds a lazily created code cache to `deno compile` by default. The code cache is created on first run to a single file in the temp directory and is only written once. After it's been written, the code cache becomes read only on subsequent runs. Only the modules loaded during startup are cached (dynamic imports are not code cached). The code cache can be disabled by compiling with `--no-code-cache`.
Diffstat (limited to 'cli/cache')
-rw-r--r--cli/cache/code_cache.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/cache/code_cache.rs b/cli/cache/code_cache.rs
index abcd0d46a..b1d9ae757 100644
--- a/cli/cache/code_cache.rs
+++ b/cli/cache/code_cache.rs
@@ -1,10 +1,14 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+use std::sync::Arc;
+
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
use deno_runtime::code_cache;
use deno_runtime::deno_webstorage::rusqlite::params;
+use crate::worker::CliCodeCache;
+
use super::cache_db::CacheDB;
use super::cache_db::CacheDBConfiguration;
use super::cache_db::CacheDBHash;
@@ -82,6 +86,12 @@ impl CodeCache {
}
}
+impl CliCodeCache for CodeCache {
+ fn as_code_cache(self: Arc<Self>) -> Arc<dyn code_cache::CodeCache> {
+ self
+ }
+}
+
impl code_cache::CodeCache for CodeCache {
fn get_sync(
&self,