Skip to content

Conversation

AndrewKraevskii
Copy link
Contributor

I tried to use zig reduce but it bitrot a bit since it used old GenericWriter. 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.

@AndrewKraevskii
Copy link
Contributor Author

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).
With that there are no more usages of deprecatedWriter in codebase.

@AndrewKraevskii AndrewKraevskii changed the title Fix tools by remove usages of deprecatedWriter. Fix tools by removing usages of deprecatedWriter. Sep 12, 2025
Copy link
Member

@andrewrk andrewrk left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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)?

@AndrewKraevskii
Copy link
Contributor Author

@andrewrk I rebased it on master

@andrewrk andrewrk enabled auto-merge (rebase) September 18, 2025 18:02
@andrewrk andrewrk merged commit de48903 into ziglang:master Sep 19, 2025
14 checks passed
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.

2 participants