Thread safety

Matt Mackall mpm at selenic.com
Wed Nov 6 16:02:26 CST 2013


On Wed, 2013-11-06 at 20:46 +0100, Mads Kiilerich wrote:
> How safe/unsafe do you think it is to run Mercurial in a multi threaded app?
> 
> Especially, how dangerous / efficient is it really to run hgweb multi 
> threaded? Is it really necessary to run multiple "threads" as separate 
> processes?
> 
> http://selenic.com/pipermail/mercurial/2009-May/026069.html says:
> > - you can't have multiple threads working on the same objects
> > (repository, dirstate, context, revlog)
> > - there are a couple global variables such as encoding mode
> >
> > These shouldn't be much of an issue. For instance, you can create
> > multiple repo objects pointing to the same repo on disk and they will
> > use locking appropriately.
> >
> > However, there may be bugs lurking as this is definitely not the
> > standard mode of operation.
> 
> Largefiles do horrible things such as monkey patching modules and 
> classes on runtime. That is however only(?) at the command level and for 
> operations touching the working directory. The server and store parts 
> seems better.
> 
> Can anyone add more to how tread safe Mercurial is? Are you aware of 
> other problems or have you tried it and found that there is no problems?

I think it's pretty good and there are no fundamental problems with the
approach. This sort of thing here is the biggest problem I'm aware of:

http://bz.selenic.com/show_bug.cgi?id=3953

This is one of the very rare things that's shared across requests, and
here it's getting modified without locking. Really straightforward to
fix by introducing a lock in the hgwebdir code.

Extensions can theoretically introduce problems, but in general they're
not doing much after setup.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list