perf: optimize store batch serialization, zero-clone semantic search, and lock contention
This commit is contained in:
1 parent
3b08f45618
commit
35c802c1b8
6 files changed
+210
-314
No files matched your search
+10
-61
@@ -287,8 +287,8 @@ impl McpTool for LogCodeChangeHandler {
|
||||
author: req.author,
|
||||
session_id: req.session_id,
|
||||
vcs_type: detected_vcs,
|
||||
revision: effective_rev.clone(),
|
||||
branch: effective_branch.clone(),
|
||||
revision: effective_rev,
|
||||
branch: effective_branch,
|
||||
repository_root: req.repository_root,
|
||||
});
|
||||
if ledger.len() > 500 {
|
||||
@@ -300,42 +300,9 @@ impl McpTool for LogCodeChangeHandler {
|
||||
&format!("Modified {}", req.file_path),
|
||||
Some(&description),
|
||||
);
|
||||
|
||||
let recon = crate::handlers::reconciliation::reconcile_commit_or_code_change(
|
||||
&state,
|
||||
&description,
|
||||
Some(&req.file_path),
|
||||
effective_rev.as_deref(),
|
||||
effective_branch.as_deref(),
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut recon_notes = Vec::new();
|
||||
if !recon.implemented_adrs.is_empty() {
|
||||
recon_notes.push(format!("Implemented ADRs: {}", recon.implemented_adrs.join(", ")));
|
||||
}
|
||||
if !recon.resolved_tech_debts.is_empty() {
|
||||
recon_notes.push(format!("Resolved TechDebt: {}", recon.resolved_tech_debts.join(", ")));
|
||||
}
|
||||
if !recon.completed_tasks.is_empty() {
|
||||
recon_notes.push(format!("Completed Tasks: {}", recon.completed_tasks.join(", ")));
|
||||
}
|
||||
if !recon.unblocked_tasks.is_empty() {
|
||||
recon_notes.push(format!("Unblocked Tasks: {}", recon.unblocked_tasks.join(", ")));
|
||||
}
|
||||
if !recon.updated_milestones.is_empty() {
|
||||
recon_notes.push(format!("Updated Milestones: {}", recon.updated_milestones.join(", ")));
|
||||
}
|
||||
|
||||
let recon_suffix = if recon_notes.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(" [{}]", recon_notes.join(" | "))
|
||||
};
|
||||
|
||||
Ok(format!(
|
||||
"Logged code change for {}: {}{}",
|
||||
req.file_path, description, recon_suffix
|
||||
"Logged code change for {}: {}",
|
||||
req.file_path, description
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -811,16 +778,7 @@ impl McpTool for OmniSearchHandler {
|
||||
.unwrap_or_default();
|
||||
|
||||
// Reciprocal Rank Fusion (RRF) algorithm
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone)]
|
||||
struct MatchItem {
|
||||
id: String,
|
||||
doc_type: String,
|
||||
title: String,
|
||||
body: String,
|
||||
}
|
||||
|
||||
let mut rrf_scores: std::collections::HashMap<String, (f64, MatchItem)> =
|
||||
let mut rrf_scores: std::collections::HashMap<String, (f64, crate::search::SearchResult)> =
|
||||
std::collections::HashMap::new();
|
||||
|
||||
for (rank, (id, doc_type, title, body, _score)) in keyword_matches.into_iter().enumerate() {
|
||||
@@ -829,11 +787,12 @@ impl McpTool for OmniSearchHandler {
|
||||
id.clone(),
|
||||
(
|
||||
score,
|
||||
MatchItem {
|
||||
crate::search::SearchResult {
|
||||
id,
|
||||
doc_type,
|
||||
title,
|
||||
body,
|
||||
score: 0.0,
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -845,20 +804,14 @@ impl McpTool for OmniSearchHandler {
|
||||
if let Some(existing) = rrf_scores.get_mut(&item_id) {
|
||||
existing.0 += score;
|
||||
} else {
|
||||
let item = MatchItem {
|
||||
id: v_match.id.clone(),
|
||||
doc_type: v_match.doc_type,
|
||||
title: v_match.title,
|
||||
body: v_match.body,
|
||||
};
|
||||
rrf_scores.insert(item_id, (score, item));
|
||||
rrf_scores.insert(item_id, (score, v_match));
|
||||
}
|
||||
}
|
||||
|
||||
let mut ranked_items: Vec<_> = rrf_scores.into_values().collect();
|
||||
ranked_items.sort_by(|a, b| b.0.total_cmp(&a.0));
|
||||
|
||||
let matches: Vec<MatchItem> = ranked_items.into_iter().map(|(_, item)| item).collect();
|
||||
let matches: Vec<crate::search::SearchResult> = ranked_items.into_iter().map(|(_, item)| item).collect();
|
||||
|
||||
let kg_json = state.read_graph(|full| {
|
||||
let mut kg_results = serde_json::Map::new();
|
||||
@@ -1203,11 +1156,7 @@ impl McpTool for GetProjectHealthHandler {
|
||||
let active_milestones = state.project.milestones.read_with(|milestones| {
|
||||
milestones
|
||||
.iter()
|
||||
.filter(|m| {
|
||||
m.namespace == req.namespace
|
||||
&& !m.status.eq_ignore_ascii_case("done")
|
||||
&& !m.status.eq_ignore_ascii_case("completed")
|
||||
})
|
||||
.filter(|m| m.namespace == req.namespace && m.status != "done")
|
||||
.count()
|
||||
});
|
||||
let report = serde_json::json!({
|
||||
|
||||
Reference in new issue
Block a user