tvix-eval: hotspot in locals lookups

#227
Opened by tazjin at 2022-12-10T10·39+00

We have a performance hotspot in the compiler, when resolving locals by name. We currently walk a list and do string comparisons for each item in the list.

The list needs fast position-based access (i.e. locals[n]), but we need to find a way to also add fast name-based access (e.g. locals[idx_for(name)]). This isn't as simple as adding a secondary index HashMap, because values can be shadowed. A naive solution like HashMap<String, Vec<usize>> might not end up performing faster at all.

There's probably some clever thing we can do here, I'm just logging it for now to source some collective thought.

  1. This is significantly improved with cl/7560, after that it basically doesn't show up in eval performance analysis anymore and we can consider it closed for now.

    tazjin at 2022-12-16T10·44+00

  2. tazjin closed this issue at 2022-12-16T10·44+00