mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Rollup merge of #104797 - weihanglo:stream-write-dwp, r=jackh726
rustc_codegen_ssa: write `.dwp` in a streaming fashion
When writing a `.dwp` file, rustc writes to a Vec first then to a BufWriter-wrapped file. It seems very likely that we can write in a streaming fashion to avoid double buffering in an intermediate Vec.
On my Linux machine, `.dwp` from the latest rust-lang/cargo is 113MiB. It may worth a stream writer, though I didn't do any benchmark 🙇🏾♂️.
This commit is contained in:
commit
aec60c6b7c
@ -676,8 +676,7 @@ fn link_dwarf_object<'a>(
|
|||||||
thorin::MissingReferencedObjectBehaviour::Skip,
|
thorin::MissingReferencedObjectBehaviour::Skip,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let output = package.finish()?.write()?;
|
let output_stream = BufWriter::new(
|
||||||
let mut output_stream = BufWriter::new(
|
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
@ -685,8 +684,10 @@ fn link_dwarf_object<'a>(
|
|||||||
.truncate(true)
|
.truncate(true)
|
||||||
.open(dwp_out_filename)?,
|
.open(dwp_out_filename)?,
|
||||||
);
|
);
|
||||||
output_stream.write_all(&output)?;
|
let mut output_stream = object::write::StreamingBuffer::new(output_stream);
|
||||||
output_stream.flush()?;
|
package.finish()?.emit(&mut output_stream)?;
|
||||||
|
output_stream.result()?;
|
||||||
|
output_stream.into_inner().flush()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}) {
|
}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user