Skip to content

ls: properly release parent nodes in DFS#11465

Open
Alonely0 wants to merge 3 commits intouutils:mainfrom
Alonely0:fix-ls-rec
Open

ls: properly release parent nodes in DFS#11465
Alonely0 wants to merge 3 commits intouutils:mainfrom
Alonely0:fix-ls-rec

Conversation

@Alonely0
Copy link
Contributor

@Alonely0 Alonely0 commented Mar 23, 2026

Fixes a regression introduced in #11386 (sorry) where DFS nodes did not properly free the recorded inodes of the parent directories. This caused critical errors in some instances of recursive hard links, and made memory usage increase with a combinatorical explosion.

@oech3
Copy link
Contributor

oech3 commented Mar 23, 2026

Would you add test?

@Alonely0
Copy link
Contributor Author

Would you add test?

I'm not even sure of how to build a minimum reproducible example lol, but I'll try. I found this by dumb luck.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 23, 2026

Merging this PR will degrade performance by 5.35%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 6 improved benchmarks
❌ 2 regressed benchmarks
✅ 292 untouched benchmarks
⏩ 46 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory ls_recursive_long_all_deep_tree[(100, 4)] 126.3 KB 107.8 KB +17.12%
Memory ls_recursive_mixed_tree 133 KB 122.5 KB +8.55%
Memory ls_recursive_balanced_tree[(6, 4, 15)] 1,817.8 KB 117.3 KB ×15
Memory ls_recursive_deep_tree[(200, 2)] 143.3 KB 106.9 KB +33.98%
Memory ls_recursive_long_all_balanced_tree[(6, 4, 15)] 1,988.5 KB 288 KB ×6.9
Memory ls_recursive_long_all_mixed_tree 133.6 KB 123.1 KB +8.51%
Simulation ls_recursive_wide_tree[(10000, 1000)] 35.3 ms 36.5 ms -3.27%
Simulation ls_recursive_balanced_tree[(6, 4, 15)] 51.8 ms 54.8 ms -5.35%

Comparing Alonely0:fix-ls-rec (a2cacf1) with main (e0f0318)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Alonely0
Copy link
Contributor Author

It appears this fixes this fully fixes the insane memory consumption introduced by the DFS PR lol.

@Alonely0
Copy link
Contributor Author

Alonely0 commented Mar 23, 2026

Would you add test?

I've discovered I can't since this relies on hard links of directories, which are not a thing on most filesystems.

@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/retry. tests/tail/retry is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/tail/pipe-f2 is no longer failing!
Congrats! The gnu test tests/tail/tail-n0f is now passing!

Fixes a regression introduced in uutils#11386 (sorry) where DFS nodes did not properly free the recorded inodes of the parent directories, causing critical errors in some instances of recursive symlinks.
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.

@oech3
Copy link
Contributor

oech3 commented Mar 24, 2026

Windows has many hardlinks on WinSxS, or you can make hardlink at tests.

Depending on the sorting it would not, so it could recurse back through `..`.
@Alonely0
Copy link
Contributor Author

Pushed a quick fix of a bug I found while writing the test lol

@oech3
Copy link
Contributor

oech3 commented Mar 24, 2026

Add WINDIR to spell-checker: ignore

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/cp/link-heap is now being skipped but was previously passing.

@oech3
Copy link
Contributor

oech3 commented Mar 24, 2026

thread 'test_ls::test_ls_recursive_hardlink_cycles' (8648) panicked at tests\uutests\src\lib\util.rs:2000:35:
called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "wait: Timeout of '30s' reached" }

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