Optimizations to reduce contention for high connections in a JetStream enabled account with high API usage.

Several strategies which are listed below.

1. Checking a RaftNode to see if it is the leader now uses atomics.
2. Checking if we are the JetStream meta leader from the server now uses an atomic.
3. Accessing the JetStream context no longer requires a server lock, uses atomic.Pointer.
4. Filestore syncBlocks would hold msgBlock locks during sync, now does not.

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2023-09-30 14:52:15 -07:00
parent 15b46117af
commit dba03dbc2f
11 changed files with 127 additions and 152 deletions

View File

@@ -875,7 +875,7 @@ func (s *Server) sendStatsz(subj string) {
m.Stats.ActiveServers = len(s.sys.servers) + 1
// JetStream
if js := s.js; js != nil {
if js := s.js.Load(); js != nil {
jStat := &JetStreamVarz{}
s.mu.RUnlock()
js.mu.RLock()