fabiospampinato / vscode-todo-plus

Manage todo lists with ease. Powerful, easy to use and customizable.
MIT License
902 stars 228 forks source link

Todo+ slow initial load? #348

Open vfonic opened 2 years ago

vfonic commented 2 years ago

Hi Fabio,

I've noticed that my VS Code is a bit slow and I found this blog post mentioning how to track how much time it takes each extension to load. https://jason-williams.co.uk/speeding-up-vscode-extensions-in-2022

Here are my stats for `Developer: Startup Performance` command run in VS Code: ## Extension Activation Stats | Extension | Eager | Load Code | Call Activate | Finish Activate | Event | By | | --------------------------------- | ----- | --------- | ------------- | --------------- | --------------------------------- | --------------------------------- | | vscode.debug-auto-launch | true | 2 | 0 | 24 | * | vscode.debug-auto-launch | | vscode.git | true | 33 | 3 | 67 | * | vscode.git | | vscode.git-base | true | 2 | 1 | 23 | * | vscode.github | | vscode.github | true | 13 | 0 | 1 | * | vscode.github | | EditorConfig.EditorConfig | true | 20 | 0 | 23 | * | EditorConfig.EditorConfig | | fabiospampinato.vscode-todo-plus | true | 79 | 18 | 6 | * | fabiospampinato.vscode-todo-plus | | formulahendry.auto-close-tag | true | 3 | 0 | 6 | * | formulahendry.auto-close-tag | | ms-vscode.sublime-keybindings | true | 3 | 0 | 6 | * | ms-vscode.sublime-keybindings | | vscode.emmet | false | 4 | 2 | 8 | onStartupFinished | vscode.emmet | | vscode.extension-editing | false | 7 | 2 | 22 | onLanguage:markdown | vscode.extension-editing | | vscode.github-authentication | false | 92 | 2 | 9 | onAuthenticationRequest:github | vscode.github-authentication | | vscode.markdown-language-features | false | 15 | 2 | 20 | onLanguage:markdown | vscode.markdown-language-features | | vscode.markdown-math | false | 5 | 0 | 0 | api | vscode.markdown-language-features | | vscode.merge-conflict | false | 5 | 2 | 6 | onStartupFinished | vscode.merge-conflict | | vscode.microsoft-authentication | false | 10 | 1 | 215 | onAuthenticationRequest:microsoft | vscode.microsoft-authentication |

If you have a look at "Load Code" column, you'll notice that Todo+ seems to be one of the slowest extensions in my VS Code setup.

Here's what the blog post author says that can be done:

VSCode offers a comprehensive range of different activation events for extensions to use, but if you really need a startup hook, then consider using onStartupFinished. This will kick off your extension after VSCode has loaded and will also give other extensions time to start up. Coming back to Postfix TS, it’s only effective on TypeScript/JavaScript files, so there’s no point loading it any time other than when you’re using these languages. So, let’s change the activation event to:

[
    "onLanguage:javascript",
    "onLanguage:typescript",
    "onLanguage:javascriptreact",
    "onLanguage:typescriptreact"
]

This allows VSCode to ignore the extension if I’m not using those languages and will save me a whole chunk of startup time.

Maybe this can be set for Todo+? Maybe this would work:

[
  "onLanguage:todo",
]

I haven't tried this.

What do you think?

fabiospampinato commented 2 years ago

@vfonic What's the unit of that Load Code column, milliseconds?

Maybe this can be set for Todo+?

Maybe, definitely activating the extension all the time doesn't seem optimal.

vfonic commented 2 years ago

@vfonic What's the unit of that Load Code column, milliseconds?

Seems like it. From the blog post:

https://jason-williams.co.uk/speeding-up-vscode-extensions-in-2022#case-study-postfix-ts

Load Code (Column 3): How long is spent parsing and executing the source code supplied by the extension (in ms). CPU-intensive script parsing and execution can delay not only other extensions, but also user interaction (not to mention cause battery drain if using a laptop or mobile device). In the above image, load code is the third column in, showing the value 153ms.

And there's a screenshot showing 153 in the third column.

fabiospampinato commented 2 years ago

Trimming down the dependencies tree should have a significant impact on this.

albert-ying commented 2 years ago

Same here, do we really want the Todo+ to initialize at the start? Could it be set to be initialized only when opening TODO file?

image

Maybe can also do similar thing as this

    "activationEvents": [
        "onCommand:whichkey.show",
        "onCommand:whichkey.showTransient",
        "onCommand:whichkey.register"
    ],