nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
16k stars 1.41k forks source link

Use interest-based intersection for `NumPendingMulti` #6112

Closed neilalexander closed 1 week ago

neilalexander commented 1 week ago

This optimises #6089 by ensuring that we don't over-walk either the sublist or the subject tree, instead only matching the subject tree on subjects for which the sublist expresses interest.

On my machine, in the JetStreamConsumeWithFilters benchmark with -benchtime 1000x, this reduces the CPU time taken by NumPendingMulti by 19.41 seconds, reducing it to only 0.06 seconds.

Signed-off-by: Neil Twigg neil@nats.io