]> git.lizzy.rs Git - rust.git/commit
Serialize incr comp structures to file via fixed-size buffer
authorTyson Nottingham <tgnottingham@gmail.com>
Mon, 7 Dec 2020 01:30:55 +0000 (17:30 -0800)
committerTyson Nottingham <tgnottingham@gmail.com>
Mon, 11 Jan 2021 20:13:22 +0000 (12:13 -0800)
commit52f21791fbec58e14a54b8c6f9146807a8ae8d84
tree909011c456b942de9598dc80d10965d13924ef13
parent6526e5c772f2da07db745c94ca6bb0a591a39ba4
Serialize incr comp structures to file via fixed-size buffer

Reduce a large memory spike that happens during serialization by writing
the incr comp structures to file by way of a fixed-size buffer, rather
than an unbounded vector.

Effort was made to keep the instruction count close to that of the
previous implementation. However, buffered writing to a file inherently
has more overhead than writing to a vector, because each write may
result in a handleable error. To reduce this overhead, arrangements are
made so that each LEB128-encoded integer can be written to the buffer
with only one capacity and error check. Higher-level optimizations in
which entire composite structures can be written with one capacity and
error check are possible, but would require much more work.

The performance is mostly on par with the previous implementation, with
small to moderate instruction count regressions. The memory reduction is
significant, however, so it seems like a worth-while trade-off.
compiler/rustc_data_structures/src/fingerprint.rs
compiler/rustc_incremental/src/persist/file_format.rs
compiler/rustc_incremental/src/persist/save.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_middle/src/ty/codec.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/query/on_disk_cache.rs
compiler/rustc_serialize/src/leb128.rs
compiler/rustc_serialize/src/lib.rs
compiler/rustc_serialize/src/opaque.rs
compiler/rustc_serialize/tests/leb128.rs