@appkit/llamacpp-cli 1.11.0 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +356 -3
- package/dist/cli.js +99 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/admin/config.d.ts +10 -0
- package/dist/commands/admin/config.d.ts.map +1 -0
- package/dist/commands/admin/config.js +100 -0
- package/dist/commands/admin/config.js.map +1 -0
- package/dist/commands/admin/logs.d.ts +10 -0
- package/dist/commands/admin/logs.d.ts.map +1 -0
- package/dist/commands/admin/logs.js +114 -0
- package/dist/commands/admin/logs.js.map +1 -0
- package/dist/commands/admin/restart.d.ts +2 -0
- package/dist/commands/admin/restart.d.ts.map +1 -0
- package/dist/commands/admin/restart.js +29 -0
- package/dist/commands/admin/restart.js.map +1 -0
- package/dist/commands/admin/start.d.ts +2 -0
- package/dist/commands/admin/start.d.ts.map +1 -0
- package/dist/commands/admin/start.js +30 -0
- package/dist/commands/admin/start.js.map +1 -0
- package/dist/commands/admin/status.d.ts +2 -0
- package/dist/commands/admin/status.d.ts.map +1 -0
- package/dist/commands/admin/status.js +82 -0
- package/dist/commands/admin/status.js.map +1 -0
- package/dist/commands/admin/stop.d.ts +2 -0
- package/dist/commands/admin/stop.d.ts.map +1 -0
- package/dist/commands/admin/stop.js +21 -0
- package/dist/commands/admin/stop.js.map +1 -0
- package/dist/commands/logs.d.ts +1 -0
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +22 -0
- package/dist/commands/logs.js.map +1 -1
- package/dist/lib/admin-manager.d.ts +111 -0
- package/dist/lib/admin-manager.d.ts.map +1 -0
- package/dist/lib/admin-manager.js +413 -0
- package/dist/lib/admin-manager.js.map +1 -0
- package/dist/lib/admin-server.d.ts +148 -0
- package/dist/lib/admin-server.d.ts.map +1 -0
- package/dist/lib/admin-server.js +1161 -0
- package/dist/lib/admin-server.js.map +1 -0
- package/dist/lib/download-job-manager.d.ts +64 -0
- package/dist/lib/download-job-manager.d.ts.map +1 -0
- package/dist/lib/download-job-manager.js +164 -0
- package/dist/lib/download-job-manager.js.map +1 -0
- package/dist/tui/MultiServerMonitorApp.js +1 -1
- package/dist/types/admin-config.d.ts +19 -0
- package/dist/types/admin-config.d.ts.map +1 -0
- package/dist/types/admin-config.js +3 -0
- package/dist/types/admin-config.js.map +1 -0
- package/dist/utils/log-parser.d.ts +9 -0
- package/dist/utils/log-parser.d.ts.map +1 -1
- package/dist/utils/log-parser.js +11 -0
- package/dist/utils/log-parser.js.map +1 -1
- package/docs/images/web-ui-servers.png +0 -0
- package/package.json +1 -1
- package/src/cli.ts +100 -0
- package/src/commands/admin/config.ts +121 -0
- package/src/commands/admin/logs.ts +91 -0
- package/src/commands/admin/restart.ts +26 -0
- package/src/commands/admin/start.ts +27 -0
- package/src/commands/admin/status.ts +84 -0
- package/src/commands/admin/stop.ts +16 -0
- package/src/commands/logs.ts +24 -0
- package/src/lib/admin-manager.ts +435 -0
- package/src/lib/admin-server.ts +1243 -0
- package/src/lib/download-job-manager.ts +213 -0
- package/src/tui/MultiServerMonitorApp.ts +1 -1
- package/src/types/admin-config.ts +25 -0
- package/src/utils/log-parser.ts +13 -0
- package/web/README.md +429 -0
- package/web/eslint.config.js +23 -0
- package/web/index.html +13 -0
- package/web/llamacpp-web-dist.tar.gz +0 -0
- package/web/package-lock.json +4017 -0
- package/web/package.json +38 -0
- package/web/postcss.config.js +6 -0
- package/web/public/vite.svg +1 -0
- package/web/src/App.css +42 -0
- package/web/src/App.tsx +86 -0
- package/web/src/assets/react.svg +1 -0
- package/web/src/components/ApiKeyPrompt.tsx +71 -0
- package/web/src/components/CreateServerModal.tsx +372 -0
- package/web/src/components/DownloadProgress.tsx +123 -0
- package/web/src/components/Nav.tsx +89 -0
- package/web/src/components/RouterConfigModal.tsx +240 -0
- package/web/src/components/SearchModal.tsx +306 -0
- package/web/src/components/ServerConfigModal.tsx +291 -0
- package/web/src/hooks/useApi.ts +259 -0
- package/web/src/index.css +42 -0
- package/web/src/lib/api.ts +226 -0
- package/web/src/main.tsx +10 -0
- package/web/src/pages/Dashboard.tsx +103 -0
- package/web/src/pages/Models.tsx +258 -0
- package/web/src/pages/Router.tsx +270 -0
- package/web/src/pages/RouterLogs.tsx +201 -0
- package/web/src/pages/ServerLogs.tsx +553 -0
- package/web/src/pages/Servers.tsx +358 -0
- package/web/src/types/api.ts +140 -0
- package/web/tailwind.config.js +31 -0
- package/web/tsconfig.app.json +28 -0
- package/web/tsconfig.json +7 -0
- package/web/tsconfig.node.json +26 -0
- package/web/vite.config.ts +25 -0
- package/MONITORING-ACCURACY-FIX.md +0 -199
- package/PER-PROCESS-METRICS.md +0 -190
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
# Historical Monitoring Accuracy Fix
|
|
2
|
-
|
|
3
|
-
**STATUS:** This document describes the initial fix attempt for memory calculations. However, the root issue was that historical monitoring was showing **system-wide metrics** instead of **per-process metrics**. See `PER-PROCESS-METRICS.md` for the correct implementation.
|
|
4
|
-
|
|
5
|
-
## Issue Summary
|
|
6
|
-
|
|
7
|
-
Comparison between our historical monitoring and macmon revealed discrepancies in memory usage calculations.
|
|
8
|
-
|
|
9
|
-
## Issues Identified
|
|
10
|
-
|
|
11
|
-
### 1. Memory Total Calculation (CRITICAL)
|
|
12
|
-
|
|
13
|
-
**Problem:** Total memory was calculated by summing all vm_stat page counts, which doesn't equal the actual installed RAM.
|
|
14
|
-
|
|
15
|
-
**Evidence:**
|
|
16
|
-
- Historical monitor showed: ~60% memory usage
|
|
17
|
-
- macmon showed: 26.86 / 32.0 GB = ~84% memory usage
|
|
18
|
-
- The denominator (32.0 GB installed RAM) was being calculated incorrectly
|
|
19
|
-
|
|
20
|
-
**Root Cause:**
|
|
21
|
-
```typescript
|
|
22
|
-
// OLD CODE (INCORRECT)
|
|
23
|
-
const totalPages = pagesActive + pagesWired + pagesCompressed +
|
|
24
|
-
pagesFree + pagesInactive + pagesSpeculative;
|
|
25
|
-
const memoryTotal = totalPages * pageSize;
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
This approach has fundamental flaws:
|
|
29
|
-
- vm_stat doesn't report all memory categories (kernel reserved, etc.)
|
|
30
|
-
- Page counts don't sum to actual installed RAM
|
|
31
|
-
- Results in artificially inflated "total" value
|
|
32
|
-
- Makes memory usage appear lower than reality
|
|
33
|
-
|
|
34
|
-
**Fix:**
|
|
35
|
-
```typescript
|
|
36
|
-
// NEW CODE (CORRECT)
|
|
37
|
-
// Get total installed RAM from sysctl (accurate)
|
|
38
|
-
const memoryTotal = await execCommand('sysctl -n hw.memsize 2>/dev/null');
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Use `sysctl hw.memsize` to get actual installed RAM size in bytes. This matches what Activity Monitor and macmon report.
|
|
42
|
-
|
|
43
|
-
### 2. Memory Used Calculation (VERIFIED CORRECT)
|
|
44
|
-
|
|
45
|
-
**Current approach:**
|
|
46
|
-
```typescript
|
|
47
|
-
// Used = Active + Wired + Compressed
|
|
48
|
-
const usedPages = pagesActive + pagesWired + pagesCompressed;
|
|
49
|
-
const memoryUsed = usedPages * pageSize;
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
This formula is **correct** and matches what Activity Monitor and macmon report as "used memory".
|
|
53
|
-
|
|
54
|
-
- **Active:** Recently used memory
|
|
55
|
-
- **Wired:** Kernel memory that can't be paged out
|
|
56
|
-
- **Compressed:** Compressed pages in RAM
|
|
57
|
-
|
|
58
|
-
We removed the calculation of unused page types (free, inactive, speculative) since they're not needed.
|
|
59
|
-
|
|
60
|
-
### 3. CPU Calculation (VERIFIED CORRECT)
|
|
61
|
-
|
|
62
|
-
**Formula:**
|
|
63
|
-
```typescript
|
|
64
|
-
cpuUsage = ((pcpuUsage * pCoreCount) + (ecpuUsage * eCoreCount)) / totalCores * 100
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
This weighted average is mathematically correct:
|
|
68
|
-
- macmon reports per-core-type averages (P-CPU: 25%, E-CPU: 36%)
|
|
69
|
-
- Formula computes overall system average: `(25% × 6 + 36% × 4) / 10 = 29.4%`
|
|
70
|
-
- Historical average of 33% is reasonable given fluctuations over time
|
|
71
|
-
|
|
72
|
-
### 4. GPU Calculation (VERIFIED CORRECT)
|
|
73
|
-
|
|
74
|
-
**Observation:**
|
|
75
|
-
- Historical: Avg: 1.8%, Max: 4.0%, Min: 0.6%
|
|
76
|
-
- macmon snapshot: GPU 4%
|
|
77
|
-
|
|
78
|
-
This is **expected behavior**:
|
|
79
|
-
- GPU is mostly idle (0-2%) between inference requests
|
|
80
|
-
- Spikes to 4% during active token generation
|
|
81
|
-
- Average of 1.8% correctly reflects mostly-idle state
|
|
82
|
-
- Max of 4.0% matches macmon's instantaneous reading
|
|
83
|
-
|
|
84
|
-
## Changes Made
|
|
85
|
-
|
|
86
|
-
### `src/lib/system-collector.ts`
|
|
87
|
-
|
|
88
|
-
**1. Removed total memory calculation from vm_stat parsing:**
|
|
89
|
-
```typescript
|
|
90
|
-
// Now only returns memoryUsed
|
|
91
|
-
private parseVmStatOutput(output: string): { memoryUsed: number }
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**2. Added method to get actual installed RAM:**
|
|
95
|
-
```typescript
|
|
96
|
-
private async getTotalMemory(): Promise<number> {
|
|
97
|
-
const output = await execCommand('sysctl -n hw.memsize 2>/dev/null');
|
|
98
|
-
return parseInt(output.trim(), 10) || 0;
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
**3. Combined both sources in new method:**
|
|
103
|
-
```typescript
|
|
104
|
-
private async getMemoryMetrics(): Promise<{
|
|
105
|
-
memoryUsed: number;
|
|
106
|
-
memoryTotal: number;
|
|
107
|
-
}> {
|
|
108
|
-
// Get used memory from vm_stat (active + wired + compressed)
|
|
109
|
-
const vmStatOutput = await execCommand('vm_stat 2>/dev/null');
|
|
110
|
-
const { memoryUsed } = this.parseVmStatOutput(vmStatOutput);
|
|
111
|
-
|
|
112
|
-
// Get total installed RAM from sysctl (accurate)
|
|
113
|
-
const memoryTotal = await this.getTotalMemory();
|
|
114
|
-
|
|
115
|
-
return { memoryUsed, memoryTotal };
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**4. Updated collector to use new method:**
|
|
120
|
-
```typescript
|
|
121
|
-
// Always get memory from vm_stat + sysctl (accurate total from sysctl)
|
|
122
|
-
const memoryMetrics = await this.getMemoryMetrics();
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## Verification
|
|
126
|
-
|
|
127
|
-
After these changes, memory usage should now accurately match macmon and Activity Monitor:
|
|
128
|
-
|
|
129
|
-
**Before:**
|
|
130
|
-
- Total: Calculated from page sum (~40 GB equivalent)
|
|
131
|
-
- Used: 26.86 GB
|
|
132
|
-
- **Percentage: ~60% (WRONG)**
|
|
133
|
-
|
|
134
|
-
**After:**
|
|
135
|
-
- Total: 32.0 GB (from `sysctl hw.memsize`)
|
|
136
|
-
- Used: 26.86 GB (from vm_stat)
|
|
137
|
-
- **Percentage: ~84% (CORRECT)**
|
|
138
|
-
|
|
139
|
-
## Testing Recommendations
|
|
140
|
-
|
|
141
|
-
1. **Compare with macmon:**
|
|
142
|
-
```bash
|
|
143
|
-
# Terminal 1: Run macmon
|
|
144
|
-
macmon
|
|
145
|
-
|
|
146
|
-
# Terminal 2: Monitor server
|
|
147
|
-
npm run dev -- server monitor <server-id>
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Memory percentages should now match within 1-2%.
|
|
151
|
-
|
|
152
|
-
2. **Compare with Activity Monitor:**
|
|
153
|
-
- Open Activity Monitor → Memory tab
|
|
154
|
-
- Check "Memory Used" value
|
|
155
|
-
- Should match historical monitor's memory calculation
|
|
156
|
-
|
|
157
|
-
3. **Verify historical data:**
|
|
158
|
-
```bash
|
|
159
|
-
# View historical metrics (press H in monitor)
|
|
160
|
-
npm run dev -- server monitor <server-id>
|
|
161
|
-
# Press 'H' to toggle historical view
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Memory usage should now show realistic values (~80-90% on actively used system).
|
|
165
|
-
|
|
166
|
-
4. **Check edge cases:**
|
|
167
|
-
- Fresh boot (low memory usage ~30-40%)
|
|
168
|
-
- Under load (high memory usage ~85-95%)
|
|
169
|
-
- Multiple servers running (memory should increase proportionally)
|
|
170
|
-
|
|
171
|
-
## Impact on Historical Data
|
|
172
|
-
|
|
173
|
-
**Note:** Existing historical data was collected with the old (incorrect) calculation.
|
|
174
|
-
|
|
175
|
-
**Options:**
|
|
176
|
-
|
|
177
|
-
1. **Keep old data as-is** (recommended for now)
|
|
178
|
-
- Historical charts will show old incorrect baseline
|
|
179
|
-
- New data will be accurate going forward
|
|
180
|
-
- Natural transition over 24 hours as old data ages out
|
|
181
|
-
|
|
182
|
-
2. **Clear history and start fresh:**
|
|
183
|
-
```bash
|
|
184
|
-
rm ~/.llamacpp/history/*.json
|
|
185
|
-
```
|
|
186
|
-
- Immediate accuracy
|
|
187
|
-
- Lose historical context
|
|
188
|
-
|
|
189
|
-
## Related Files
|
|
190
|
-
|
|
191
|
-
- `src/lib/system-collector.ts` - System metrics collection (MODIFIED)
|
|
192
|
-
- `src/lib/history-manager.ts` - History persistence (unchanged)
|
|
193
|
-
- `src/tui/HistoricalMonitorApp.ts` - Historical UI (unchanged)
|
|
194
|
-
|
|
195
|
-
## References
|
|
196
|
-
|
|
197
|
-
- macOS `vm_stat` documentation: Reports memory in pages (16KB on Apple Silicon)
|
|
198
|
-
- macOS `sysctl` documentation: `hw.memsize` reports installed RAM in bytes
|
|
199
|
-
- Activity Monitor algorithm: Uses active + wired + compressed for "Memory Used"
|
package/PER-PROCESS-METRICS.md
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# Per-Process Metrics Implementation
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Historical monitoring now shows **per-process metrics** for the specific llama-server being monitored, rather than system-wide metrics. This provides accurate resource usage for each model.
|
|
6
|
-
|
|
7
|
-
## What Changed
|
|
8
|
-
|
|
9
|
-
### Before (System-Wide)
|
|
10
|
-
- **GPU Usage:** All processes combined
|
|
11
|
-
- **CPU Usage:** All processes combined
|
|
12
|
-
- **Memory Usage:** All processes combined (% of total RAM)
|
|
13
|
-
|
|
14
|
-
### After (Per-Process)
|
|
15
|
-
- **GPU Usage:** System-wide (unchanged - can't isolate per-process on macOS)
|
|
16
|
-
- **CPU Usage:** Just the llama-server process (from `ps`)
|
|
17
|
-
- **Memory Usage:** Just the llama-server process in GB (from `top`)
|
|
18
|
-
|
|
19
|
-
## Implementation Details
|
|
20
|
-
|
|
21
|
-
### 1. Process Metrics Collection
|
|
22
|
-
|
|
23
|
-
**Added CPU collection (`src/utils/process-utils.ts`):**
|
|
24
|
-
```typescript
|
|
25
|
-
// Batch collection for efficiency
|
|
26
|
-
export async function getBatchProcessCpu(pids: number[]): Promise<Map<number, number | null>>
|
|
27
|
-
|
|
28
|
-
// Single process collection
|
|
29
|
-
export async function getProcessCpu(pid: number): Promise<number | null>
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Features:**
|
|
33
|
-
- Uses `ps -p <pid> -o %cpu` to get per-process CPU percentage
|
|
34
|
-
- 3-second cache to prevent excessive process spawning
|
|
35
|
-
- Batch collection for multi-server monitoring
|
|
36
|
-
- Returns percentage (0-100+, can exceed 100% on multi-core)
|
|
37
|
-
|
|
38
|
-
### 2. Type Updates
|
|
39
|
-
|
|
40
|
-
**ServerMetrics interface (`src/types/monitor-types.ts`):**
|
|
41
|
-
```typescript
|
|
42
|
-
export interface ServerMetrics {
|
|
43
|
-
// ... existing fields
|
|
44
|
-
processMemory?: number; // Already existed
|
|
45
|
-
processCpuUsage?: number; // NEW: Per-process CPU %
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**HistorySnapshot interface (`src/types/history-types.ts`):**
|
|
50
|
-
```typescript
|
|
51
|
-
export interface HistorySnapshot {
|
|
52
|
-
server: {
|
|
53
|
-
// ... existing fields
|
|
54
|
-
processMemory?: number; // Already existed
|
|
55
|
-
processCpuUsage?: number; // NEW: Per-process CPU %
|
|
56
|
-
};
|
|
57
|
-
system?: {
|
|
58
|
-
// ... system-wide metrics (kept for live monitoring)
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 3. Metrics Collection
|
|
64
|
-
|
|
65
|
-
**MetricsAggregator (`src/lib/metrics-aggregator.ts`):**
|
|
66
|
-
- Added `processCpuUsage` parameter to `collectServerMetrics()`
|
|
67
|
-
- Collects CPU in parallel with other metrics
|
|
68
|
-
- Supports batch collection for multi-server scenarios
|
|
69
|
-
|
|
70
|
-
**HistoryManager (`src/lib/history-manager.ts`):**
|
|
71
|
-
- Saves `processCpuUsage` in snapshots
|
|
72
|
-
- Maintains backward compatibility (optional field)
|
|
73
|
-
|
|
74
|
-
### 4. Historical Monitor UI
|
|
75
|
-
|
|
76
|
-
**HistoricalMonitorApp (`src/tui/HistoricalMonitorApp.ts`):**
|
|
77
|
-
|
|
78
|
-
**Chart Changes:**
|
|
79
|
-
|
|
80
|
-
**GPU Usage:**
|
|
81
|
-
- **Unchanged:** Still system-wide
|
|
82
|
-
- **Reason:** macOS doesn't provide per-process GPU metrics easily
|
|
83
|
-
- **Label:** "GPU Usage (%)"
|
|
84
|
-
|
|
85
|
-
**CPU Usage:**
|
|
86
|
-
- **Before:** `snapshot.system.cpuUsage` (system-wide)
|
|
87
|
-
- **After:** `snapshot.server.processCpuUsage` (per-process)
|
|
88
|
-
- **Label:** "Process CPU Usage (%)"
|
|
89
|
-
- **Range:** Not forced to 0-100% (can show >100% for multi-threaded workloads)
|
|
90
|
-
|
|
91
|
-
**Memory Usage:**
|
|
92
|
-
- **Before:** `(system.memoryUsed / system.memoryTotal) * 100` (system-wide %)
|
|
93
|
-
- **After:** `processMemory / (1024 * 1024 * 1024)` (per-process GB)
|
|
94
|
-
- **Label:** "Process Memory Usage (GB)"
|
|
95
|
-
- **Format:** Shows 2 decimal places (e.g., "3.45 GB")
|
|
96
|
-
- **Statistics:** Avg, Max, Min in GB
|
|
97
|
-
|
|
98
|
-
**Multi-Server Comparison:**
|
|
99
|
-
- Table also updated to show per-process CPU and memory
|
|
100
|
-
- Memory column now shows GB instead of %
|
|
101
|
-
|
|
102
|
-
## Benefits
|
|
103
|
-
|
|
104
|
-
1. **Accurate Attribution:** See exactly what each model is using
|
|
105
|
-
2. **Multi-Server Clarity:** Compare resource usage across different models
|
|
106
|
-
3. **Debugging:** Identify which specific model is consuming resources
|
|
107
|
-
4. **Capacity Planning:** Understand per-model requirements
|
|
108
|
-
|
|
109
|
-
## Example Output
|
|
110
|
-
|
|
111
|
-
**Before (System-Wide):**
|
|
112
|
-
```
|
|
113
|
-
CPU Usage (%)
|
|
114
|
-
Avg: 33.0% (±17.4) Max: 86.6% Min: 12.0%
|
|
115
|
-
|
|
116
|
-
Memory Usage (%)
|
|
117
|
-
Avg: 31.0% (±0.6) Max: 31.9% Min: 29.9%
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**After (Per-Process):**
|
|
121
|
-
```
|
|
122
|
-
Process CPU Usage (%)
|
|
123
|
-
Avg: 45.2% (±12.3) Max: 120.5% Min: 8.1%
|
|
124
|
-
|
|
125
|
-
Process Memory Usage (GB)
|
|
126
|
-
Avg: 3.45 GB (±0.12) Max: 3.67 GB Min: 3.21 GB
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Edge Cases Handled
|
|
130
|
-
|
|
131
|
-
1. **Missing Data:** Fields are optional, gracefully handles old snapshots
|
|
132
|
-
2. **Process Not Running:** Returns null, charts skip those data points
|
|
133
|
-
3. **Multi-Core:** CPU can exceed 100% (expected behavior)
|
|
134
|
-
4. **Cache Expiry:** 3-second TTL prevents stale data
|
|
135
|
-
5. **Batch Collection:** Efficient when monitoring multiple servers
|
|
136
|
-
|
|
137
|
-
## Testing Recommendations
|
|
138
|
-
|
|
139
|
-
1. **Single Server:**
|
|
140
|
-
```bash
|
|
141
|
-
npm run dev -- server monitor <server-id>
|
|
142
|
-
# Press 'H' to view historical data
|
|
143
|
-
```
|
|
144
|
-
- Verify CPU shows reasonable per-process values (not system-wide)
|
|
145
|
-
- Verify memory shows model size in GB (not total RAM %)
|
|
146
|
-
|
|
147
|
-
2. **Multi-Server:**
|
|
148
|
-
```bash
|
|
149
|
-
npm run dev -- server monitor
|
|
150
|
-
# Press 'H' to view comparison table
|
|
151
|
-
```
|
|
152
|
-
- Verify each server shows different CPU/memory values
|
|
153
|
-
- Verify table shows GB for memory column
|
|
154
|
-
|
|
155
|
-
3. **Compare with Activity Monitor:**
|
|
156
|
-
- Open Activity Monitor
|
|
157
|
-
- Filter for `llama-server` process
|
|
158
|
-
- CPU % should match within 5-10%
|
|
159
|
-
- Memory should match within 0.1 GB
|
|
160
|
-
|
|
161
|
-
4. **Compare with `ps`:**
|
|
162
|
-
```bash
|
|
163
|
-
ps -p <pid> -o %cpu,rss
|
|
164
|
-
```
|
|
165
|
-
- CPU % should match
|
|
166
|
-
- RSS (memory) should match when converted to GB
|
|
167
|
-
|
|
168
|
-
## Backward Compatibility
|
|
169
|
-
|
|
170
|
-
- Old history files still work (missing fields treated as undefined)
|
|
171
|
-
- System-wide metrics still collected for live monitoring
|
|
172
|
-
- Live monitoring TUI unchanged (still shows system-wide for context)
|
|
173
|
-
- Only historical view changed to per-process
|
|
174
|
-
|
|
175
|
-
## Related Files
|
|
176
|
-
|
|
177
|
-
- `src/utils/process-utils.ts` - Added CPU collection functions
|
|
178
|
-
- `src/types/monitor-types.ts` - Added processCpuUsage field
|
|
179
|
-
- `src/types/history-types.ts` - Added processCpuUsage to snapshots
|
|
180
|
-
- `src/lib/metrics-aggregator.ts` - Collects CPU metrics
|
|
181
|
-
- `src/lib/history-manager.ts` - Saves CPU metrics
|
|
182
|
-
- `src/tui/HistoricalMonitorApp.ts` - Displays per-process charts
|
|
183
|
-
|
|
184
|
-
## Future Improvements
|
|
185
|
-
|
|
186
|
-
1. **Per-Process GPU:** Investigate Metal API for GPU attribution
|
|
187
|
-
2. **Network I/O:** Track per-process network usage
|
|
188
|
-
3. **Disk I/O:** Track per-process disk reads/writes
|
|
189
|
-
4. **Thread Count:** Show number of threads used by process
|
|
190
|
-
5. **Context Switches:** Show voluntary/involuntary context switches
|