about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/fingerprint.rs
AgeCommit message (Collapse)AuthorLines
2023-04-30Use the full Fingerprint when stringifying SvhBen Kimock-0/+5
2023-04-18Add #[inline] to some new functionsBen Kimock-0/+2
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-14/+29
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-12-05StableOrd: Address review comments.Michael Woerister-1/+1
2022-12-02Add StableOrd trait as proposed in MCP 533.Michael Woerister-1/+1
The StableOrd trait can be used to mark types as having a stable sort order across compilation sessions. Collections that sort their items in a stable way can safely implement HashStable by hashing items in sort order.
2022-08-31Fix a bunch of typoDezhi Wu-2/+2
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-06-14Rename rustc_serialize::opaque::Encoder as MemEncoder.Nicholas Nethercote-5/+5
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-10Revert b983e42936feab29f6333e9835913afc6b4a394e.Nicholas Nethercote-5/+5
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-5/+5
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-5/+4
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-02-22Provide copy-free access to raw Decoder bytesMark Rousskov-3/+1
2022-02-02Rollup merge of #92528 - tmiasko:combine-commutative, r=michaelwoeristerMatthias Krüger-1/+4
Make `Fingerprint::combine_commutative` associative The previous implementation swapped lower and upper 64-bits of a result of modular addition, so the function was non-associative. r? `@Aaron1011`
2022-01-22Make `Decodable` and `Decoder` infallible.Nicholas Nethercote-5/+5
`Decoder` has two impls: - opaque: this impl is already partly infallible, i.e. in some places it currently panics on failure (e.g. if the input is too short, or on a bad `Result` discriminant), and in some places it returns an error (e.g. on a bad `Option` discriminant). The number of places where either happens is surprisingly small, just because the binary representation has very little redundancy and a lot of input reading can occur even on malformed data. - json: this impl is fully fallible, but it's only used (a) for the `.rlink` file production, and there's a `FIXME` comment suggesting it should change to a binary format, and (b) in a few tests in non-fundamental ways. Indeed #85993 is open to remove it entirely. And the top-level places in the compiler that call into decoding just abort on error anyway. So the fallibility is providing little value, and getting rid of it leads to some non-trivial performance improvements. Much of this commit is pretty boring and mechanical. Some notes about a few interesting parts: - The commit removes `Decoder::{Error,error}`. - `InternIteratorElement::intern_with`: the impl for `T` now has the same optimization for small counts that the impl for `Result<T, E>` has, because it's now much hotter. - Decodable impls for SmallVec, LinkedList, VecDeque now all use `collect`, which is nice; the one for `Vec` uses unsafe code, because that gave better perf on some benchmarks.
2022-01-03Make `Fingerprint::combine_commutative` associativeTomasz Miąsko-1/+4
The previous implementation swapped lower and upper 64-bits of a result of modular addition, so the function was non-associative.
2021-12-09Remove redundant [..]sest31-2/+2
2021-03-25Allow for reading raw bytes from rustc_serialize::Decoder without unsafe code.Michael Woerister-8/+28
2021-03-19Remove FingerprintEncoder/Decoder.Camille GILLOT-56/+10
2021-03-19Move raw bytes handling to Encoder/Decoder.Camille GILLOT-2/+2
2021-02-04Add documentation to Unhasher impl for Fingerprint.Michael Woerister-1/+12
2021-02-02Let a portion of DefPathHash uniquely identify the DefPath's crate.Michael Woerister-2/+13
This allows to directly map from a DefPathHash to the crate it originates from, without constructing side tables to do that mapping. It also allows to reliably and cheaply check for DefPathHash collisions.
2021-01-11Serialize incr comp structures to file via fixed-size bufferTyson Nottingham-10/+12
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.
2021-01-01rustc_serialize: have read_raw_bytes take MaybeUninit<u8> sliceTyson Nottingham-2/+2
2020-11-18Make PackedFingerprint's Fingerprint privateTyson Nottingham-1/+18
2020-11-18Use PackedFingerprint in DepNode to reduce memory consumptionTyson Nottingham-0/+42
2020-10-13Replace absolute paths with relative onesest31-2/+2
Modern compilers allow reaching external crates like std or core via relative paths in modules outside of lib.rs and main.rs.
2020-09-01Avoid rehashing Fingerprint as a map keyJosh Stone-1/+29
This introduces a no-op `Unhasher` for map keys that are already hash- like, for example `Fingerprint` and its wrapper `DefPathHash`. For these we can directly produce the `u64` hash for maps. The first use of this is `def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>`.
2020-08-30mv compiler to compiler/mark-0/+130