Thread safety

Augie Fackler raf at durin42.com
Tue Nov 12 13:30:56 CST 2013


On Wed, Nov 06, 2013 at 08:46:01PM +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?

We run hg's hgweb code for the hg wireproto commands at Google in a
multithreaded environment (thread-per-connection, since wsgi basically
forces that on you) and it works fine.

Note that we're not using the revlog storage layer, so I can't speak
to anything in or below localrepo in the stack.

>
> 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?
>
> /Mads
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list