-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix tools by removing usages of deprecatedWriter. #25220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tools by removing usages of deprecatedWriter. #25220
Conversation
I decided to not touch arocc since it would make sense to update it with the rest of arocc (arocc already removed usages of deprecatedWriter). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this work.
Sorry, I merged a newer PR that conflicted on one of the files. This is otherwise good to land though.
@@ -122,7 +122,9 @@ fn mode(comptime x: comptime_int) comptime_int { | |||
} | |||
|
|||
pub fn main() !void { | |||
const stdout = std.fs.File.stdout().deprecatedWriter(); | |||
var stdout_buffer: [0x100]u8 = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to flush at every write, instead simply give it an empty buffer. Or, put only one flush at the very end.
Note: this conflicts with another merged patch so you can probably just drop this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did what you suggested at first but when I checked and print() actually will make multiple syscalls if provided with empty buffer.
Additionally im flushing not after all writes but only before blocking writes e.g. printing results of benchmark and printing header for next benchmark in one syscall since they become available for printing at the same time and it preserves old behavior.
But I guess it doesn't matter for this scripts much so might as well drop it to make implementation simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it doesn't matter too much, other than that any code that exists, serves as an example for people reading the code to follow, so there's value to always doing best practices, particularly in ziglang/zig. Not a merge blocker though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not sure which practice of these two you mean to be best? Doing simpler code (no buffering) or doing faster code (with buffering)?
acd6cdb
to
1c66570
Compare
@andrewrk I rebased it on master |
I tried to use
zig reduce
but it bitrot a bit since it used oldGenericWriter
. I went and updated it and some other tools to use new Writer.Also Adler32 API changed so I also updated lib/std/hash/benchmark.zig to handle it properly just so I can test my changes with Writer.