Skip to content

Remove the global hashtable for tracked fns with >1 argument #599

@nikomatsakis

Description

@nikomatsakis

As described in this hackmd, we currently create an interned ingredient for every tracked function unless it has exactly 1 argument. This is wasteful. The reason we do this is because the memos for tracked functions are stored on salsa structs1 and so we need to have a 1:1 relationship between a (salsa struct, tracked fn) pair and a memo.

We should refactor things so that:

  • Every tracked function has as its first argument a salsa struct. If there are no arguments, we can add some kind of dummy interned struct in salsa like #[salsa::intern] struct Placeholder<'db>{ data: () } and redefine the argument as being called on a Placeholder<'db>, which we can trivially create (it'd also be nice to have a more optimized "global struct", maybe that's worth thinking about; even interning unit is more work than it really ought to be for this case).
  • For tracked functions with >1 argument, when you index into the memo-table for a tracked struct, you would get back a DashMap instead of a single memo; the map would be keyed by the additional arguments.

Footnotes

  1. (Salsa struct = input | tracked | interned)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions