Skip to content

Hashing of result values #11

@nikomatsakis

Description

@nikomatsakis

Right now, for incremental computation, we verify that the return value of a query is the same as its previous value by using a full equality comparison. In Rustc, we often just rely on hashing instead, which is useful as values can sometimes grow to be quite big. Relying on hashing also has advantages if we ever want to support serialization to disk (#10). It can also be used to support a new incremental mode, where we store the hash but not the actual value (which we recompute on demand).

Supporting hashing isn't hard but it requires a bit of work. I imagine we'd define a stable-hash trait -- I'd love to use the digest-hash crate but it seems to be too specialized for cryptography. e.g., it's not implemented for usize or vectors.

Another option is to use the Hash trait, of course. In Rustc, we opted not to, because many hash implementations are not stable. A common example is interned data: it's convenient to hash the pointer or index, but that's not stable across implementations (though there is another option: you can compute the hash once, when the value is interned, and reuse that; not sure why we don't do that).

Metadata

Metadata

Assignees

No one assigned

    Labels

    rfcActive discussion about a possible future feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions