mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
perf: disable fetching graph cache info except for deno info
(#17698)
This commit is contained in:
parent
ef9b66950f
commit
8b0a612e30
2 changed files with 17 additions and 1 deletions
12
cli/cache/mod.rs
vendored
12
cli/cache/mod.rs
vendored
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue