From 13b758889f977e55907bff8eebb9c015ac8fa2be Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2026 07:49:00 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20perf:=20cache=20tech.toml=20parsing?= =?UTF-8?q?=20during=20dependency=20resolution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces a HashMap to cache the parsed entry paths from `tech.toml` files during module resolution in `cli/src/project.rs`. This avoids redundantly reading and parsing the TOML manifest when a package is imported multiple times. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- .gitignore | 7 +++++++ cli/src/project.rs | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 77ef54c8..643b31f0 100644 --- a/.gitignore +++ b/.gitignore @@ -82,3 +82,10 @@ bin/ build/ dist/ site/ +mock_heavy_project/ +mock_project/ +mock_project_fast/ +run_bench.sh +run_heavy_bench.sh +mock_many_imports/ +run_many_imports.sh diff --git a/cli/src/project.rs b/cli/src/project.rs index 8b15e1c7..32254841 100644 --- a/cli/src/project.rs +++ b/cli/src/project.rs @@ -163,6 +163,7 @@ impl ProjectBuildGraph { // 2. Resolve imports recursively let mut visited = HashSet::new(); + let mut manifest_cache: HashMap = HashMap::new(); while let Some((fid, path, pkg_name)) = to_resolve.pop() { if visited.contains(&fid) { continue; @@ -256,14 +257,18 @@ impl ProjectBuildGraph { } if !try_file.exists() { let manifest_toml = pkg_path.join("tech.toml"); - if manifest_toml.exists() { + if let Some(cached_entry) = manifest_cache.get(&manifest_toml) { + try_file = pkg_path.join(cached_entry); + } else if manifest_toml.exists() { if let Ok(toml_content) = std::fs::read_to_string(&manifest_toml) { if let Ok(manifest) = toml::from_str::( &toml_content, ) { - try_file = pkg_path.join(manifest.package.entry); + let entry = manifest.package.entry; + try_file = pkg_path.join(&entry); + manifest_cache.insert(manifest_toml, entry); } } }