Use strong references for JTF dependencies. #847
Merged
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.
Consider in Dev 17.
Move away from WeakReferenceDictionary, and switch to strong reference in JTF dependency graph. This would reduce the complexity/overhead of the data structure & also makes it much easier to walk through the dependencies tree in a debug session.
Weak reference gives very little value to us here, because:
1, all incompleted JTF tasks are referenced by a global strong reference table inside JTF Context, so a weak reference to them will lead them to be GCed.
2, when JTF task is completed, it always removes itself from the graph
Basically, a weak reference to a JTF task inside JTF dependency graph never gives any memory benefit.
A weak reference to a JTF Collection does give some benefit, if it is no longer used and empty, but is still held by a not completed JTF task (Joins to a collection). In that case, the weak reference does allow the JTF collection to be GCed. But in the real product, this is fairly rare, and the memory usage of an empty JTF collection is limited, comparing the overhead of using weak reference dictionary in all JTF tasks/collections to track their dependencies.
(Thought about the change for a while, it sounds to me Dev 17 is a good time for it.)