diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-10-01 06:15:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-01 12:15:56 +0200 |
commit | ecfafda9d8ead19cb35708f310e49176db2ec2b5 (patch) | |
tree | 222a52e0e5c06cc946d45240a6194c57b46a8724 /cli/proc_state.rs | |
parent | 1058d1868fcc28ce115d1cc231e66016308b76ce (diff) |
perf: node cjs & esm analysis cache (#16097)
This commit adds a cache for CJS and ESM analysis that is backed by an
SQLite file.
The connection to the DB is lazily created on first use, so shouldn't
have impact on the startup time.
Benched with running Vite
Deno v1.26:
```
$ deno task dev
Warning deno task is unstable and may drastically change in the future
Task dev deno run -A --unstable --node-modules-dir npm:vite
VITE v3.1.4 ready in 961 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
```
This branch:
```
../deno/target/release/deno task dev
Warning deno task is unstable and may drastically change in the future
Task dev deno run -A --unstable --node-modules-dir npm:vite
VITE v3.1.4 ready in 330 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
```
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 27cd0603d..bdd57da98 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -7,6 +7,7 @@ use crate::args::TypeCheckMode; use crate::cache; use crate::cache::EmitCache; use crate::cache::FastInsecureHasher; +use crate::cache::NodeAnalysisCache; use crate::cache::ParsedSourceCache; use crate::cache::TypeCheckCache; use crate::deno_dir; @@ -88,6 +89,7 @@ pub struct Inner { pub parsed_source_cache: ParsedSourceCache, maybe_resolver: Option<Arc<dyn deno_graph::source::Resolver + Send + Sync>>, maybe_file_watcher_reporter: Option<FileWatcherReporter>, + pub node_analysis_cache: NodeAnalysisCache, pub npm_cache: NpmCache, pub npm_resolver: NpmPackageResolver, pub cjs_resolutions: Mutex<HashSet<ModuleSpecifier>>, @@ -245,6 +247,8 @@ impl ProcState { .resolve_local_node_modules_folder() .with_context(|| "Resolving local node_modules folder.")?, ); + let node_analysis_cache = + NodeAnalysisCache::new(Some(dir.node_analysis_db_file_path())); let emit_options: deno_ast::EmitOptions = ts_config_result.ts_config.into(); Ok(ProcState(Arc::new(Inner { @@ -268,6 +272,7 @@ impl ProcState { parsed_source_cache, maybe_resolver, maybe_file_watcher_reporter, + node_analysis_cache, npm_cache, npm_resolver, cjs_resolutions: Default::default(), |