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

perf: disable fetching graph cache info except for deno info #17698

Merged
merged 1 commit into from
Feb 9, 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
12 changes: 12 additions & 0 deletions cli/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct FetchCacher {
dynamic_permissions: PermissionsContainer,
file_fetcher: Arc<FileFetcher>,
root_permissions: PermissionsContainer,
cache_info_enabled: bool,
}

impl FetchCacher {
Expand All @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion cli/tools/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down