#!/usr/sbin/dtrace -qs /* * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved. * * mutex.d - Display DB mutex wait times. * * Specify the target application with -p or -c " [..]" * * The optional integer maxcount parameter directs the script to exit once that * many mutex times have been accumulated. * * usage: apicalls.d { -p | -c " [suspend = timestamp; } /* mutex-resume(unsigned mutex, boolean exclusive, unsigned alloc_id, struct __db_mutex_t *mutexp) */ bdb$target:::mutex-resume /self->suspend/ { this->duration = timestamp - self->suspend; self->suspend = 0; @mutexwaits[arg0, arg1, idnames[arg2], tid] = quantize(this->duration); @classwaits[idnames[arg2], arg1] = quantize(this->duration); mutexcount++; } bdb$target:::mutex-resume /mutexcount == maxcount/ { exit(0); } dtrace:::END { printf("Mutex wait times grouped by (mutex, mode, thread)\n"); printa("Mutex %d exclusive %d %s thread %p wait times in nanoseconds %@d\n", @mutexwaits); printf("\nAggregate mutex wait times grouped by (alloc_id, mode)\n"); printa("Mutex class %s exclusive %d wait times in nanoseconds %@d\n", @classwaits); }