Commit 9c80a1d
fix(sort): GNU sort-continue.sh test (uutils#9107)
* feat: dynamically adjust merge batch size based on file descriptor limits
- Add `effective_merge_batch_size()` function to calculate batch size considering fd soft limit, with minimums and safety margins.
- Generalize fd limit handling from Linux-only to Unix systems using `fd_soft_limit()`.
- Update merge logic to use dynamic batch size instead of fixed `settings.merge_batch_size` to prevent fd exhaustion.
* fix(sort): update rlimit fetching to use fd_soft_limit with error handling
Replace direct call to get_rlimit()? with fd_soft_limit(), adding a check for None value to return a usage error if rlimit cannot be fetched. This improves robustness on Linux by ensuring proper error handling when retrieving the file descriptor soft limit.
* refactor(sort): restrict nix::libc and fd_soft_limit to Linux
Update conditional compilation attributes from #[cfg(unix)] to #[cfg(target_os = "linux")]
for the nix::libc import and fd_soft_limit function implementations, ensuring these
features are only enabled on Linux systems to improve portability and avoid issues
on other Unix-like platforms.
* refactor: improve thread management and replace unsafe libc calls
Replace unsafe libc::getrlimit calls in fd_soft_limit with safe nix crate usage.
Update Rayon thread configuration to use ThreadPoolBuilder instead of environment variables for better control.
Add documentation comment to effective_merge_batch_size function for clarity.
* refactor(linux): improve error handling in fd_soft_limit function
Extract the rlimit fetching logic into a separate `get_rlimit` function that returns `UResult<usize>` and properly handles errors with `UUsageError`, instead of silently returning `None` on failure or infinity. This provides better error reporting for resource limit issues on Linux platforms.
* refactor(sort): reorder imports in get_rlimit for consistency
Reordered the nix::sys::resource imports to group constants first (RLIM_INFINITY), then types (Resource), and finally functions (getrlimit), improving code readability and adhering to import style guidelines.1 parent 9258427 commit 9c80a1d
2 files changed
Lines changed: 70 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
65 | 87 | | |
66 | 88 | | |
67 | 89 | | |
| |||
94 | 116 | | |
95 | 117 | | |
96 | 118 | | |
97 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
98 | 123 | | |
99 | 124 | | |
100 | 125 | | |
101 | 126 | | |
102 | | - | |
| 127 | + | |
103 | 128 | | |
104 | 129 | | |
105 | | - | |
106 | | - | |
| 130 | + | |
| 131 | + | |
107 | 132 | | |
108 | | - | |
| 133 | + | |
109 | 134 | | |
110 | 135 | | |
111 | 136 | | |
| |||
115 | 140 | | |
116 | 141 | | |
117 | 142 | | |
118 | | - | |
| 143 | + | |
119 | 144 | | |
120 | 145 | | |
121 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1073 | 1073 | | |
1074 | 1074 | | |
1075 | 1075 | | |
1076 | | - | |
| 1076 | + | |
1077 | 1077 | | |
1078 | | - | |
1079 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1080 | 1084 | | |
1081 | 1085 | | |
1082 | 1086 | | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1083 | 1097 | | |
1084 | 1098 | | |
1085 | 1099 | | |
| |||
1232 | 1246 | | |
1233 | 1247 | | |
1234 | 1248 | | |
1235 | | - | |
1236 | | - | |
| 1249 | + | |
| 1250 | + | |
1237 | 1251 | | |
1238 | 1252 | | |
1239 | 1253 | | |
1240 | | - | |
| 1254 | + | |
1241 | 1255 | | |
1242 | 1256 | | |
1243 | 1257 | | |
| |||
1366 | 1380 | | |
1367 | 1381 | | |
1368 | 1382 | | |
1369 | | - | |
1370 | | - | |
1371 | | - | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
1372 | 1392 | | |
1373 | 1393 | | |
1374 | 1394 | | |
| |||
1419 | 1439 | | |
1420 | 1440 | | |
1421 | 1441 | | |
1422 | | - | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
1423 | 1451 | | |
1424 | 1452 | | |
1425 | 1453 | | |
| |||
0 commit comments