-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spell check large file blocks all other extensions #1
Comments
Hello Peng! Thanks for kind words about the extension. It is something between a Lab Rat and Proof of Concept. Also it reflects my vision of spell checker - light, unobtrusive with as little setup as possible (well, I don't mean So I have to agree and disagree. First I agree with the obvious - spelling takes about O(n) time. So it's only a matter of finding document large enough to prove it. Delay that you experience does not happen in I am pretty confident that time spent in But I think have to disagree with the solutions proposed. What the whole situation calls for is:
Having spelling asynchronous in either way you propose could lead to a racing condition - the document could be changed by user/extension while it is being spell checked. It's impossible to handle as the If there would be an Spelling inside What do you think? Side Notes:
Spell check start of "c:\Users\ban.necne\Documents\tex\v1_8.md" [markdown].
Spell check start of "c:\Users\ban.necne\Documents\tex\v1_8.md" [markdown].
Thanks for kind words about the extension. It is something between a Lab Rat and Proof of Concept. Also it reflects my vision of spell checker - light, unobtrusive with as little setup as possible (well, I don't mean So I have to agree and disagree. First I agree with the obvious - spelling takes about O(n) time. So it's only a matter of finding document large enough. Delay that you experience does not happen in I am pretty confident that time spent in But I think I have to disagree with the solutions proposed. What the whole situation calls for is:
Having spelling asynchronous in either way you propose could lead to a racing condition - the document could be changed by user/extension while it is being spell checked. It's impossible to handle as the If there would be an Spelling inside What do you think? Side Notes:
Spell check start of "c:\Users\ban.necne\Documents\tex\v1_8.md" [markdown].
Spell check start of "c:\Users\ban.necne\Documents\tex\v1_8.md" [markdown].
|
Such a long reply, thank you thank you. Even though you mentioned Perf Spell checking the whole document is where might block. 2-3 seconds on a single document is not a big deal sometimes but it becomes worse when users are viewing/debugging/searching in files. onIdle But postponing spellchecking to idle phase is similar to multithread, it still has racing issue. Let's say we are running spellchecking when nodejs event loop thinks it's idle, and a content change event occurs. This content change event deletes several lines before the line we are spellchecking. It means after getting the spell checking result, we don't know the correct line number of spelling errors, because the content change event is still waiting in event loop, we actually don't know if it exists or not ---> we don't if the model is dirty. racing
that's exactly what I did right now, it works reasonably. We can do the same thing for the time-costing spell checking event for the whole document
ConclusionI think we have a good agreement that we need to somehow make the first spell checking process fast, non-blocking and safe. I'm pretty close to solve the racing problem in a proper way. Once I finish that I'll share it with you and see if it's possible to adopt part of them in this extension. I'd like to find a balance between async/multithreads and sync. |
It's been changed to do spelling in Idle time. Should not block extension host's main thread in the way that @rebornix has described (vim mode + spelling large document). |
@rebornix In this very long answer (for which I am sorry, but it gathers few important things I was thinking about, so it is in parts for me) I have asked one question, which may have got unnoticed: What do you mean by "Besides I put it inside VS Code." regarding asynchronous node spellchecker? |
Hey Bartosz, our PM pointed me to an awesome spell checking extension on the marketplace and the amazing part is we already knew each other :) I played with your extension, it's pretty fast and the results are really reasonable (aka I really like it , even though I need to run
node-gyp rebuild
myself 😃, tada).We talked about async interface in microsoft/vscode#20266 (comment) and at that time I think it's not a big deal as we can use
setTimeout
to makespellchecker
's api async. But this doesn't mitigate the performance issue.spellcheck.checkspelling
directly, which is a synchronous function. It means thisonDidTextDocumentChange
handler is synchronous, when nodejs is running this function, no other events will be handled in the event loop.setTimeout
or whatever delaying function, thisonDidTextDocumentChange
handler is finished immediately, which is good. However when nodejs picks up thespellcheck.checkspelling
, it still blocks all other events.So this time let me describe it more precisely, if the spellchecking api is running in the main thread (the event loop), the main thread is blocked. For small documents, it's okay as spellchecking is pretty fast. But for medium to large files (eg, https://github.com/Microsoft/vscode-docs/blob/master/release-notes/v1_8.md ), it takes several seconds to finish the spellchecking, then none other extension is reactive.
A proper reproduce step:
hjkl
. After the spellchecking is done, then all of events get flushed to Vim extension.To mitigate this issue and the
node-gyp
rebuild problem, I tried two waysYou may want to go with the first option or similar solutions to solve the node-gyp problem and even better not block the extension host :)
Lastly I'm thinking about how to ignore ranges in a document, your approach is really inspiring.
The text was updated successfully, but these errors were encountered: