Extension API context evaluation/parsing significantly slows down switching tabs on GitHub
Created by: felixfbecker
To reproduce:
- Open a PR on GitHub, go to the files tab and make sure the code views/extensions get initialised (get a hover).
- Now switch the tab back to "discussion", or to "issues", something that removes the code view again.
- This switching is significantly delayed compared to without the browser extension running, indicating the JavaScript main thread is blocked on something CPU intensive.
- Switching back and forth now exhibits the same behaviour
Profiling reveals that most time is spent parsing context expressions:
Potential solutions:
- Can we optimise the evaluation process? E.g. reduce the amount of things that need to be recomputed, don't recompile expressions on new code views but just reevaluate them
- Can we run this CPU-intensive work in the background script / extension host instead?
- Can we do away with context expression parsing completely?
I found one TODO in this file, could this help? https://sourcegraph.com/github.com/sourcegraph/sourcegraph@d5467869681e187eb19199b2848aede9598b61f1/-/blob/shared/src/api/client/services/contribution.ts#L127:1
cc @sqs
Profile: Browser Extension ext API slowdown profile.json.zip