Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid FluxReplay buffer retaining/leaking with tiny TTL (#2998)
This commit eliminates two sources of over-retaining with TTL Duration less than 1ms. It is fixing the add method, which also attempts to clear up outdated nodes from the linked data structure. First it treats the Duration.ZERO case as a fast path that will directly set the head to the newly added node. Even if it is technically outdated it is the only one that needs to be kept around because it must remain visible to the subsequent `replay` call to the active subscribers. Second, it ensures that if the whole list is traversed without finding a node which `time` is greater than the limit, the head is still moved to the newly added node. This is more of a corner case where the TTL is small enough that valueNode's time is not > limit. Both changes avoid marking most nodes as removable while skipping the actual removal, which can lead to degraded performance and memory pressure when a lot of elements are added to the buffer. In addition, this commit reworks and improve the FluxReplayTest cases (reorganized test order, removed VirtualTimeScheduler unless strictly needed, turned info-level logging to debug-level). Fixes #2994.
- Loading branch information