[arvados] updated: 2.5.0-43-g7d3a6de4e

git repository hosting git at public.arvados.org
Fri Jan 27 18:31:10 UTC 2023


Summary of changes:
 services/keep-balance/balance.go | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

       via  7d3a6de4ee5afb635e561c75d4f99d1067f030f2 (commit)
      from  1ddc21430ede024aa6841e6c49deafe87788c287 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 7d3a6de4ee5afb635e561c75d4f99d1067f030f2
Author: Tom Clegg <tom at curii.com>
Date:   Fri Jan 27 13:30:09 2023 -0500

    19923: Report heap and stack stats from Go runtime.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/services/keep-balance/balance.go b/services/keep-balance/balance.go
index ef15ea070..33c907c20 100644
--- a/services/keep-balance/balance.go
+++ b/services/keep-balance/balance.go
@@ -1228,26 +1228,42 @@ func (bal *Balancer) reportMemorySize(ctx context.Context) {
 		pagesize <<= 10
 	}
 	if pagesize == 0 {
-		bal.logf("cannot report memory size: failed to parse KernelPageSize from /proc/self/smaps")
-		return
+		bal.logf("cannot log OS-reported memory size: failed to parse KernelPageSize from /proc/self/smaps")
+	}
+	osstats := func() string {
+		if pagesize == 0 {
+			return ""
+		}
+		buf, _ := os.ReadFile("/proc/self/statm")
+		fields := strings.Split(string(buf), " ")
+		if len(fields) < 2 {
+			return ""
+		}
+		virt, _ := strconv.ParseInt(fields[0], 10, 64)
+		virt *= pagesize
+		res, _ := strconv.ParseInt(fields[1], 10, 64)
+		res *= pagesize
+		if virt == 0 || res == 0 {
+			return ""
+		}
+		return fmt.Sprintf(" virt %d res %d", virt, res)
 	}
 
 	var nextTime time.Time
-	var nextMem int64
+	var nextMem uint64
 	const maxInterval = time.Minute * 10
 	const maxIncrease = 1.4
 
 	ticker := time.NewTicker(time.Second)
 	defer ticker.Stop()
+	var memstats runtime.MemStats
 	for ctx.Err() == nil {
 		now := time.Now()
-		buf, _ := os.ReadFile("/proc/self/statm")
-		fields := strings.Split(string(buf), " ")
-		mem, _ := strconv.ParseInt(fields[0], 10, 64)
-		mem *= pagesize
+		runtime.ReadMemStats(&memstats)
+		mem := memstats.StackInuse + memstats.HeapInuse
 		if now.After(nextTime) || mem >= nextMem {
-			bal.logf("process virtual memory size %d", mem)
-			nextMem = int64(float64(mem) * maxIncrease)
+			bal.logf("heap %d stack %d heapalloc %d%s", memstats.HeapInuse, memstats.StackInuse, memstats.HeapAlloc, osstats())
+			nextMem = uint64(float64(mem) * maxIncrease)
 			nextTime = now.Add(maxInterval)
 		}
 		<-ticker.C

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list