From 7b1d61e9e9f0ef61be53558265ea2f3e40ef5d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 15:33:13 +0300 Subject: [PATCH] =?UTF-8?q?Revert=20"=E2=9A=A1=20perf:=20a=20tree's=20last?= =?UTF-8?q?-commit=20walk=20is=20cached=20per=20commit;=20the=20code=20pag?= =?UTF-8?q?e=20renders=20in=205=20ms=20instead=20of=2038=20ms=20after=20it?= =?UTF-8?q?s=20first=20view"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ed35470096ab56222b613ee2c5138d05557e1902. --- crates/forge-web-pages/src/pages/tree.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/crates/forge-web-pages/src/pages/tree.rs b/crates/forge-web-pages/src/pages/tree.rs index 0eea46a..a42992c 100644 --- a/crates/forge-web-pages/src/pages/tree.rs +++ b/crates/forge-web-pages/src/pages/tree.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; -use std::sync::{Mutex, OnceLock}; use std::time::Duration; use forge_core::Repo as RepoRow; @@ -67,13 +66,6 @@ pub async fn read_file(path: PathBuf, commit: String, file: String) -> Result)>>; - -fn last_commit_cache() -> &'static LastCommitCache { - static CACHE: OnceLock = OnceLock::new(); - CACHE.get_or_init(|| Mutex::new(HashMap::new())) -} - pub async fn last_commits( state: &AppState, path: &Path, @@ -81,22 +73,9 @@ pub async fn last_commits( dir: &str, names: &[String], ) -> HashMap { - let key = (path.to_path_buf(), dir.to_owned()); - if let Some((at, map)) = last_commit_cache().lock().expect("last-commit cache").get(&key) - && at == commit - { - return map.clone(); - } let walk = history::last_commits(&state.git, path, commit, dir, names, LAST_COMMIT_WALK); match tokio::time::timeout(LAST_COMMIT_TIMEOUT, walk).await { - Ok(Ok(map)) => { - let mut cache = last_commit_cache().lock().expect("last-commit cache"); - if cache.len() >= 1024 { - cache.clear(); - } - cache.insert(key, (commit.to_owned(), map.clone())); - map - } + Ok(Ok(map)) => map, Ok(Err(e)) => { tracing::warn!(error = %e, "last-commit walk failed"); HashMap::new()