-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IMPROVED] NumPending calculations and subject index memory in filestore #4960
Commits on Jan 16, 2024
-
Stree is an adaptive radix tree implementation used for storing and retrieving literal subjects. It also allows quick matching to wildcard subjects, which is it's major design goal along with using less memory in high subject cardinality situations. This will be used in the filestore implementation to replace the PSIM hash map which was fast at insert and lookup but suffered when trying to filter based on wildcard subjects. This is used specifically in calculations on NumPending with a wildcard, and given we push folks to use larger muxed streams with down filtered consumers and/or mirrors this was becoming a performance issue. Signed-off-by: Derek Collison <derek@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 172fb73 - Browse repository at this point
Copy the full SHA 172fb73View commit details -
Swapped out psim as a hashmap for our stree impl.
Signed-off-by: Derek Collison <derek@nats.io>
Configuration menu - View commit details
-
Copy full SHA for a5290b3 - Browse repository at this point
Copy the full SHA a5290b3View commit details
Commits on Jan 17, 2024
-
Signed-off-by: Derek Collison <derek@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 334206f - Browse repository at this point
Copy the full SHA 334206fView commit details
Commits on Jan 18, 2024
-
Remove comment that is no longer applicable
Signed-off-by: Derek Collison <derek@nats.io>
Configuration menu - View commit details
-
Copy full SHA for c0c41be - Browse repository at this point
Copy the full SHA c0c41beView commit details -
stree: Reduce allocations in
iter
andmatch
Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 8a0cbc6 - Browse repository at this point
Copy the full SHA 8a0cbc6View commit details -
stree: Reduce allocations in
iter
andmatch
(#4974)The `_pre` and `cparts` copies are more often than not unnecessary and result in potentially gigabytes of allocations which can slow down functions like `NumPending`. Passing `pre` and `nparts` down recursively without copies is usually safe, even where there are appends in those, because there is no concurrency and those appends will not modify the slice length back at the callsite. Instead we'll only reallocate either when `append` does so naturally (we've ran out of capacity) or when we know specifically that we're modifying something in-place (like in `matchParts`). This improves performance of things like `NumPending` with high subject cardinality. Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for cecd5eb - Browse repository at this point
Copy the full SHA cecd5ebView commit details
Commits on Jan 19, 2024
-
stree: Reduce heap escapes in
iter
When using `make(x, y, z)`, there is a heap escape due to the non-constant size/capacity. Try to stay on the stack instead, reducing GC pressure. Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for f40e99b - Browse repository at this point
Copy the full SHA f40e99bView commit details -
stree: Reduce heap escapes in
iter
(#4977)When using `make(x, y, z)`, there is a heap escape due to the non-constant size/capacity. Try to stay on the stack instead, reducing GC pressure. Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 6de76a4 - Browse repository at this point
Copy the full SHA 6de76a4View commit details -
Preallocate
pre
at top levelMatch
/Iter
callsIn #4974 I removed preallocated buffers for `pre` as the copies were unnecessary on each single recursion, however it turns out that having a preallocation up front removes quite a few unnecessary allocations from subject construction, relieving further pressure on the GC. Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 5919557 - Browse repository at this point
Copy the full SHA 5919557View commit details -
stree: Preallocate
pre
at top levelMatch
/Iter
calls (#4978)In #4974 I removed preallocated buffers for `pre` as the copies were unnecessary on each single recursion, however it turns out that having a preallocation up front removes quite a few unnecessary allocations from subject construction as the underlying memory gets reused throughout the iteration or match process, relieving further pressure on the GC. Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for e309831 - Browse repository at this point
Copy the full SHA e309831View commit details -
Signed-off-by: Neil Twigg <neil@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 30baeba - Browse repository at this point
Copy the full SHA 30baebaView commit details
Commits on Jan 20, 2024
-
Iteration across a node's children was slower than expected and creat…
…ing memory for the GC. The solution was to have a node return its children as a []node. Since node256 is sparse the upper layers need to check for nil, but this improved the performance. Signed-off-by: Derek Collison <derek@nats.io>
Configuration menu - View commit details
-
Copy full SHA for 90a8897 - Browse repository at this point
Copy the full SHA 90a8897View commit details