Don't lock eviction parent set if it's likely empty - #1047
Open
FelixMcFelix wants to merge 2 commits into
Open
Conversation
FelixMcFelix
force-pushed
the
evict-track-parents-ll
branch
2 times, most recently
from
September 1, 2026 13:25
7d21d40 to
fb1e1ed
Compare
FelixMcFelix
marked this pull request as ready for review
September 1, 2026 13:25
FelixMcFelix
force-pushed
the
evict-track-parents-ll
branch
from
September 2, 2026 11:29
fb1e1ed to
d05b491
Compare
rcgoodfellow
self-requested a review
September 2, 2026 15:24
rcgoodfellow
approved these changes
Sep 3, 2026
|
|
||
| /// An estimate of the number of elements in [`Self::children`], used | ||
| /// to avoid locking and querying consistently empty elements. | ||
| n_children: AtomicUsize, |
Contributor
There was a problem hiding this comment.
May want to consider wrapping n_children and children up in a struct with an interface that makes it impossible for them to get out of sync. Seems like it'd be pretty easy to update children in some future PR and forget to update n_children.
This prevents us doing meaningless work when calculating eviction priority of a UFT/TCP entry while evaluating LFT candidates.
The use of `n_children` makes it a little quicker for us to early exit from eviction if we come across an entry which is genuinely expired.
FelixMcFelix
force-pushed
the
evict-track-parents-ll
branch
from
September 3, 2026 21:23
cbb091a to
96682a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
By keeping a counter outside of the locked
childrenlist, we can avoid the cost of acquiring a readlock when an entry has nothing which depends on it. This is most relevant for UFT and TCP flow table entries, which should never have any children, but calculating the eviction score for an LFT entry benefits indirectly since they calleviction_priorityfor each child.We also use this now to identify flows which have no children, and thus can be evicted because they are ready for expiry but are not cleaned up by the periodic task yet. When this occurs we can exit the eviction candidate scan early.