mechatroner / vscode_rainbow_csv

🌈Rainbow CSV - VS Code extension: Highlight CSV and TSV files in different rainbow colors to make them more readable
MIT License
436 stars 53 forks source link

Limit Rainbow CSV loading to custom file extensions #145

Open mdnava opened 1 year ago

mdnava commented 1 year ago

Please consider adding support to limit loading of this plugin to custom file extensions (by default: csv, tab, tsv.. etc..).. This in order to remove unnecessary load time. It tends to add up, and I barely use csv files with different file extensions.

2023-09-17 20 00 54

Edit 2023-09-17 20:09

I noticed I can remove "Autodetect_separators" and loading time goes down,.

2023-09-17 20 08 54

I still think it would be a good feature to keep the "Autodetect_separators" and be able to limit loading by file extension. Any way it goes is okay. I think it worth to mention.

Best regards..

mechatroner commented 1 year ago

Thanks for opening this issue, it could serve as a good reference for tracking potential loading performance problems. So far the best loading performance tracking tool I have found is Ctrl + P + Developer: Startup Performance command. The first time I ran it "rainbow-csv" was among the slowest extensions with 120 ms loading time, but then I reopened VSCode and it actually became one of the fastest (see the table below). So it looks like the loading time is not very consistent and can change from start-up to start-up.

In rainbow-csv I tried to minimize the amount of code the extension needs for the most basic functions and lazy-load the more advanced stuff. Also, the table shows that the activation function takes a lot of time to finish, but I guess it is not such a big deal since the function is async (actually it has await sleep(1000) in it as a hacky workaround for some VSCode behavior, so it explains >1 sec activation time).

I am not sure if it is possible to limit the activation of a particular extension through the user config, but I will check. Also, I see no reason why removing "Autodetect_separators" would affect loading time (although I might be missing something) so most likely this is just the overall noisiness of this metric

Extension Activation Stats

Extension Eager Load Code Call Activate Finish Activate Event By
vscode.git true 34 17 124 * vscode.git
vscode.git-base true 8 0 0 * vscode.git
vscode.github true 20 1 3 * vscode.github
vscode.npm true 14 5 439 workspaceContains:package.json vscode.npm
vscode.debug-auto-launch false 6 1 0 onStartupFinished vscode.debug-auto-launch
vscode.emmet false 11 8 0 onLanguage vscode.emmet
vscode.extension-editing false 10 1 0 onLanguage:markdown vscode.extension-editing
vscode.github-authentication false 21 1 2 onAuthenticationRequest:github vscode.github-authentication
vscode.markdown-language-features false 53 7 302 onLanguage:markdown vscode.markdown-language-features
vscode.markdown-math false 13 0 0 api vscode.markdown-language-features
vscode.merge-conflict false 13 4 3 onStartupFinished vscode.merge-conflict
vscode.microsoft-authentication false 26 1 12 onAuthenticationRequest:microsoft vscode.microsoft-authentication
ms-vscode-remote.remote-wsl-recommender false 19 16 2 onStartupFinished ms-vscode-remote.remote-wsl-recommender
mechatroner.rainbow-csv false 11 3 1016 onLanguage:csv mechatroner.rainbow-csv
ms-vscode.remote-server false 43 19 0 onStartupFinished ms-vscode.remote-server
mechatroner commented 1 year ago

I did some googling and apparently this functionality is not supported in VSCode - the feature request was closed: https://github.com/microsoft/vscode/issues/83783

mdnava commented 1 year ago

I did some googling and apparently this functionality is not supported in VSCode - the feature request was closed: microsoft/vscode#83783

Edited 2023-09-22 03:12

@mechatroner Does this means all VS Code extensions are activated all the time?. I would assume only extensions currently showing up the loading time are active in VS Code (when first opened). And as far as I can recall these exts usually match assigned filetypes.

For instance, opening a Python script:

2023-09-22 02 45 47

Opening any other filetype:

2023-09-22 02 44 58

It seems the Python extension is only loaded when Python scripts are opened. I might be wrong. At this time I don't actually know the inner workings of VS Code.

mechatroner commented 1 year ago

Right, very often extensions define a set of file types that should trigger the activation event, the problem is that it is not possible to override these rules from the user config.

mdnava commented 1 year ago

@mechatroner

Right, very often extensions define a set of file types that should trigger the activation event, the problem is that it is not possible to override these rules from the user config.

Well, I do implement something like this, that works:

    "files.associations": {
        "*.ahk":    "ahk",
        "*.ahk2":   "ahk2",
        "*.jsx":    "javascript",
        "*.py2":    "python",
        "*.task":   "xml"
    },

Language extensions are loaded properly for each option set here.

I don't know if the extension developer has access to allow this customization, but I would assume.