Skip to content
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

tools/api: Speed up fmt from 1min to 18s by writing to rustfmt stdin #1254

Merged
merged 3 commits into from
Oct 29, 2021

Conversation

MarijnS95
Copy link
Contributor

This reintroduces the "pipe Rust code through rustfmt before writing to disk" code from #828 and yields a massive performance improvement for running in parallel over all files now, and not having to write, read, and write the same files over again.

Unfortunately Rust's Command structure does not yet have proper support for forwarding stdout to a file (that's not unix-specific), though it could possibly be beneficial to write chunks read from stdout directly to a file instead of reading the whole lot into memory first.

Using forward slashes makes it so that all the tools generate files into
the proper directories on Linux - otherwise new folders/files with `\\`
in the name are created, and none of the existing files are properly
overwritten.
This reintroduces the "pipe Rust code through rustfmt before writing to
disk" code from [microsoft#828] and yields a massive performance improvement for
running in parallel over all files now, and not having to write, read,
and write the same files over again.

Unfortunately Rust's `Command` structure does not yet have proper
support for forwarding stdout to a file (that's not unix-specific),
though it could possibly be beneficial to write chunks read from stdout
directly to a file instead of reading the whole lot into memory first.

[microsoft#828]: microsoft#828
@MarijnS95 MarijnS95 force-pushed the rustfmt-parallel branch 2 times, most recently from 52aee5e to 3ecd976 Compare October 28, 2021 20:55
@kennykerr kennykerr merged commit 5e91647 into microsoft:master Oct 29, 2021
@MarijnS95 MarijnS95 deleted the rustfmt-parallel branch October 29, 2021 08:01
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.

None yet

2 participants