[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2006-03-08 (23:45) |
From: | Robert Roessler <roessler@r...> |
Subject: | Re: [Caml-list] STM support in OCaml |
Brian Hurt wrote: > On Thu, 9 Mar 2006, skaller wrote: > >> Ahem. Now try that on an AMDx2 (dual core). The cost goes through >> the roof if one process has a thread on each core. Because each >> core has its own cache and both caches have to be flushed/ >> synchronised. And those caches are BIG! > > Love to. Wanna buy me the box? :-} Seriously- my code is attached, if > someone wants to run it on other boxes and post the results, feel free. > It's GNU-C/x86 specific, as I'm using GNU C's inline assembler and the > rdtsc instruction to get accurate cycle counts. > > As to the cache comment: the whole caches don't have to be flushed, just > the line the mutex is on. Which makes it approximately the cost of a > cache miss- that's a good approximation of the cost of getting an > uncontended lock. > >> >> I have no idea if Linux, for example, running SMP kernel, >> is smart enough to know if a mutex is shared between two >> processing units or not: AFAIK Linux doesn't support >> interprocess mutex. Windows does. Be interesting to >> compare. > > It doesn't look like the mutex software is even going into the kernel. I > don't think the Linux kernel even knows the mutex *exists*, let alone > what threads are competing for it. On the x86, at least, lock > instructions are not priveledged. Brian [, this may be fairly off-topic, but], could you possibly comment on how these results may or may not pertain to g_mutex_lock (rather than pthread_mutex_lock)? I have been going to some trouble to operate a glyph-string cache without needing any locking for the *lookup* case - which is doable, only needing locking for *adding*. OTOH, for the flushing operation, it looks a bit tougher... ;) But if g_mutex_lock/g_mutex_unlock is not all that grim... Robert Roessler roessler@rftp.com http://www.rftp.com