Repository navigation
Conversation
kallisti5
commented
Sep 16, 2026
- Some platforms like Haiku offer a i64 for statvfs pointers.
- The pointer-width checks don't catch i64 vs u64
- Instead of the duplicated code and excessive platform checks, prefer 'as u64' which catches all situations
* Some platforms like Haiku offer a i64 for statvfs pointers. * The pointer-width checks don't catch i64 vs u64 * Instead of the duplicated code and excessive platform checks, prefer 'as u64' which catches all situations
|
This one is based on the conversation in #14607 Cuts way, way, way down on duplicate code while preserving platform compatibility. (hopefully!)
|
|
@kallisti5 sorry, I already had fully tested changes to get |
|
In the context of fsext... I feel like this one is a little cleaner 😆 It should accomplish the same thing and work across more platforms more universally. |
|
Sorry, but I think we lose some type-safety with these simplifications. I assume the original code was structured that way for a reason. |
|
Rust is type-safe at compile though, so that doesn't really make sense. I'm 100% sure that there was a reason originally for this design choice, but everyone just stacked tech-debt on-top as they added additional platforms to support. The rest of the Haiku patches look awesome, but I feel like we have a good opportunity here to cleanup some major tech-debt in the process. @sylvestre absolutely feel free to disagree with me here though. I'm a newbie making contributions to coreutils |
|
GNU testsuite comparison: |
|
For example, this case would previously have triggered a panic on $ RUSTC_BOOTSTRAP=1 cargo clippy -q -Zbuild-std -p uucore --features fsext --all-targets --target x86_64-unknown-netbsd -- -D clippy::cast_possible_wrap
error: casting `u64` to `i64` may wrap around the value
--> src/uucore/src/lib/features/fsext/mod.rs:485:9
|
485 | self.f_bsize as i64
| ^^^^^^^^^^^^^^^^^^^ help: if this is intentional, use `cast_signed()` instead: `self.f_bsize.cast_signed()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#cast_possible_wrap |
@kallisti5 Thank you for pushing back on this. I considered your comments and made some simplifications using |
|
Binary size comparison: |
Merging this PR will regress 2 benchmarks
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | sort_dictionary_order[500000] |
1.9 s | 2.1 s | -6.43% |
| ❌ | Simulation | ls_recursive_deep_tree[(200, 2)] |
3.2 ms | 3.3 ms | -4.09% |
| ⚡ | Simulation | complex_relative_date |
397.5 µs | 287 µs | +38.49% |
| ⚡ | Simulation | check_sorted_utf8_locale |
492.2 ms | 422.9 ms | +16.4% |
| ⚡ | Simulation | sort_numeric_utf8_locale |
41.2 ms | 36.5 ms | +12.61% |
| ⚡ | Simulation | merge_single_file_utf8_locale |
133.3 ms | 119.4 ms | +11.66% |
| ⚡ | Simulation | merge_pre_sorted_files_utf8_locale |
251.9 ms | 238 ms | +5.88% |
| ⚡ | Simulation | merge_pre_sorted_files |
252.8 ms | 238.9 ms | +5.83% |
| ⚡ | Simulation | sort_case_sensitive[500000] |
339.5 ms | 325.7 ms | +4.22% |
| ⚡ | Simulation | sort_german_de_locale |
297.9 ms | 285.8 ms | +4.21% |
| ⚡ | Simulation | du_wide_tree[(5000, 500)] |
18.7 ms | 18.1 ms | +3.57% |
| ⚡ | Simulation | du_all_wide_tree[(5000, 500)] |
38.2 ms | 36.9 ms | +3.42% |
| ⚡ | Simulation | sort_spill_to_tmp_files_utf8_locale |
340.2 ms | 329.1 ms | +3.39% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing kallisti5:fxext-cleanup (8a7f8eb) with main (529f011)
Footnotes
-
50 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. ↩