Skip to content

yes: separate platform-specific output implementations - #15478

Merged
sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/yes-platform-modules-12371
Oct 19, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
limadog9:fix/yes-platform-modules-12371

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

Move the Linux/Android output loop and buffer size into linux.rs, and the portable writer into portable.rs. Keep command parsing and buffer preparation in yes.rs and re-export the existing exec entry point.

Validation: 10 integration tests and 1 unit test pass; formatting, Clippy, and macOS/FreeBSD compilation checks pass.

Closes #12371

Comment on lines +8 to +9
// it's possible that using a smaller or larger buffer might provide better performance
pub(super) const BUF_SIZE: usize = 16 * 1024;

@anastygnome anastygnome Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use st_blksize on stdout ? Otherwise, after some tests I suggest 64*1024 for performance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is platform specific pipe size. Someone said Windows's pipe is very small.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes > file should use larger size.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Don't you use yes | pv > /dev/null on Linux or Android if you tune this)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we aren't on a pipe maybe the extra syscall to get the blksize is worth it ? In any case, maybe the pipe size should be a platform specific const ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use yes for pipe, we need 1st few byte to tell y to script at most cases.
Otherwise yes is used for generating large test data or wiping strage device quickly.
So we could send 1st (page size) and switch to 64 KiB later as fast-path.

But this PR should not improve perf.

Comment thread src/uu/yes/src/yes.rs Outdated
// it's possible that using a smaller or larger buffer might provide better performance
#[cfg(not(any(target_os = "linux", target_os = "android")))]
const BUF_SIZE: usize = 16 * 1024;
#[cfg_attr(any(target_os = "linux", target_os = "android"), path = "linux.rs")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please move them to src/platform/ like the other utils? and two plain #[cfg] #[path] lines like nohup would be easier to read than cfg_attr

@limadog9
limadog9 force-pushed the fix/yes-platform-modules-12371 branch from 3885bc7 to ce5bac8 Compare October 18, 2026 22:36
Comment thread src/uu/yes/src/yes.rs Outdated
use std::ffi::OsString;
use std::io::{self, Write};
#[cfg(any(windows, target_os = "wasi"))]
use std::io;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please drop this cfg'd import and use std::io::ErrorKind::BrokenPipe directly below?

Move the Linux/Android output loop and buffer size into linux.rs, and
the portable writer into portable.rs. Keep command parsing and buffer
preparation in yes.rs and re-export the existing exec entry point.

Validation: 10 integration tests and 1 unit test pass; formatting,
Clippy, and macOS/FreeBSD compilation checks pass.

Closes uutils#12371
@limadog9
limadog9 force-pushed the fix/yes-platform-modules-12371 branch from ce5bac8 to e295ef3 Compare October 19, 2026 10:06
@limadog9

Copy link
Copy Markdown
Contributor Author
simplified the yes import

@sylvestre
sylvestre merged commit b320003 into uutils:main Oct 19, 2026
99 of 100 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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.

yes: split Linux specific code for readability

4 participants