-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
We currently send alerts at every eval interval, and we sent alerts synchronously, see https://github.com/prometheus/alertmanager/blob/master/dispatch/dispatch.go#L371-L373, so when the reader read alerts from channel, it will not continue to read next alert until it successfully send the alert to all kinds of clients. And as we all know sending alert message to clients involve networking, which is slow. So, consumer can not catch up with producer, thus the channel will saturate.
Then, I propose to send alerts asynchronously:
// current synchronous code at https://github.com/prometheus/alertmanager/blob/master/dispatch/dispatch.go#L371-L373
ag.flush(func(alerts ...*types.Alert) bool {
return nf(ctx, alerts...)
})
// asynchronous code I propose:
go func() {
ag.flush(func(alerts ...*types.Alert) bool {
return nf(ctx, alerts...)
})
}()With this simple optimization, the runtime.mach_semaphore_signal time can decrease from 33.3% to 16.6%
mxinden and skorpy2009

