[arvados] updated: 2.1.0-2871-g193ebedab
git repository hosting
git at public.arvados.org
Fri Sep 2 14:29:42 UTC 2022
Summary of changes:
services/keep-web/cache.go | 34 +++++++++-------------------------
1 file changed, 9 insertions(+), 25 deletions(-)
via 193ebedab37c71170f649308732fe0a18d7d2ba6 (commit)
from 2c0638b0444652591fa18d6cae2d1977ee5e5731 (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 193ebedab37c71170f649308732fe0a18d7d2ba6
Author: Tom Clegg <tom at curii.com>
Date: Fri Sep 2 10:28:52 2022 -0400
19428: Tidy up pruneSessions, avoid calling MemorySize 2x.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/services/keep-web/cache.go b/services/keep-web/cache.go
index b08abad85..7ec8639ab 100644
--- a/services/keep-web/cache.go
+++ b/services/keep-web/cache.go
@@ -274,9 +274,10 @@ func (c *cache) GetSession(token string) (arvados.CustomFileSystem, *cachedSessi
// until approximate remaining size <= maxsize/2
func (c *cache) pruneSessions() {
now := time.Now()
- var size int64
keys := c.sessions.Keys()
- for idx, token := range keys {
+ sizes := make([]int64, len(keys))
+ var size int64
+ for i, token := range keys {
ent, ok := c.sessions.Peek(token)
if !ok {
continue
@@ -284,37 +285,20 @@ func (c *cache) pruneSessions() {
s := ent.(*cachedSession)
if s.expire.Before(now) {
c.sessions.Remove(token)
- keys[idx] = ""
continue
}
if fs, ok := s.fs.Load().(arvados.CustomFileSystem); ok {
- size += fs.MemorySize()
+ sizes[i] = fs.MemorySize()
+ size += sizes[i]
}
}
// Remove tokens until reaching size limit, starting with the
// least frequently used entries (which Keys() returns last).
- for i := len(keys) - 1; i >= 0; i-- {
- token := keys[i]
- if token == "" {
- // removed this session in the loop above;
- // don't prune it, even if it's already been
- // reinserted.
- continue
- }
- if size <= c.cluster.Collections.WebDAVCache.MaxCollectionBytes/2 {
- break
- }
- ent, ok := c.sessions.Peek(token)
- if !ok {
- continue
- }
- s := ent.(*cachedSession)
- fs, _ := s.fs.Load().(arvados.CustomFileSystem)
- if fs == nil {
- continue
+ for i := len(keys) - 1; i >= 0 && size > c.cluster.Collections.WebDAVCache.MaxCollectionBytes/2; i-- {
+ if sizes[i] > 0 {
+ c.sessions.Remove(keys[i])
+ size -= sizes[i]
}
- c.sessions.Remove(token)
- size -= fs.MemorySize()
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list