Skip to content

Experiment splitting declaration and definition storage #647

@vinistock

Description

@vinistock

We currently store all declarations and definitions in their respective maps, which is part of the reason why we need to use u64 rather than u32 for IDs.

I think we may be able to change that situation if we partition the maps. One example of how we might do it is:

  • constants: IdentityHashMap<ConstantId, Declaration> all constants including namespaces
  • methods: IdentityHashMap<MethodId, Declaration> all methods
  • variables: IdentityHashMap<VariableId, Declaration> global, class and instance variables

Experimenting with the granularity may also reveal interesting trade offs. The only concern is that we need to be able to trace the graph from the top (declarations) and from the bottom (documents).

  • From the top, we need to be able to derive the entity kind from the name. By looking at Foo, we don't know if it's a constant, constant alias, module, class. So having a single ConstantId probably makes sense. However, we always know when something is a method, global, class or instance variable. So we could get very granular if that proves to reduce memory or yield better performance
  • From the bottom, we always know how a definition gets connected to its declaration, so it's straight forward

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions