Skip to content

Conversation

@wswsmao
Copy link
Contributor

@wswsmao wswsmao commented Oct 21, 2025

Problem

Testing revealed that sortEntries execution time increases significantly with larger prioritized input lists. The original implementation calls in.remove(name) for each prioritized entry, which rebuilds the entire stream (O(n) operation). When processing k prioritized files, this results in O(k·n) time complexity, causing severe performance degradation with large priority lists.

Solution

Instead of removing entries one by one, the optimized version:

  1. Uses addRec to collect prioritized entries and mark them in a picked set
  2. Performs a single O(n) filtering pass via dumpExcept to exclude marked entries
  3. Concatenates prioritized and remaining entries

Copy link
Member

@ktock ktock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ktock ktock merged commit 23f6882 into containerd:main Oct 29, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants