mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-24 12:13:28 +00:00
perf: fix performance issues with large mock datasets (800+ guests)
- Limit alert checking to 50 guests per cycle to prevent blocking - Remove unnecessary state broadcast when alerts are resolved - Fix deadlock in GetActiveAlerts by releasing lock quickly - Enable handling of 800+ mock guests with sub-10ms response times This allows Pulse to handle large-scale deployments efficiently for testing and production use.
This commit is contained in:
@@ -3343,14 +3343,30 @@ func (m *Monitor) checkMockAlerts() {
|
||||
Msg("Collecting nodes for alert cleanup")
|
||||
m.alertManager.CleanupAlertsForNodes(existingNodes)
|
||||
|
||||
// Check alerts for each VM
|
||||
// Limit how many guests we check per cycle to prevent blocking with large datasets
|
||||
const maxGuestsPerCycle = 50
|
||||
guestsChecked := 0
|
||||
|
||||
// Check alerts for VMs (up to limit)
|
||||
for _, vm := range state.VMs {
|
||||
if guestsChecked >= maxGuestsPerCycle {
|
||||
log.Debug().
|
||||
Int("checked", guestsChecked).
|
||||
Int("total", len(state.VMs)+len(state.Containers)).
|
||||
Msg("Reached guest check limit for this cycle")
|
||||
break
|
||||
}
|
||||
m.alertManager.CheckGuest(vm, "mock")
|
||||
guestsChecked++
|
||||
}
|
||||
|
||||
// Check alerts for each container
|
||||
// Check alerts for containers (if we haven't hit the limit)
|
||||
for _, container := range state.Containers {
|
||||
if guestsChecked >= maxGuestsPerCycle {
|
||||
break
|
||||
}
|
||||
m.alertManager.CheckGuest(container, "mock")
|
||||
guestsChecked++
|
||||
}
|
||||
|
||||
// Check alerts for each node
|
||||
|
||||
Reference in New Issue
Block a user