Skip to content

Commit 7ffde77

Browse files
committed
refactor(module_reload): remove stats and history tracking
1 parent 22a0e5d commit 7ffde77

6 files changed

Lines changed: 3 additions & 154 deletions

File tree

crates/rari/src/runtime/module_reload/config.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ pub struct ReloadConfig {
55
pub reload_timeout_ms: u64,
66
pub parallel_reloads: bool,
77
pub debounce_delay_ms: u64,
8-
pub max_history_size: usize,
9-
pub enable_memory_monitoring: bool,
108
}
119

1210
impl Default for ReloadConfig {
@@ -17,8 +15,6 @@ impl Default for ReloadConfig {
1715
reload_timeout_ms: 5000,
1816
parallel_reloads: true,
1917
debounce_delay_ms: 150,
20-
max_history_size: 100,
21-
enable_memory_monitoring: true,
2218
}
2319
}
2420
}
@@ -31,8 +27,6 @@ impl ReloadConfig {
3127
reload_timeout_ms: 3000,
3228
parallel_reloads: true,
3329
debounce_delay_ms: 200,
34-
max_history_size: 50,
35-
enable_memory_monitoring: false,
3630
}
3731
}
3832

@@ -43,8 +37,6 @@ impl ReloadConfig {
4337
reload_timeout_ms: 10000,
4438
parallel_reloads: true,
4539
debounce_delay_ms: 100,
46-
max_history_size: 200,
47-
enable_memory_monitoring: true,
4840
}
4941
}
5042

crates/rari/src/runtime/module_reload/manager.rs

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
use crate::error::{ModuleReloadError, RariError};
22
use crate::rsc::components::ComponentRegistry;
33
use crate::runtime::JsExecutionRuntime;
4-
use crate::runtime::module_reload::{
5-
DebounceManager, ModuleReloadRequest, ReloadConfig, ReloadHistoryEntry, ReloadStats,
6-
};
4+
use crate::runtime::module_reload::{DebounceManager, ModuleReloadRequest, ReloadConfig};
75
use crate::runtime::utils::DistPathResolver;
86
use std::collections::VecDeque;
97
use std::path::Path;
108
use std::sync::Arc;
11-
use std::time::{Duration, Instant};
12-
use tokio::sync::{Mutex, RwLock};
9+
use std::time::Duration;
10+
use tokio::sync::Mutex;
1311
use tracing::error;
1412

1513
pub struct ModuleReloadManager {
1614
reload_queue: Arc<Mutex<VecDeque<ModuleReloadRequest>>>,
17-
reload_stats: Arc<RwLock<ReloadStats>>,
1815
config: ReloadConfig,
1916
runtime: Option<Arc<JsExecutionRuntime>>,
2017
component_registry: Option<Arc<parking_lot::Mutex<ComponentRegistry>>>,
2118
debounce_manager: DebounceManager,
22-
reload_history: Arc<Mutex<VecDeque<ReloadHistoryEntry>>>,
2319
dist_path_resolver: Option<Arc<DistPathResolver>>,
2420
}
2521

2622
impl Clone for ModuleReloadManager {
2723
fn clone(&self) -> Self {
2824
Self {
2925
reload_queue: Arc::clone(&self.reload_queue),
30-
reload_stats: Arc::clone(&self.reload_stats),
3126
config: self.config.clone(),
3227
runtime: self.runtime.clone(),
3328
component_registry: self.component_registry.clone(),
3429
debounce_manager: self.debounce_manager.clone(),
35-
reload_history: Arc::clone(&self.reload_history),
3630
dist_path_resolver: self.dist_path_resolver.clone(),
3731
}
3832
}
@@ -42,25 +36,21 @@ impl ModuleReloadManager {
4236
pub fn new(config: ReloadConfig) -> Self {
4337
Self {
4438
reload_queue: Arc::new(Mutex::new(VecDeque::new())),
45-
reload_stats: Arc::new(RwLock::new(ReloadStats::default())),
4639
config,
4740
runtime: None,
4841
component_registry: None,
4942
debounce_manager: DebounceManager::new(),
50-
reload_history: Arc::new(Mutex::new(VecDeque::new())),
5143
dist_path_resolver: None,
5244
}
5345
}
5446

5547
pub fn with_runtime(config: ReloadConfig, runtime: Arc<JsExecutionRuntime>) -> Self {
5648
Self {
5749
reload_queue: Arc::new(Mutex::new(VecDeque::new())),
58-
reload_stats: Arc::new(RwLock::new(ReloadStats::default())),
5950
config,
6051
runtime: Some(runtime),
6152
component_registry: None,
6253
debounce_manager: DebounceManager::new(),
63-
reload_history: Arc::new(Mutex::new(VecDeque::new())),
6454
dist_path_resolver: None,
6555
}
6656
}
@@ -89,10 +79,6 @@ impl ModuleReloadManager {
8979
self.config.enabled
9080
}
9181

92-
pub async fn get_stats(&self) -> ReloadStats {
93-
self.reload_stats.read().await.clone()
94-
}
95-
9682
pub async fn enqueue_reload(&self, request: ModuleReloadRequest) {
9783
let mut queue = self.reload_queue.lock().await;
9884
queue.push_back(request);
@@ -116,37 +102,6 @@ impl ModuleReloadManager {
116102
fn clone_for_task(&self) -> Self {
117103
self.clone()
118104
}
119-
120-
async fn record_reload_stats(&self, success: bool, duration_ms: u64) {
121-
let mut stats = self.reload_stats.write().await;
122-
stats.record_reload(success, duration_ms);
123-
}
124-
125-
async fn add_to_history(&self, component_id: String, success: bool, duration_ms: u64) {
126-
let mut history = self.reload_history.lock().await;
127-
128-
let entry = ReloadHistoryEntry::new(component_id, success, duration_ms);
129-
history.push_back(entry);
130-
131-
while history.len() > self.config.max_history_size {
132-
history.pop_front();
133-
}
134-
}
135-
136-
pub async fn get_reload_history(&self) -> Vec<ReloadHistoryEntry> {
137-
let history = self.reload_history.lock().await;
138-
history.iter().cloned().collect()
139-
}
140-
141-
pub async fn clear_history(&self) {
142-
let mut history = self.reload_history.lock().await;
143-
history.clear();
144-
}
145-
146-
pub async fn get_memory_usage(&self) -> u64 {
147-
let stats = self.reload_stats.read().await;
148-
stats.estimated_memory_bytes
149-
}
150105
}
151106

152107
impl ModuleReloadManager {
@@ -192,15 +147,8 @@ impl ModuleReloadManager {
192147
return Ok(());
193148
}
194149

195-
let start = Instant::now();
196-
197150
let result = self.reload_with_retry(component_id, file_path).await;
198151

199-
let duration_ms = start.elapsed().as_millis() as u64;
200-
201-
self.record_reload_stats(result.is_ok(), duration_ms).await;
202-
self.add_to_history(component_id.to_string(), result.is_ok(), duration_ms).await;
203-
204152
match &result {
205153
Ok(_) => {}
206154
Err(e) => {

crates/rari/src/runtime/module_reload/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ pub mod config;
22
pub mod debounce;
33
pub mod manager;
44
pub mod request;
5-
pub mod stats;
65
pub mod verification;
76

87
pub use config::ReloadConfig;
98
pub use debounce::{DebounceManager, DebouncePendingMap};
109
pub use manager::ModuleReloadManager;
1110
pub use request::ModuleReloadRequest;
12-
pub use stats::{ReloadHistoryEntry, ReloadStats};
1311
pub use verification::{JsComponentVerification, JsModuleCacheInfo, JsReloadResult};

crates/rari/src/runtime/module_reload/stats.rs

Lines changed: 0 additions & 70 deletions
This file was deleted.

crates/rari/src/server/config/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ pub struct RscConfig {
303303
pub hmr_reload_timeout_ms: u64,
304304
pub hmr_parallel_reloads: bool,
305305
pub hmr_debounce_delay_ms: u64,
306-
pub hmr_max_history_size: usize,
307-
pub hmr_enable_memory_monitoring: bool,
308306
}
309307

310308
impl Default for RscConfig {
@@ -321,8 +319,6 @@ impl Default for RscConfig {
321319
hmr_reload_timeout_ms: 5000,
322320
hmr_parallel_reloads: true,
323321
hmr_debounce_delay_ms: 150,
324-
hmr_max_history_size: 100,
325-
hmr_enable_memory_monitoring: true,
326322
}
327323
}
328324
}
@@ -463,19 +459,6 @@ impl Config {
463459
.map_err(|_| ConfigError::Config("RARI_HMR_DEBOUNCE_DELAY_MS".to_string()))?;
464460
}
465461

466-
if let Ok(history_size_str) = std::env::var("RARI_HMR_MAX_HISTORY_SIZE") {
467-
config.rsc.hmr_max_history_size = history_size_str
468-
.parse()
469-
.map_err(|_| ConfigError::Config("RARI_HMR_MAX_HISTORY_SIZE".to_string()))?;
470-
}
471-
472-
if let Ok(memory_monitoring_str) = std::env::var("RARI_HMR_ENABLE_MEMORY_MONITORING") {
473-
config.rsc.hmr_enable_memory_monitoring = memory_monitoring_str.cow_to_lowercase()
474-
== "true"
475-
|| memory_monitoring_str == "1"
476-
|| memory_monitoring_str.cow_to_lowercase() == "yes";
477-
}
478-
479462
if let Ok(rsc_html_enabled_str) = std::env::var("RARI_RSC_HTML_ENABLED") {
480463
config.rsc_html.enabled = rsc_html_enabled_str.cow_to_lowercase() == "true"
481464
|| rsc_html_enabled_str == "1"

crates/rari/src/server/core/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ impl Server {
129129
reload_timeout_ms: config.rsc.hmr_reload_timeout_ms,
130130
parallel_reloads: config.rsc.hmr_parallel_reloads,
131131
debounce_delay_ms: config.rsc.hmr_debounce_delay_ms,
132-
max_history_size: config.rsc.hmr_max_history_size,
133-
enable_memory_monitoring: config.rsc.hmr_enable_memory_monitoring,
134132
};
135133
let mut module_reload_manager =
136134
crate::runtime::module_reload::ModuleReloadManager::new(reload_config);

0 commit comments

Comments
 (0)