tee: improve throughput by raw syscall#12131
Conversation
|
is it possible to have a codspeed benchmark to evaluate the win? |
This comment was marked as resolved.
This comment was marked as resolved.
|
i asked on discord |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
GNU testsuite comparison: |
72a2adc to
e81feb1
Compare
|
The fn write(&mut self, buf: &[u8]) -> Result<()>Additionally, avoiding |
This comment was marked as resolved.
This comment was marked as resolved.
|
This impl is because |
|
I still think its's confusing to implement |
This comment was marked as resolved.
This comment was marked as resolved.
|
I was thinking something like this: b0edaae |
|
No. Because write syscall does not guarantee writing everything. Needs loop and take sum of returned values. |
|
It would solve many problems if we could use |
|
Private? Is it need to copy and paste unsafe code to uucore? |
|
The issue we’re working around is that |
|
https://docs.rs/rustix/latest/rustix/stdio/fn.stdout.html but unix only... |
|
We already have a solution in |
This comment was marked as resolved.
This comment was marked as resolved.
|
We cannot use it #12157 |
Merging this PR will improve performance by ×17
Performance Changes
Comparing Footnotes
|
|
+syscall time is still better |
This comment was marked as resolved.
This comment was marked as resolved.
fe34eec to
fe4aba2
Compare
|
Windows example (with unsafe) is rust-lang/rust#58326 (comment) and rust-lang/rust#58326 (comment) |
This comment was marked as outdated.
This comment was marked as outdated.
fc1e944 to
ce98ec5
Compare
|
I would have expected |
|
raw means raw-syscall. |
|
Considering most API is buffered, I think |
It would be better to move it to a new |
|
I think new module for 1 fn is overkill and causing confusion as it is clearly |
|
How naming it pub trait WriteFdExt: AsFd {
fn write_all_fd(&self, buf: &[u8]) -> io::Result<()> { ... }
}
impl<T: AsFd + ?Sized> WriteFdExt for T {} |
|
|
|
I'll rename it to something after several PRs depending on it were merged (to avoid CI breakage). |
|
I'm trying a different approach with |
|
I minimized diff by sharing code with @sylvestre Would you review this? Benchmark is already enabled. |
Remove flush overhead and use raw syscall for POSIX tee requirement.
I was really surprised that
std::iohas such overhead.