-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce memory hoarding in the unit test #2028
base: main
Are you sure you want to change the base?
Reduce memory hoarding in the unit test #2028
Conversation
Various internal caches in the origin/cache monitoring were filling with temporary session information, causing unpredictable results in the memory "stress test" unit tests. This commit: - Allows monitoring to be turned off completely if desired; labelled as a hidden variable. - Removes the user ID from the users cache as soon as it is used. Since there's a single use case - and no other indication the user ID cache entry isn't needed - we remove it here. - Reduce redundant calls into the ttlcache.
Reduces churn of objects on the heap observed in memory profiles
// Remove the user id record as this is the only use for it; otherwise, it'll sit around in the cache, | ||
// using memory. | ||
userids.Delete(xrdUserId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the userids.Get
up a line 624?
existingRec := sessions.Get(userId).Value() | ||
item, found := sessions.GetOrSet(userId, UserRecord{Project: project, Host: xrdUserId.Host}, ttlcache.WithTTL[UserId, UserRecord](ttlcache.DefaultTTL)) | ||
if found { | ||
existingRec := item.Value() | ||
existingRec.Project = project | ||
existingRec.Host = xrdUserId.Host | ||
sessions.Set(userId, existingRec, ttlcache.DefaultTTL) | ||
} else { | ||
sessions.Set(userId, UserRecord{Project: project, Host: xrdUserId.Host}, ttlcache.DefaultTTL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this now redundant with the sessions.GetOrSet
above?
I modified the test to run for 10,000 iterations, and collected one profile without this PR's changes ( The reduction in allocations:
The reduction in live heap:
|
This PR reduces memory hoarding and memory churn by: