Have you implemented your own Thread::Queue then? But I'm not sure whether there is a way to see which thread holds a lock, other than adding print statements.
As a work around, I would try to restructure the code so that the work units fetched from the locked area are larger, and thus less lock contention happens. See Data::Stream::Bulk for a possible implementation.
| [reply] [d/l] |
Yes, I have implemented my own Thread::Queue. I needed some more functionality, and Thread::Queue is written in Perl anyway so there are no performance gains to be expected.
I have already made some improvement in my locking problems. However, I'd prefer not to discuss that in more depth.
So I repeat my original question: Is it possible to get the current lock owner somehow? I am expecting some low-level hack here. :-)
| [reply] |
I have a multi-threaded Perl script that is experiencing lock contention issues. Is it possible to get the current lock owner somehow? This way I could debug which of my threads holds the locks most of the time.
What platform? Which version of perl?
Yes, I have implemented my own Thread::Queue. I needed some more functionality, and Thread::Queue is written in Perl anyway so there are no performance gains to be expected.
What sort of functionality do you need? Read locking, exclusive locks, write locks on a specific region?
Again, what platform (Linux, Solaris, Windows etc) are you on? Different ones have different quirks in file locks.
Do you have access to a C compiler?
I have already made some improvement in my locking problems. However, I'd prefer not to discuss that in more depth.
If you don't tell us what you have already done, so that we can gain more insight into your problem, why should we reinvent the wheel? File and record locking procedures do not come under the heading of trade secrets, and can benefit from our collective expertise if you help us help you.
So I repeat my original question: Is it possible to get the current lock owner somehow? I am expecting some low-level hack here.
Perhaps if you explained more about the problem. It could be as simple as a lock file in a temp directory which contains the PID and TID of the locking thread. It could be as complicated as looking at the system structures (in /proc on Linux for example).
| [reply] |
$ perl -Mthreads -MDevel::Peek -e"my $locked=1; my $unlocked=1; Dump($
+unlocked); lock($locked); Dump($locked)"
SV = IV(0x98a490) at 0x98a494
REFCNT = 1
FLAGS = (PADMY,IOK,pIOK)
IV = 1
SV = IV(0x3e8c10) at 0x3e8c14
REFCNT = 1
FLAGS = (PADMY,IOK,pIOK)
IV = 1
http://cpansearch.perl.org/src/JDHEDDEN/threads-shared-1.33/shared.xs says
/* User-level locks:
This structure is attached (using ext magic) to any shared SV that
so you might have luck using Variable::Magic to peek at the magic | [reply] [d/l] [select] |