From 4c331656ef5d04d685ddbc2efb15b7ef8dd675cf Mon Sep 17 00:00:00 2001 From: Justin C Presley Date: Fri, 16 Feb 2024 18:55:33 -0600 Subject: [PATCH] faster detection if a interest is needed after suppression --- docs/CHANGELOG.md | 1 + pkg/svs/twostate_core.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 22bb990..1412a59 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] ## Changed +- After a SVS `Core` exits `Suppression` state, more efficiently detect if a Sync Interest needs to be sent. - De-interface small simple structures: `MissingData` and `StatusChange`. - Reorganized functions to match interface method order. - Changed naming of a constant variable to be more consistent with others that function the same. diff --git a/pkg/svs/twostate_core.go b/pkg/svs/twostate_core.go index a1fcdeb..0322f3e 100644 --- a/pkg/svs/twostate_core.go +++ b/pkg/svs/twostate_core.go @@ -258,20 +258,19 @@ func (c *twoStateCore) recordVector(vector StateVector) { } func (c *twoStateCore) mergeRecordToLocal() bool { - var isNewer bool c.localMtx.Lock() - for p := c.record.Entries().Back(); p != nil; p = p.Prev() { + defer c.localMtx.Unlock() + if c.record.Len() < c.local.Len() { + return true + } + for p := c.record.Entries().Front(); p != nil; p = p.Next() { if c.local.Get(p.Kstr) > p.Val && !slices.Contains(c.selfsets, p.Kstr) { if !c.effSuppress || time.Since(c.updateTimes[p.Kstr]) >= c.constants.SuppressionInterval { - isNewer = true + return true } } } - if c.record.Len() < c.local.Len() { - isNewer = true - } - c.localMtx.Unlock() - return isNewer + return false } func suppressionDelay(val time.Duration, jitter float32) time.Duration {