Have you checked out the benchmarks in the runtime and sync packages? You may be able to adapt them to your purpose.
Yes, I could have been clearer, I am trying to do some simple benchmarking of lock contention. I appreciate all the assumptions/dependencies etc but it would be good to know if this is possible at all (without hacking the go src in runtime or making C calls). My first grok through the packages and exposed APIs suggests no.
Thanks, but I don't think either the benchmarks or the profiling provide the information I'm after i.e. which core did the go routine execute on. Contention for a lock will clearly be different if both routines run in the same core, cpu or same socket as opposed to running distributed across cores/cpu/sockets in a shared memory system.It's not a problem, just curious to know if there was a way to observe it.// Matt
Isn't this what the up coming race detector is for?
If not
perf list --help
+ your cpu's manual for the specific performance monitoring counter.
There are counters for cache contention which will be caused by lock contention.
Thanks, but I don't think either the benchmarks or the profiling provide the information I'm after i.e. which core did the go routine execute on. Contention for a lock will clearly be different if both routines run in the same core, cpu or same socket as opposed to running distributed across cores/cpu/sockets in a shared memory system.It's not a problem, just curious to know if there was a way to observe it.
It's a shame not all architectures allow user level access to getting cpuid.
In response to the code you listed on github, you probably want to use a slice (or array) for the counter inside the instrumented mutex. The map introduces a 10x hit on lock/unlock of the mutex. Additionally you probably only need to update the counter on the Lock method.
FWIW, after poking around a bit, it seems like this approach to RW
locking is far from new. Linux calls then "big reader locks"
(https://lwn.net/Articles/378911/).
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.