question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic classification: more aggressive debounce and perf considerations

See original GitHub issue

Testing #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.

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:open
  • Created 2 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

3reactions
rebornixcommented, Aug 2, 2021

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.

2reactions
bpaserocommented, Aug 7, 2021

💯

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:

  • [x] would it make sense to move the language detection code into the untitled text editor model itself to possibly making the integration tighter? For example, I find the setMode change dubious with the fragile setExplicitly option which possibly would benefit from being dealt with internally. It is also weird to register a core workbench.editor.untitled.experimentalLanguageDetection setting that is only being used from a workbench contribution imho
  • we seem to be creating a full string of the text model each time to detect the language - this can be very expensive for large models and at the very minimum should support stream based detection via the text model factory (see for example how backups are created for text files where we convert a snapshot of the text model to a byte stream here)
  • can we explore moving the language detection into a worker and off the renderer process? I believe we do something similar when computing the diff of a file (@alexdima could possibly chime in on that matter or maybe @rebornix for how notebooks do this in src/vs/workbench/contrib/notebook/common/services/notebookWorkerServiceImpl.ts)
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found