You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the pool uses a slice and appends and pops connections from the end of the slice (LIFO mode). There is also the FIFO mode, where the code copies the data just to pop an element from the beginning of the slice. Code:
// Note that FIFO has slightly higher overhead compared to LIFO,
// but it helps closing idle connections faster reducing the pool size.
PoolFIFObool
Why not use a doubly linked list?
The pool.Conn can be embedded into an element struct as is (not a pointer) and then we'd avoid extra allocations for the holder elements. All typical operations will be O(1) - append, prepend. Removal from the middle will be O(n) just like it is today, but only because of the list traversal - no copying will be necessary
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently the pool uses a slice and appends and pops connections from the end of the slice (LIFO mode). There is also the FIFO mode, where the code copies the data just to pop an element from the beginning of the slice. Code:
go-redis/internal/pool/pool.go
Lines 326 to 348 in fcb3506
This copying is not efficient, as documented:
go-redis/options.go
Lines 93 to 97 in fcb3506
Why not use a doubly linked list?
The
pool.Conn
can be embedded into anelement
struct as is (not a pointer) and then we'd avoid extra allocations for the holder elements. All typical operations will be O(1) - append, prepend. Removal from the middle will be O(n) just like it is today, but only because of the list traversal - no copying will be necessaryWDYT?.
Beta Was this translation helpful? Give feedback.
All reactions