From 681e4c4977855e37c70086742276ded217ad8d95 Mon Sep 17 00:00:00 2001 From: Alex Aizman Date: Sat, 17 Aug 2024 11:40:40 -0400 Subject: [PATCH] core: 'uname' is a pointer * fix lcache re-caching * regression: e6045456d449c Signed-off-by: Alex Aizman --- cmn/cos/log_module.go | 2 +- core/lcache.go | 27 ++++++++++++++------------- core/lom.go | 24 ++++++++++++++++-------- core/lom_xattr.go | 2 +- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/cmn/cos/log_module.go b/cmn/cos/log_module.go index 61e652f5c0f..460bd603b99 100644 --- a/cmn/cos/log_module.go +++ b/cmn/cos/log_module.go @@ -19,7 +19,7 @@ const ( SmoduleTransport = 1 << iota SmoduleAIS SmoduleMemsys - SmoduleCluster + SmoduleCore SmoduleFS SmoduleReb SmoduleEC diff --git a/core/lcache.go b/core/lcache.go index e7c30690241..c1eef030e7b 100644 --- a/core/lcache.go +++ b/core/lcache.go @@ -89,17 +89,19 @@ func UncacheMountpath(mi *fs.Mountpath) { // lchk // ////////// -func (lchk *lchk) housekeep() (d time.Duration) { - var tag string - d, tag = lchk.mp() +func (lchk *lchk) housekeep() time.Duration { + d, tag := lchk.mp() if !lchk.running.CAS(false, true) { - if tag != "" { - nlog.Infof("running now: memory pressure %q, next sched %v", tag, d) - } - return + nlog.Infoln("running now; memory pressure:", tag, "next HK:", d) + return d } - go lchk.evictAll(d /*evict older than*/) - return + + go func(d time.Duration) { + lchk.evictOlder(d) + lchk.running.Store(false) + }(d) + + return d } const termDuration = time.Duration(-1) @@ -124,7 +126,7 @@ func (*lchk) mp() (d time.Duration, tag string) { return } -func (lchk *lchk) evictAll(d time.Duration) { +func (lchk *lchk) evictOlder(d time.Duration) { lchk.now = time.Now() lchk.d = d @@ -133,6 +135,7 @@ func (lchk *lchk) evictAll(d time.Duration) { // single-threaded: one cache at a time caches := lomCaches() if lchk.terminating() { + nlog.Infoln("terminating -->") for _, cache := range caches { lchk.cache = cache cache.Range(lchk.fterm) @@ -146,14 +149,12 @@ func (lchk *lchk) evictAll(d time.Duration) { } if _, tag := lchk.mp(); tag != "" { - nlog.Infof("memory pressure %q, total %d, evicted %d", tag, lchk.totalCnt, lchk.evictedCnt) + nlog.Infoln("post-evict memory pressure:", tag, "total:", lchk.totalCnt, "evicted:", lchk.evictedCnt) } // stats g.tstats.Add(LcacheEvictedCount, lchk.evictedCnt) g.tstats.Add(LcacheFlushColdCount, lchk.flushColdCnt) - - lchk.running.Store(false) } func (lchk *lchk) fterm(_, value any) bool { diff --git a/core/lom.go b/core/lom.go index 53ff7eaf8d1..b46b2275c5c 100644 --- a/core/lom.go +++ b/core/lom.go @@ -20,6 +20,7 @@ import ( "github.com/NVIDIA/aistore/cmn/cos" "github.com/NVIDIA/aistore/cmn/debug" "github.com/NVIDIA/aistore/cmn/feat" + "github.com/NVIDIA/aistore/cmn/nlog" "github.com/NVIDIA/aistore/core/meta" "github.com/NVIDIA/aistore/fs" "github.com/NVIDIA/aistore/ios" @@ -117,7 +118,7 @@ func Term() { for i := 0; i < 8 && !g.lchk.running.CAS(false, true); i++ { time.Sleep(sleep) } - g.lchk.evictAll(termDuration) + g.lchk.evictOlder(termDuration) } ///////// @@ -483,7 +484,7 @@ func (lom *LOM) LoadUnsafe() (err error) { // store new or refresh existing func (lom *LOM) Recache() { debug.Assert(!lom.IsCopy()) - lom.setbid(lom.Bprops().BID) // TODO -- FIXME: 52 bits + lom.setbid(lom.Bprops().BID) md := lom.md @@ -493,14 +494,21 @@ func (lom *LOM) Recache() { return } lmd := val.(*lmeta) - if lmd.uname != lom.md.uname { - g.tstats.Inc(LcacheCollisionCount) // target stats + if *lmd.uname != *lom.md.uname { + lom._collide(lmd) } else { // updating the value that's already in the map (race extremely unlikely, benign anyway) md.cpAtime(lmd) } } +func (lom *LOM) _collide(lmd *lmeta) { + if cmn.Rom.FastV(4, cos.SmoduleCore) || (lom.digest%17) == 5 { + nlog.InfoDepth(1, LcacheCollisionCount, lom.digest, "[", *lmd.uname, "]", *lom.md.uname, lom.Cname()) + } + g.tstats.Inc(LcacheCollisionCount) +} + func (lom *LOM) Uncache() { lcache := lom.lcache() md, ok := lcache.LoadAndDelete(lom.digest) @@ -508,8 +516,8 @@ func (lom *LOM) Uncache() { return } lmd := md.(*lmeta) - if lmd.uname != lom.md.uname { - g.tstats.Inc(LcacheCollisionCount) // target stats + if *lmd.uname != *lom.md.uname { + lom._collide(lmd) } else { lom.md.cpAtime(lmd) } @@ -534,8 +542,8 @@ func (lom *LOM) fromCache() (lcache *sync.Map, lmd *lmeta) { lcache = lom.lcache() if md, ok := lcache.Load(lom.digest); ok { lmd = md.(*lmeta) - if lmd.uname != lom.md.uname { - g.tstats.Inc(LcacheCollisionCount) // target stats + if *lmd.uname != *lom.md.uname { + lom._collide(lmd) } } return diff --git a/core/lom_xattr.go b/core/lom_xattr.go index 5433290d00a..d2c1b3ce498 100644 --- a/core/lom_xattr.go +++ b/core/lom_xattr.go @@ -390,7 +390,7 @@ func (md *lmeta) unpack(buf []byte) error { mpathInfo, _, err := fs.FQN2Mpath(copyFQN) if err != nil { // Mountpath with the copy is missing. - if cmn.Rom.FastV(4, cos.SmoduleCluster) { + if cmn.Rom.FastV(4, cos.SmoduleCore) { nlog.Warningln(err) } // For utilities and tests: fill the map with mpath names always