fabiospampinato / vscode-todo-plus

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

Improve scalability #54

Open fabiospampinato opened 6 years ago

fabiospampinato commented 6 years ago

The amount of work this extension performs scales with the number of lines, basically a file with 1000 lines will take 10 times more to decorate than a file with 100 lines.

At the moment, when the document changes, we trash all the previous decorations and start over, this will cause lags if the file is big enough.

Most of the times only one line or few lines change, usually there's no need to refresh the decorations for all the other lines.

Possible improvements:

fabiospampinato commented 6 years ago

As of v2.0.0 performance should be much better, I've been editing a 7k+ lines file without too many problems. Editing smaller files should feel pretty quick.

Some previous O(n) scenarios are now O(1):

I've also optimized the code quite a bit, but unfortunately I couldn't properly cache decorations of unedited lines, turns out VSC's APIs are pretty lacking in this regard. I'm going to keep this open as performance could be improved even further, but there's not much that I can do without proper APIs, upstream issues:

fabiospampinato commented 6 years ago

Another currently O(n) scenario that could be optimized to be O(1) is this:

marco-m commented 5 years ago

Microsoft/vscode#50346 has been closed as dup of Microsoft/vscode#585

fabiospampinato commented 3 years ago

It looks like there's a "Semantic tokens API", could be interesting: https://github.com/microsoft/vscode/issues/86415

beeplin commented 3 years ago

I came from https://github.com/fabiospampinato/vscode-todo-plus/issues/210 and is suffering from the same lag in a 100 lines todo file. Have to reload vscode window again and again to avoid the lag. :(

beeplin commented 3 years ago

I guess the lag is caused by redrawing the whole document each time the document is changed -- that is, each time a key is pressed. Maybe we could improved it by introducing some kind of debouncing behavior. When keep typing continuously, it can wait until the typing stoped for, say, 1 second.