Skip to content

Commit

Permalink
cache of events improvement
Browse files Browse the repository at this point in the history
don't reset/recalculate checksums on every configuration change, only if
the checksums config item has changed.
  • Loading branch information
gustavo-iniguez-goya committed Dec 12, 2023
1 parent 431e2d3 commit 0207e3a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions daemon/procmon/cache_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (e *EventsStore) ReplaceItem(oldProc, newProc *Process) {
// Note: in rare occasions, the process being replaced is the older one.
// if oldProc.Starttime > newProc.Starttime {}
//

newProc.PPID = oldProc.ID
e.UpdateItem(newProc)

Expand Down Expand Up @@ -307,14 +308,20 @@ func (e *EventsStore) SetComputeChecksums(compute bool) {
e.mu.Lock()
defer e.mu.Unlock()

if compute == e.checksumsEnabled {
log.Debug("SetComputeChecksums(), no changes (%v, %v)", e.checksumsEnabled, compute)
return
}
e.checksumsEnabled = compute
if !compute {
log.Debug("SetComputeChecksums() disabled, deleting saved checksums")
for _, item := range e.eventByPID {
// XXX: reset saved checksums? or keep them in cache?
item.Proc.ResetChecksums()
}
return
}
log.Debug("SetComputeChecksums() enabled, recomputing cached checksums")
for _, item := range e.eventByPID {
if item.Proc.ChecksumsCount() == 0 {
item.Proc.ComputeChecksums(e.checksums)
Expand Down

0 comments on commit 0207e3a

Please sign in to comment.