Commit 44e3710
committed
Major System Overhaul: Real-time Dashboard, Enhanced Error Handling & Structural Refactoring
**Update Description:**
This major update introduces comprehensive improvements across the entire danteGPU, focusing on real-time monitoring, error resilience, and architectural optimization. Key changes include:
---
### 1. **Real-time Dashboard Engine Overhaul**
**What Changed:**
- Implemented async-aware mutex locking with `tokio::sync::Mutex` replacing `std::sync::Mutex`
- Added 500ms auto-refresh loop using `tokio::select!` for concurrent UI updates and input handling
- Rewrote terminal drawing logic with ratatui's `List` widgets for dynamic GPU/user list rendering
- Integrated non-blocking input handling with `crossterm::event::poll`
```rust
// New event loop structure
loop {
let timeout = tokio::time::sleep(Duration::from_millis(500));
tokio::select! {
_ = timeout => {
// Async lock acquisition
let gpupool = gpupool.lock().await;
let users = users.lock().await;
terminal.draw(|f| { /* ... */ })?;
}
event = crossterm::event::read() => {
// Input handling
}
}
}
```
---
### 2. **Enhanced Error Handling System**
**Key Improvements:**
- Added detailed error context propagation using `anyhow::Context`
- Implemented automatic user creation with 1M default credits for demo purposes
- Created custom error types for critical operations:
```rust
#[derive(Debug, thiserror::Error)]
pub enum AllocationError {
#[error("GPU {0} not found")]
GpuNotFound(u32),
#[error("Insufficient credits: needed {needed:.2}, available {available:.2}")]
InsufficientCredits { needed: f64, available: f64 },
}
```
- Added backpressure control in API middleware using governor rate limiting
---
### 3. **GPU Management Core Refactoring**
**Structural Changes:**
- Removed legacy pricing map in favor of algorithmic cost calculation:
```rust
fn calculate_cost(&self, gpu_id: u32) -> f64 {
let gpu = self.gpus.get(&gpu_id).unwrap();
gpu.vram_mb as f64 * 0.1 + gpu.compute_units as f64 * 2.0
}
```
- Standardized GPU initialization with realistic hardware profiles:
```rust
GPUPool {
gpus: HashMap::from([
(0, VirtualGPU::new(8192, 32)), // Mid-range GPU
(1, VirtualGPU::new(16384, 64)), // High-end GPU
])
}
```
- Added atomic reference counting for GPU state sharing
---
### 4. **User Management System Upgrade**
**New Features:**
- Auto-creation of users with default 1M credit balance
- Credit deduction validation with detailed error reporting
- Added user activity tracking:
```rust
pub struct User {
pub last_active: DateTime<Utc>,
pub session_count: u32,
pub total_spent: f64,
}
```
---
### 5. **Testing & Validation Suite**
**Added Test Cases:**
```rust
#[tokio::test]
async fn test_concurrent_allocations() {
// Stress test with 100 concurrent requests
}
```
**Example Test Commands:**
```bash
# Test real-time dashboard updates
cargo run --release --bin dashboard &
# Generate load
for i in {1..10}; do
cargo run --release -- rent --gpu-id 0 --user "user$i" --duration 10
done
```
---
### 6. **Dependency & Configuration Updates**
- Upgraded tokio to 1.36 with full features
- Added ratatui 0.26 and crossterm 0.27 for terminal UI
- Configured default-run in Cargo.toml for better CLI handling
- Removed legacy NVML/Windows API code paths
---
### 7. **CI/CD Improvements**
- Added release profile optimization flags:
```toml
[profile.release]
lto = true
codegen-units = 1
```
- Configured automated rustfmt/clippy checks
- Added basic healthcheck endpoint to API
---
**Migration Notes:**
1. Existing users will be automatically migrated with 1M credit balance
2. GPU pricing model changed from fixed to dynamic calculation
3. Dashboard now requires tokio runtime for async operation
**Known Issues:**
- Dashboard may show brief inconsistencies during high contention
- GPU release notifications have 500ms propagation delay
**Future Roadmap:**
- Implement JWT-based authentication layer
- Add GPU utilization graphs using plotters crate
- Develop WebSocket API for browser-based dashboard1 parent 1619356 commit 44e3710
File tree
26 files changed
+1527
-1424
lines changed- src
- api
- middleware
- bin
- cli
- core
- dashboard
- gpu
- monitoring
- utils
- tests
26 files changed
+1527
-1424
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
| 9 | + | |
7 | 10 | | |
8 | | - | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | | - | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | | - | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
43 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
115 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
116 | 161 | | |
117 | 162 | | |
118 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
0 commit comments