Skip to content

Commit a66d2fb

Browse files
craig[bot]mgartner
andcommitted
Merge #143307
143307: slstorage: reduce allocations in `(*Storage).isAlive` r=mgartner a=mgartner Using a session ID as a key in an `cache.UnorderedCache` requires the key to be boxed as an `interface{}`, requiring an allocation. This commit combines two of these allocations into one. Epic: None Release note: None Co-authored-by: Marcus Gartner <[email protected]>
2 parents e06b49b + dbe396e commit a66d2fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/sql/sqlliveness/slstorage/slstorage.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,12 @@ func (s *Storage) isAlive(
213213
if !s.mu.started {
214214
return false, false, singleflight.Future{}, sqlliveness.NotStartedError
215215
}
216-
if _, ok := s.mu.deadSessions.Get(sid); ok {
216+
sidKey := any(sid)
217+
if _, ok := s.mu.deadSessions.Get(sidKey); ok {
217218
s.metrics.IsAliveCacheHits.Inc(1)
218219
return false, false, singleflight.Future{}, nil
219220
}
220-
if expiration, ok := s.mu.liveSessions.Get(sid); ok {
221+
if expiration, ok := s.mu.liveSessions.Get(sidKey); ok {
221222
expiration := expiration.(hlc.Timestamp)
222223
// The record exists and is valid.
223224
if s.clock.Now().Less(expiration) {

0 commit comments

Comments
 (0)