Automatic classification: more aggressive debounce and perf considerations
See original GitHub issueTesting #129436
On my machine it takes around 300ms
for the language classification to compute. However some of our users have a slower machine, so here are some ideas on how to make sure to not slow down when users that are just scribbling in an untitled editor.
- Do not classify when less than 20 characters present (unless to reset mode if file has auto detected already) - Done in https://github.com/microsoft/vscode-languagedetection/commit/b024b29a080c20b6875141797380dabb1bf3f672
- Increase debounce from 300ms to 600ms (this will still not be a noticeable lag when the user stops typing, pastes) - Done in https://github.com/microsoft/vscode/pull/130006
- If you have already run the classification
n
times and every time you are unsuccessful maybe stop trying and only on larger changes run - If you already auto detected a language - great! Do not be so aggressive then, only if a big change to the file content happened
Both 3 and 4 require some knowledge about what is a bigger change to a file. We can figure something out. Maybe @bpasero has ideas
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Debouncing and Throttling Explained Through Examples
Debounce and throttle are two similar (but different!) techniques to control how many times we allow a function to be executed over time. ......
Read more >Cisco MDS 9000 Series Interfaces Configuration Guide ...
Besides these modes, each interface may be configured in auto or Fx port modes. ... policies and not the more aggressive edge type...
Read more >Driver Behavior Classification System Analysis Using Machine ...
In this paper, four machine learning classification methods are implemented and compared to identify drivers' behavior and distraction ...
Read more >EOS 4.29.0F - Ethernet Ports - Arista
The show interface transceiver dom command displays the most important current performance data on the media (line) side. Example
Read more >Dell EMC Networking N-Series Switches CLI Reference Guide ...
show interfaces debounce . ... Interface Error Disable and Auto Recovery . . . . . . .499 ... consisting of classification fields...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @bpasero for bringing this to my attention. I don’t think having it running in main thread scales in terms of performance, especially now we are also adding bracket matching on typing. Adding a few ms doesn’t seem to hurt typing but if everyone is doing so, a single type can easily exceed 16ms and we can’t finish rendering in one single frame.
Note that we already have tokenization and multiple event listeners (auto save trigger), which take a couple of ms each.
💯
We have to be very very careful of running an expensive operation in the same thread where the user is typing in (see https://github.com/microsoft/vscode/issues/27378 for example to get some inspiration). At the minimum we should debounce in a way that continuous typing further delays the computation up to the point where the user stops typing for a moment.
This becomes even more important if we decide to make language detection enabled by default.
Further thoughts:
setMode
change dubious with the fragilesetExplicitly
option which possibly would benefit from being dealt with internally. It is also weird to register a coreworkbench.editor.untitled.experimentalLanguageDetection
setting that is only being used from a workbench contribution imhosrc/vs/workbench/contrib/notebook/common/services/notebookWorkerServiceImpl.ts
)