[mosh-devel] Mosh multithreaded support
Carlos Cabanero
carlosecabanero at gmail.com
Wed Jun 15 11:48:26 EDT 2016
Hi everyone!
One of the challenges we faced on Blink was to make Mosh work
multithreaded. These were the basic changes made:
* Compressor - A shared compressor between threads makes sense, but the
problem is the internal buffer inside the class needs to be per thread.
* Select - There is one client instanced per thread, the problem is that
handle_signal (for that thread), would come from nowhere and needs to
figure out for what.
* millis_cache on timestamp.cc - I thought this was gonna be fine, and the
client actually works for a long time. But if you fully close and then
reopen a new one, obviously the millis_cache will be all wrong.
For stability testing, and making sure these were the only ones, I used
pthread on the first two and __thread on the last one (there is no function
to change that). It is working fine, so that’s all that is required to make
Mosh multithreaded.
On the solutions side of things:
- pthread I do not think it is a good option due to platform reasons.
- Adding __thread on all the statics would be a suitable solution but
not all the compilers and architectures might support it, it could just be
a compiling option.
- Removing singletons could be the second option. On the Compressor,
maybe the NetworkTransport could have one compressor but there are strange
ties between object, and also not very clear on the Select and millis_cache
case.
Please let me know what you think, as maybe this will complicate more than
it would add and it isn’t of general appeal to have on the main branch.
Someone with more expertise might have more feedback too on possible ways.
I’m glad to work on any of them.
Thanks!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/mosh-devel/attachments/20160615/8464c0ff/attachment.html
More information about the mosh-devel
mailing list