-
Notifications
You must be signed in to change notification settings - Fork 420
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
Use BlockingCollection in SharedTextWriter #1427
Conversation
Could do some benchmarks to see if there's any actual performance boost. |
I just figure if we can avoid blocking a thread at all it would probably be better. |
@mholo65 What do you think of implementing this with |
@rchande I'd be fine with that. @mholo65 lsp already has this with the output handler https://github.com/OmniSharp/csharp-language-server-protocol/blob/7d8567c09c88d27b4b4a2209959f689df8e9419d/src/JsonRpc/OutputHandler.cs |
Actually, blockingCollection blocks a thread, so this is probably better. |
A blocking collection will only block it's own thread, not the calling task, assuming you just queue the item up. For input / output it probably makes more sense to just have the dedicated thread, then we can queue data up for it as fast as we're allowed, but it'll write out at whatever rate it can. As long as the order is guaranteed (which by default Thoughts? @mholo65 @rchande As it is I'm fine with this change, but it might almost make more sense to refactor it entirely. |
@david-driscoll @rchande I think that BlockingCollection is even better, then we'll dump the IO to another thread, and won't block main thread. |
668347c
to
db6cead
Compare
@david-driscoll @rchande @filipw I modified this PR to use |
thanks 👏 |
Did some profiling and noticed a lot of time was spent on
ShareTextWriter.WriteLine
andSharedTextWriter.WriteLineAsync
.Noticed the
lock
and figured we could useSemaphoreSlim
instead.