summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-08 19:45:04 -0500
committerGitHub <noreply@github.com>2023-02-08 19:45:04 -0500
commit8b0a612e308d593205690729e23dafe0bce02eb9 (patch)
treeb4e29cef4e8802511a0911c7ed3448f2672c2706
parentef9b66950f4557003bc7d4246da838545466a518 (diff)
perf: disable fetching graph cache info except for `deno info` (#17698)
-rw-r--r--cli/cache/mod.rs12
-rw-r--r--cli/tools/info.rs6
2 files changed, 17 insertions, 1 deletions
diff --git a/cli/cache/mod.rs b/cli/cache/mod.rs
index c8fcaa223..9b6d14a5c 100644
--- a/cli/cache/mod.rs
+++ b/cli/cache/mod.rs
@@ -45,6 +45,7 @@ pub struct FetchCacher {
dynamic_permissions: PermissionsContainer,
file_fetcher: Arc<FileFetcher>,
root_permissions: PermissionsContainer,
+ cache_info_enabled: bool,
}
impl FetchCacher {
@@ -59,12 +60,23 @@ impl FetchCacher {
dynamic_permissions,
file_fetcher,
root_permissions,
+ cache_info_enabled: false,
}
}
+
+ /// The cache information takes a bit of time to fetch and it's
+ /// not always necessary. It should only be enabled for deno info.
+ pub fn enable_loading_cache_info(&mut self) {
+ self.cache_info_enabled = true;
+ }
}
impl Loader for FetchCacher {
fn get_cache_info(&self, specifier: &ModuleSpecifier) -> Option<CacheInfo> {
+ if !self.cache_info_enabled {
+ return None;
+ }
+
if matches!(specifier.scheme(), "npm" | "node") {
return None;
}
diff --git a/cli/tools/info.rs b/cli/tools/info.rs
index f3de922c6..090289e5d 100644
--- a/cli/tools/info.rs
+++ b/cli/tools/info.rs
@@ -33,7 +33,11 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> {
let ps = ProcState::build(flags).await?;
if let Some(specifier) = info_flags.file {
let specifier = resolve_url_or_path(&specifier)?;
- let graph = ps.create_graph(vec![specifier]).await?;
+ let mut loader = ps.create_graph_loader();
+ loader.enable_loading_cache_info(); // for displaying the cache information
+ let graph = ps
+ .create_graph_with_loader(vec![specifier], &mut loader)
+ .await?;
if info_flags.json {
let mut json_graph = json!(graph);