caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Odd behavior with GC and Mutex.lock
@ 2005-08-31 12:26 Yaron Minsky
  2005-09-02 21:40 ` Odd behavior with GC and Mutex.lock (resolved) Yaron Minsky
  0 siblings, 1 reply; 2+ messages in thread
From: Yaron Minsky @ 2005-08-31 12:26 UTC (permalink / raw)
  To: Caml Mailing List

I've been running into some very odd behavior with the GC and
Mutex.lock.  We have an application where a bunch of threads are all
pushing updates through a synchronized queue, so all of the threads are
contending for a global lock.  Under some rare circumstances, we've seen
very odd GC delays coming up, and we're at a bit of a loss to explain
them.  

The basic situation is that when the system comes under unusually high
GC load, we will sometimes see one of the threads take a long time (on
the order of half a second) when it tries to acquire the lock. We
instrumented the acquisition of the lock as follows:

let pre_stat = Gc.quick_stat () in
Mutex.lock mutex
let post_stat = Gc.quick_stat () in

The thread that gets delays shows hundreds or thousands of minor
collections and 5-10 major collections between the calls to
Gc.quick_stat ().  What's also weird is that it's always the same thread
that gets blocked, and other threads are not blocked during this period.
They seem to be able to acquire and release the lock without problems.
And the thread that does get delayed isn't even the one causing the
unusual load (although the delayed thread does do a big chunk of
allocation that is immediately unreachable right before it gets blocked).

I can't come up with a reasonable explanation for how this might happen,
and I'm hoping someone with a deeper understanding of the GC than I
might be able to help.

Yaron


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Odd behavior with GC and Mutex.lock (resolved)
  2005-08-31 12:26 Odd behavior with GC and Mutex.lock Yaron Minsky
@ 2005-09-02 21:40 ` Yaron Minsky
  0 siblings, 0 replies; 2+ messages in thread
From: Yaron Minsky @ 2005-09-02 21:40 UTC (permalink / raw)
  To: Caml Mailing List

For anyone who is interested, we've resolved this issue.  We were
mistaken to think this was a GC issue at all.  The long delays simply
resulted from some odd decisions by the Linux scheduler.  We resolved
them by changing SCHED_RR scheduling for the threads in question.

Yaron

On 8/31/05, Yaron Minsky <yminsky@gmail.com> wrote:
> I've been running into some very odd behavior with the GC and
> Mutex.lock.  We have an application where a bunch of threads are all
> pushing updates through a synchronized queue, so all of the threads are
> contending for a global lock.  Under some rare circumstances, we've seen
> very odd GC delays coming up, and we're at a bit of a loss to explain
> them.
> 
> The basic situation is that when the system comes under unusually high
> GC load, we will sometimes see one of the threads take a long time (on
> the order of half a second) when it tries to acquire the lock. We
> instrumented the acquisition of the lock as follows:
> 
> let pre_stat = Gc.quick_stat () in
> Mutex.lock mutex
> let post_stat = Gc.quick_stat () in
> 
> The thread that gets delays shows hundreds or thousands of minor
> collections and 5-10 major collections between the calls to
> Gc.quick_stat ().  What's also weird is that it's always the same thread
> that gets blocked, and other threads are not blocked during this period.
> They seem to be able to acquire and release the lock without problems.
> And the thread that does get delayed isn't even the one causing the
> unusual load (although the delayed thread does do a big chunk of
> allocation that is immediately unreachable right before it gets blocked).
> 
> I can't come up with a reasonable explanation for how this might happen,
> and I'm hoping someone with a deeper understanding of the GC than I
> might be able to help.
> 
> Yaron
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-02 21:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-31 12:26 Odd behavior with GC and Mutex.lock Yaron Minsky
2005-09-02 21:40 ` Odd behavior with GC and Mutex.lock (resolved) Yaron Minsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).