mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
[IMPROVED] Publish performance with lots of no interest subjects (#4359)
Do not hold onto no interest subjects from a client in the unlocked cache. If sending lots of different subjects all with no interest performance could be affected. Signed-off-by: Derek Collison <derek@nats.io> Resolves #4341
This commit is contained in:
@@ -3670,14 +3670,16 @@ func (c *client) processInboundClientMsg(msg []byte) (bool, bool) {
|
||||
// Go back to the sublist data structure.
|
||||
if !ok {
|
||||
r = acc.sl.Match(string(c.pa.subject))
|
||||
c.in.results[string(c.pa.subject)] = r
|
||||
// Prune the results cache. Keeps us from unbounded growth. Random delete.
|
||||
if len(c.in.results) > maxResultCacheSize {
|
||||
n := 0
|
||||
for subject := range c.in.results {
|
||||
delete(c.in.results, subject)
|
||||
if n++; n > pruneSize {
|
||||
break
|
||||
if len(r.psubs)+len(r.qsubs) > 0 {
|
||||
c.in.results[string(c.pa.subject)] = r
|
||||
// Prune the results cache. Keeps us from unbounded growth. Random delete.
|
||||
if len(c.in.results) > maxResultCacheSize {
|
||||
n := 0
|
||||
for subject := range c.in.results {
|
||||
delete(c.in.results, subject)
|
||||
if n++; n > pruneSize {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ const (
|
||||
// cacheMax is used to bound limit the frontend cache
|
||||
slCacheMax = 1024
|
||||
// If we run a sweeper we will drain to this count.
|
||||
slCacheSweep = 512
|
||||
slCacheSweep = 256
|
||||
// plistMin is our lower bounds to create a fast plist for Match.
|
||||
plistMin = 256
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user