posit-dev / publisher

MIT License
3 stars 0 forks source link

feat: faster extension activation #1825

Closed tdstein closed 2 weeks ago

tdstein commented 2 weeks ago

Intent

Reduces extension startup time via two mechanisms:

Type of Change

Approach

The table below shows the startup metrics on my machine between main and this branch. The first row is main, and the second row is this branch.

| Extension                                | Eager | Load Code | Call Activate | Finish Activate | Event                              | By                                       |
| ---------------------------------------- | ----- | --------- | ------------- | --------------- | ---------------------------------- | ---------------------------------------- |
| posit.publisher                          | false | 21        | 0             | 1640            | onStartupFinished                  | posit.publisher                    
| posit.publisher                          | true  | 22        | 2             | 7               | workspaceContains:*                | posit.publisher                          |

Differences:

  1. Asynchronous server startup.

By not awaiting the server startup, we significantly reduce the total duration of the activation method.

  1. Activation event.

A workspaceContains:* starts the extension earlier than onStartupFinished. This loads the extension once any file exists in the project.

Automated Tests

Directions for Reviewers

Try it out an observe the time it takes for the icon to appear in the activity bar. Verify that nothing breaks.

Checklist

tdstein commented 2 weeks ago

Pulled this down and tested it - had no issues, and it felt much faster.

I also poked around to ensure that none of the async code was going to misbehave if we weren't waiting for the service to start. Because we await useApi() we appear to be all good.

Fantastic change 🎉

Thanks for verifying the usage of useApi!