Skip to content

Commit dfd627b

Browse files
lutterclaude
andcommitted
core: Replace std::sync::RwLock with parking_lot::RwLock in SubgraphKeepAlive
Replace std::sync::RwLock with parking_lot::RwLock for the alive_map in SubgraphKeepAlive. This reduces lock contention when tracking running subgraph deployments. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0a8b92e commit dfd627b

File tree

1 file changed

+6
-4
lines changed
  • core/src/subgraph/context

1 file changed

+6
-4
lines changed

core/src/subgraph/context/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ use graph::{
2323
slog::Logger,
2424
};
2525
use std::collections::HashMap;
26-
use std::sync::{Arc, RwLock};
26+
use std::sync::Arc;
27+
28+
use graph::parking_lot::RwLock;
2729
use tokio::sync::mpsc;
2830

2931
use self::instance::SubgraphInstance;
@@ -44,18 +46,18 @@ impl SubgraphKeepAlive {
4446
}
4547

4648
pub fn remove(&self, deployment_id: &DeploymentId) {
47-
self.alive_map.write().unwrap().remove(deployment_id);
49+
self.alive_map.write().remove(deployment_id);
4850
self.sg_metrics.running_count.dec();
4951
}
5052
pub fn insert(&self, deployment_id: DeploymentId, guard: CancelGuard) {
51-
let old = self.alive_map.write().unwrap().insert(deployment_id, guard);
53+
let old = self.alive_map.write().insert(deployment_id, guard);
5254
if old.is_none() {
5355
self.sg_metrics.running_count.inc();
5456
}
5557
}
5658

5759
pub fn contains(&self, deployment_id: &DeploymentId) -> bool {
58-
self.alive_map.read().unwrap().contains_key(deployment_id)
60+
self.alive_map.read().contains_key(deployment_id)
5961
}
6062
}
6163

0 commit comments

Comments
 (0)