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(check): use v8 code cache for extension sources in deno check #28089

Merged
merged 3 commits into from
Feb 12, 2025
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
6 changes: 6 additions & 0 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,7 @@ Unless --reload is specified, this command will not re-download already cached d
)
.defer(|cmd| {
compile_args_without_check_args(cmd)
.arg(no_code_cache_arg())
.arg(
Arg::new("all")
.long("all")
Expand Down Expand Up @@ -4572,6 +4573,7 @@ fn check_parse(
doc: matches.get_flag("doc"),
doc_only: matches.get_flag("doc-only"),
});
flags.code_cache_enabled = !matches.get_flag("no-code-cache");
allow_import_parse(flags, matches);
Ok(())
}
Expand Down Expand Up @@ -7412,6 +7414,7 @@ mod tests {
doc_only: false,
}),
type_check_mode: TypeCheckMode::Local,
code_cache_enabled: true,
..Flags::default()
}
);
Expand All @@ -7426,6 +7429,7 @@ mod tests {
doc_only: false,
}),
type_check_mode: TypeCheckMode::Local,
code_cache_enabled: true,
..Flags::default()
}
);
Expand All @@ -7440,6 +7444,7 @@ mod tests {
doc_only: true,
}),
type_check_mode: TypeCheckMode::Local,
code_cache_enabled: true,
..Flags::default()
}
);
Expand Down Expand Up @@ -7468,6 +7473,7 @@ mod tests {
doc_only: false,
}),
type_check_mode: TypeCheckMode::All,
code_cache_enabled: true,
..Flags::default()
}
);
Expand Down
5 changes: 5 additions & 0 deletions cli/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,11 @@ impl CliFactory {
self.npm_resolver().await?.clone(),
self.sys(),
self.tsconfig_resolver()?.clone(),
if cli_options.code_cache_enabled() {
Some(self.code_cache()?.clone())
} else {
None
},
)))
})
.await
Expand Down
40 changes: 26 additions & 14 deletions cli/tools/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub struct TypeChecker {
npm_resolver: CliNpmResolver,
sys: CliSys,
tsconfig_resolver: Arc<TsConfigResolver>,
code_cache: Option<Arc<crate::cache::CodeCache>>,
}

impl TypeChecker {
Expand All @@ -162,6 +163,7 @@ impl TypeChecker {
npm_resolver: CliNpmResolver,
sys: CliSys,
tsconfig_resolver: Arc<TsConfigResolver>,
code_cache: Option<Arc<crate::cache::CodeCache>>,
) -> Self {
Self {
caches,
Expand All @@ -173,6 +175,7 @@ impl TypeChecker {
npm_resolver,
sys,
tsconfig_resolver,
code_cache,
}
}

Expand Down Expand Up @@ -283,6 +286,7 @@ impl TypeChecker {
grouped_roots,
options,
seen_diagnotics: Default::default(),
code_cache: self.code_cache.clone(),
}),
))
}
Expand Down Expand Up @@ -433,6 +437,7 @@ struct DiagnosticsByFolderRealIterator<'a> {
npm_check_state_hash: Option<u64>,
seen_diagnotics: HashSet<String>,
options: CheckOptions,
code_cache: Option<Arc<crate::cache::CodeCache>>,
}

impl<'a> Iterator for DiagnosticsByFolderRealIterator<'a> {
Expand Down Expand Up @@ -550,20 +555,27 @@ impl<'a> DiagnosticsByFolderRealIterator<'a> {
let tsconfig_hash_data = FastInsecureHasher::new_deno_versioned()
.write_hashable(ts_config)
.finish();
let response = tsc::exec(tsc::Request {
config: ts_config.clone(),
debug: self.log_level == Some(log::Level::Debug),
graph: self.graph.clone(),
hash_data: tsconfig_hash_data,
maybe_npm: Some(tsc::RequestNpmState {
cjs_tracker: self.cjs_tracker.clone(),
node_resolver: self.node_resolver.clone(),
npm_resolver: self.npm_resolver.clone(),
}),
maybe_tsbuildinfo,
root_names,
check_mode: self.options.type_check_mode,
})?;
let code_cache = self.code_cache.as_ref().map(|c| {
let c: Arc<dyn deno_runtime::code_cache::CodeCache> = c.clone();
c
});
let response = tsc::exec(
tsc::Request {
config: ts_config.clone(),
debug: self.log_level == Some(log::Level::Debug),
graph: self.graph.clone(),
hash_data: tsconfig_hash_data,
maybe_npm: Some(tsc::RequestNpmState {
cjs_tracker: self.cjs_tracker.clone(),
node_resolver: self.node_resolver.clone(),
npm_resolver: self.npm_resolver.clone(),
}),
maybe_tsbuildinfo,
root_names,
check_mode: self.options.type_check_mode,
},
code_cache,
)?;

let mut response_diagnostics = response.diagnostics.filter(|d| {
self.should_include_diagnostic(self.options.type_check_mode, d)
Expand Down
Loading
Loading