Use a BufWriter to wrap stdout: reduces the numbers of system calls,
improves performance drastically (2x in some cases).
Also document use cases in src/uu/seq/BENCHMARKING.md, and the
optimization we have just done here.
* GNU/CI: use the aggregated-result.json files and move to python
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
* simplify code
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
---------
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
Fix issue #7372
Rework logic for handling all-but-last-lines and all-but-last-bytes
for non-seekable files. Changes give large performance improvement.
Commit https://github.com/uutils/coreutils/pull/3396/commits/2a0d58d060eb51ee482e7e8a764f36bda21105e5 (part of https://github.com/uutils/coreutils/pull/3396 which contains a description of the changes) changed this line from libc::fsid_t to nix::sys::statfs::fsid_t.
The pull-request description at https://github.com/uutils/coreutils/pull/3396 indicates that this was done in order to fix the android build, and indeed using a cast to nix::sys::statfs::fsid_t
takes advantage of the definition of nix::sys::statfs::fsid_t which abstracts away the different name on Android:
```
/// Identifies a mounted file system
#[cfg(target_os = "android")]
pub type fsid_t = libc::__fsid_t;
/// Identifies a mounted file system
#[cfg(not(target_os = "android"))]
pub type fsid_t = libc::fsid_t;
```
This cast works as long as the libc version used by nix is the same than the libc version used by coreutils.
This cast becomes invalid when using a local libc version for local debugging, and changing Cargo.toml to point to it:
```
-libc = "0.2.153"
+libc = { path = "../path/to/libc" }
```
The cast becomes invalid because self.f_fsid is of type libc::fsid_t (local version of
libc), whereas nix::sys::statfs::fsid_t still uses the libc version downloaded
by cargo from crates.io in this case.
I was getting this error:
```
coreutils$ cargo build
Compiling libc v0.2.171 (/home/ecordonnier/dev/libc)
Compiling uucore v0.0.30 (/home/ecordonnier/dev/coreutils/src/uucore)
error[E0606]: casting `&libc::fsid_t` as `*const nix::libc::fsid_t` is invalid
--> src/uucore/src/lib/features/fsext.rs:816:25
|
816 | unsafe { &*(&self.f_fsid as *const nix::sys::statfs::fsid_t as *const [u32; 2]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0606`.
error: could not compile `uucore` (lib) due to 1 previous error
```
Let's rather use type inference to deal with libc::fsid_t vs libc::__fsid_t.
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
* Create failing test for #7455
Also update existing test to ensure output is empty.
* add ignore until relevant issue is fixed
---------
Co-authored-by: M Bussonnier <mbussonnier@gmail.com>
This removes the need for some manually duplicated code and keeps
shuf_exec() (which is generic) smaller, for less binary bloat and
better build times.
- shuf now uses OS strings, so it can read from filenames that are
invalid Unicode and it can shuffle arguments that are invalid
Unicode. `uucore` now has an `OsWrite` trait to support this without
platform-specific boilerplate.
- shuf no longer tries to split individual command line arguments,
only bulk input from a file/stdin. (This matches GNU and busybox.)
- More values are parsed inside clap instead of manually, leading to
better error messages and less code.
- Some code has been simplified or made more idiomatic.