fix: replace gotextdiff with linear-space Myers diff to prevent OOM#2311
Merged
talos-bot merged 1 commit intosiderolabs:mainfrom Feb 12, 2026
Merged
Conversation
smira
approved these changes
Feb 12, 2026
oguzkilcan
approved these changes
Feb 12, 2026
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 12, 2026
See siderolabs/omni#2311 for the rationale. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
490c6c1 to
c9c58a7
Compare
c9c58a7 to
0743b99
Compare
Unix4ever
approved these changes
Feb 12, 2026
The gotextdiff/myers library uses the naive Myers algorithm variant that stores the full edit trace, resulting in O((M+N)^2) space complexity. For machine configs with large inline K8s manifests (thousands of lines), this causes massive memory spikes — e.g., 80K lines allocates ~98 GB and gets OOM-killed. Replace it with neticdk/go-stdlib/diff/myers which implements the linear-space Myers variant (divide-and-conquer). Memory usage drops from ~25 GB to ~8 MB for 40K-line inputs. The diff output format is unchanged (unified diff with @@ hunks). Co-authored-by: Artem Chernyshev <artem.chernyshev@talos-systems.com> Co-authored-by: Oguz Kilcan <oguz.kilcan@siderolabs.com> Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
0743b99 to
a89d270
Compare
Member
Author
|
The output of the memory budget test is below. Set the hard threshold to be 50MBs, and the highest allocation with our current tweaks and 75K limit is |
Member
Author
|
/m |
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 13, 2026
See siderolabs/omni#2311 for the rationale. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Feb 18, 2026
See siderolabs/omni#2311 for the rationale. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
smira
added a commit
to smira/talos
that referenced
this pull request
Mar 6, 2026
See siderolabs/omni#2311 for the rationale. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 35ad044)
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.
The gotextdiff/myers library uses the naive Myers algorithm variant that stores the full edit trace, resulting in O((M+N)^2) space complexity.
For machine configs with large inline K8s manifests (thousands of lines), this causes massive memory spikes — e.g., 80K lines allocates ~98 GB and gets OOM-killed.
Replace it with neticdk/go-stdlib/diff/myers which implements the linear-space Myers variant (divide-and-conquer). Memory usage drops from ~25 GB to ~8 MB for 40K-line inputs.
The diff output format is unchanged (unified diff with @@ hunks).