editorService & modelService refactor and optimizations
Created by: lguychard
Still a fair bit of cleanup to do here, but this introduces some significant improvements towards https://github.com/sourcegraph/sourcegraph/issues/5172.
Notable changes:
- Refactor editorService, modelService to be backed by
Map
s, rather than immutable arrays. - Emit incremental updates of added/updated/deleted editors and models, rather than a new array of all editors/models on every emission. This dramatically reduces GC pressure, and improves efficiency of adding/updating/deleting models and editors.
- Introduces
editorService.activeEditorUpdates
, to avoid needless iteration over all editors when computing context keys. - Introduces
editorService.activeLanguages
(still very rough, may move to modelService) to avoid needless iteration over all editors when computing active extensions.
All tests passed before I started working on 3. and 4.
On the 999-file PR (https://github.com/sourcegraph/sourcegraph/pull/5157/files#diff-1de4be34265b5e830d0e2a2fea7f386bR866), I was able to reliably load up to 400 code views, including blob fetching, in <90seconds. On the same PR, an extension built from master stalls after 270 code views loaded in ~5 minutes.