refactor: Reduce memory consumption and simplify inner and outer subscription #5610
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explainer
So the old
OuterSubscription
is now calledComplexOuterSubscription
, andInnerSubscription
isComplexInnerSubscription
.Basically, back when we had all sorts of additional "resultSelectors" (pre v6), those result selectors relied on data that we captured with the
InnerSubscription
. After removing resultSelectors, that was no longer needed in the majority of cases, BUT it was still there to keep this "one inner subscription process to rule them all" sort of thing we had going.Unfortunately, those trapped outer values can be costly. Imagine this scenario:
In the above scenario, the subscription to
of(data)
, as a source begins and ends synchronously. BUT!!! even though we don't even use that huge array in the inner observable we return in themergeMap
, that array is retained in theInnerSubscriber
'souterValue
property, which is created by the merge map... and held, in this case, for 1,000 seconds! Not great.This PR solves that by no longer retaining the
outerValue
unless necessary.There's a long tail of one-offs that we'll need to address. But they are commented on the
ComplexOuterSubscriber
implementation and its methods.