Lock profiling on Win2k?

Anybody knows if there is some equivalent of lockstat (solaris), on Win2k?.

Thanks
-Johnny


DESCRIPTION
lockstat gathers and displays statistics on kernel synchron-
ization objects. lockstat allows you to specify which lock
events to watch (for example, spin on adaptive mutex, block
on read access to rwlock due to waiting writers, and so
forth), how much data to gather for each event, and how to
display that data. By default, lockstat monitors all lock
contention events, gathers frequency and timing data about
those events, and displays that data in order of decreasing
frequency so that the most heavily contended locks appear
first.

lockstat gathers kernel locking statistics until the speci-
fied command completes. For example, to gather statistics
for a fixed time interval, specify sleep(1) as the command,
as follows:

example# lockstat sleep 5


Chat with friends online, try MSN Messenger: http://messenger.msn.com

!locks in WinDbg, but this is not a command-line tool and supports
ERESOURCE locks only.

Max

----- Original Message -----
From: “Johnny D”
To: “NT Developers Interest List”
Sent: Thursday, June 06, 2002 5:55 AM
Subject: [ntdev] Lock profiling on Win2k?

> Anybody knows if there is some equivalent of lockstat (solaris), on
Win2k?.
>
> Thanks
> -Johnny
>
> -------
>
> DESCRIPTION
> lockstat gathers and displays statistics on kernel synchron-
> ization objects. lockstat allows you to specify which lock
> events to watch (for example, spin on adaptive mutex, block
> on read access to rwlock due to waiting writers, and so
> forth), how much data to gather for each event, and how to
> display that data. By default, lockstat monitors all lock
> contention events, gathers frequency and timing data about
> those events, and displays that data in order of decreasing
> frequency so that the most heavily contended locks appear
> first.
>
> lockstat gathers kernel locking statistics until the speci-
> fied command completes. For example, to gather statistics
> for a fixed time interval, specify sleep(1) as the command,
> as follows:
>
> example# lockstat sleep 5
>
>
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger:
http://messenger.msn.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>

Max, I am looking for run-time kernel lock profiling. Dont want to break
into the debugger.

Regards
-Johnny

From: “Maxim S. Shatskih”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] Re: Lock profiling on Win2k?
>Date: Fri, 7 Jun 2002 00:02:06 +0400
>
>!locks in WinDbg, but this is not a command-line tool and supports
>ERESOURCE locks only.
>
> Max
>
>----- Original Message -----
>From: “Johnny D”
>To: “NT Developers Interest List”
>Sent: Thursday, June 06, 2002 5:55 AM
>Subject: [ntdev] Lock profiling on Win2k?
>
>
> > Anybody knows if there is some equivalent of lockstat (solaris), on
>Win2k?.
> >
> > Thanks
> > -Johnny
> >
> > -------
> >
> > DESCRIPTION
> > lockstat gathers and displays statistics on kernel synchron-
> > ization objects. lockstat allows you to specify which lock
> > events to watch (for example, spin on adaptive mutex, block
> > on read access to rwlock due to waiting writers, and so
> > forth), how much data to gather for each event, and how to
> > display that data. By default, lockstat monitors all lock
> > contention events, gathers frequency and timing data about
> > those events, and displays that data in order of decreasing
> > frequency so that the most heavily contended locks appear
> > first.
> >
> > lockstat gathers kernel locking statistics until the speci-
> > fied command completes. For example, to gather statistics
> > for a fixed time interval, specify sleep(1) as the command,
> > as follows:
> >
> > example# lockstat sleep 5
> >
> >
> >
> >
> > Chat with friends online, try MSN Messenger:
>http://messenger.msn.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to %%email.unsub%%
> >
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to %%email.unsub%%


Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

If the locks you’re interested in are in your own code, you can add
conditionally compiled wrappers around those locks to get the
instrumentation you desire. KSPIN_LOCKs and mutexes are not
instrumented; only ERESOURCEs are.

/George V. Reilly mailto:xxxxx@microsoft.com
Internet Information Server / http.sys Developer

-----Original Message-----
From: Johnny D [mailto:xxxxx@hotmail.com]
Sent: Thursday, June 06, 2002 3:13 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Lock profiling on Win2k?

Max, I am looking for run-time kernel lock profiling. Dont want to break

into the debugger.

Regards
-Johnny

From: “Maxim S. Shatskih”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] Re: Lock profiling on Win2k?
>Date: Fri, 7 Jun 2002 00:02:06 +0400
>
>!locks in WinDbg, but this is not a command-line tool and supports
>ERESOURCE locks only.
>
> Max
>
>----- Original Message -----
>From: “Johnny D”
>To: “NT Developers Interest List”
>Sent: Thursday, June 06, 2002 5:55 AM
>Subject: [ntdev] Lock profiling on Win2k?
>
>
> > Anybody knows if there is some equivalent of lockstat (solaris), on
>Win2k?.
> >
> > Thanks
> > -Johnny
> >
> > -------
> >
> > DESCRIPTION
> > lockstat gathers and displays statistics on kernel synchron-
> > ization objects. lockstat allows you to specify which lock
> > events to watch (for example, spin on adaptive mutex, block
> > on read access to rwlock due to waiting writers, and so
> > forth), how much data to gather for each event, and how to
> > display that data. By default, lockstat monitors all lock
> > contention events, gathers frequency and timing data about
> > those events, and displays that data in order of decreasing
> > frequency so that the most heavily contended locks appear
> > first.
> >
> > lockstat gathers kernel locking statistics until the speci-
> > fied command completes. For example, to gather statistics
> > for a fixed time interval, specify sleep(1) as the command,
> > as follows:
> >
> > example# lockstat sleep 5
> >
> >
> >
> >
> > Chat with friends online, try MSN Messenger:
>http://messenger.msn.com
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
> > unsubscribe send a blank email to %%email.unsub%%
> >
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com To
>unsubscribe send a blank email to %%email.unsub%%


Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp.


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%

Sure I can do that and also write a usermode app to periodically pool and
get the stats, and the time diffs between the acquisitions/release etc. But
it is a bit surprising that there isnt any existing tool that already does
that.

Thanks
-Johnny

From: “George Reilly”
>Reply-To: “NT Developers Interest List”
>To: “NT Developers Interest List”
>Subject: [ntdev] Re: Lock profiling on Win2k?
>Date: Thu, 6 Jun 2002 15:47:09 -0700
>
>If the locks you’re interested in are in your own code, you can add
>conditionally compiled wrappers around those locks to get the
>instrumentation you desire. KSPIN_LOCKs and mutexes are not
>instrumented; only ERESOURCEs are.
>–
>/George V. Reilly mailto:xxxxx@microsoft.com
>Internet Information Server / http.sys Developer
>
>
>-----Original Message-----
>From: Johnny D [mailto:xxxxx@hotmail.com]
>Sent: Thursday, June 06, 2002 3:13 PM
>To: NT Developers Interest List
>Subject: [ntdev] Re: Lock profiling on Win2k?
>
>
>
>Max, I am looking for run-time kernel lock profiling. Dont want to break
>
>into the debugger.
>
>Regards
>-Johnny
>
> >From: “Maxim S. Shatskih”
> >Reply-To: “NT Developers Interest List”
> >To: “NT Developers Interest List”
> >Subject: [ntdev] Re: Lock profiling on Win2k?
> >Date: Fri, 7 Jun 2002 00:02:06 +0400
> >
> >!locks in WinDbg, but this is not a command-line tool and supports
> >ERESOURCE locks only.
> >
> > Max
> >
> >----- Original Message -----
> >From: “Johnny D”
> >To: “NT Developers Interest List”
> >Sent: Thursday, June 06, 2002 5:55 AM
> >Subject: [ntdev] Lock profiling on Win2k?
> >
> >
> > > Anybody knows if there is some equivalent of lockstat (solaris), on
> >Win2k?.
> > >
> > > Thanks
> > > -Johnny
> > >
> > > -------
> > >
> > > DESCRIPTION
> > > lockstat gathers and displays statistics on kernel synchron-
> > > ization objects. lockstat allows you to specify which lock
> > > events to watch (for example, spin on adaptive mutex, block
> > > on read access to rwlock due to waiting writers, and so
> > > forth), how much data to gather for each event, and how to
> > > display that data. By default, lockstat monitors all lock
> > > contention events, gathers frequency and timing data about
> > > those events, and displays that data in order of decreasing
> > > frequency so that the most heavily contended locks appear
> > > first.
> > >
> > > lockstat gathers kernel locking statistics until the speci-
> > > fied command completes. For example, to gather statistics
> > > for a fixed time interval, specify sleep(1) as the command,
> > > as follows:
> > >
> > > example# lockstat sleep 5
> > >
> > >
> > >
> > >
> > > Chat with friends online, try MSN Messenger:
> >http://messenger.msn.com
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@storagecraft.com To
> > > unsubscribe send a blank email to %%email.unsub%%
> > >
> >
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@hotmail.com To
> >unsubscribe send a blank email to %%email.unsub%%
>
>
>

>Get your FREE download of MSN Explorer at
>http://explorer.msn.com/intl.asp.
>
>
>—
>You are currently subscribed to ntdev as: xxxxx@microsoft.com To
>unsubscribe send a blank email to %%email.unsub%%
>
>—
>You are currently subscribed to ntdev as: xxxxx@hotmail.com
>To unsubscribe send a blank email to %%email.unsub%%

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

It is very, very rarely needed, and MS decided to avoid instrumenting
fast mutexes and spinlocks.

Max

----- Original Message -----
From: “Johnny D”
To: “NT Developers Interest List”
Sent: Friday, June 07, 2002 4:06 AM
Subject: [ntdev] Re: Lock profiling on Win2k?

>
> Sure I can do that and also write a usermode app to periodically
pool and
> get the stats, and the time diffs between the acquisitions/release
etc. But
> it is a bit surprising that there isnt any existing tool that
already does
> that.
>
> Thanks
> -Johnny
>
> >From: “George Reilly”
> >Reply-To: “NT Developers Interest List”
> >To: “NT Developers Interest List”
> >Subject: [ntdev] Re: Lock profiling on Win2k?
> >Date: Thu, 6 Jun 2002 15:47:09 -0700
> >
> >If the locks you’re interested in are in your own code, you can add
> >conditionally compiled wrappers around those locks to get the
> >instrumentation you desire. KSPIN_LOCKs and mutexes are not
> >instrumented; only ERESOURCEs are.
> >–
> >/George V. Reilly mailto:xxxxx@microsoft.com
> >Internet Information Server / http.sys Developer
> >
> >
> >-----Original Message-----
> >From: Johnny D [mailto:xxxxx@hotmail.com]
> >Sent: Thursday, June 06, 2002 3:13 PM
> >To: NT Developers Interest List
> >Subject: [ntdev] Re: Lock profiling on Win2k?
> >
> >
> >
> >Max, I am looking for run-time kernel lock profiling. Dont want to
break
> >
> >into the debugger.
> >
> >Regards
> >-Johnny
> >
> > >From: “Maxim S. Shatskih”
> > >Reply-To: “NT Developers Interest List”
> > >To: “NT Developers Interest List”
> > >Subject: [ntdev] Re: Lock profiling on Win2k?
> > >Date: Fri, 7 Jun 2002 00:02:06 +0400
> > >
> > >!locks in WinDbg, but this is not a command-line tool and
supports
> > >ERESOURCE locks only.
> > >
> > > Max
> > >
> > >----- Original Message -----
> > >From: “Johnny D”
> > >To: “NT Developers Interest List”
> > >Sent: Thursday, June 06, 2002 5:55 AM
> > >Subject: [ntdev] Lock profiling on Win2k?
> > >
> > >
> > > > Anybody knows if there is some equivalent of lockstat
(solaris), on
> > >Win2k?.
> > > >
> > > > Thanks
> > > > -Johnny
> > > >
> > > > -------
> > > >
> > > > DESCRIPTION
> > > > lockstat gathers and displays statistics on kernel
synchron-
> > > > ization objects. lockstat allows you to specify which
lock
> > > > events to watch (for example, spin on adaptive mutex,
block
> > > > on read access to rwlock due to waiting writers, and
so
> > > > forth), how much data to gather for each event, and how
to
> > > > display that data. By default, lockstat monitors all
lock
> > > > contention events, gathers frequency and timing data
about
> > > > those events, and displays that data in order of
decreasing
> > > > frequency so that the most heavily contended locks
appear
> > > > first.
> > > >
> > > > lockstat gathers kernel locking statistics until the
speci-
> > > > fied command completes. For example, to gather
statistics
> > > > for a fixed time interval, specify sleep(1) as the
command,
> > > > as follows:
> > > >
> > > > example# lockstat sleep 5
> > > >
> > > >
> > > >
> > > >

> > > > Chat with friends online, try MSN Messenger:
> > >http://messenger.msn.com
> > > >
> > > >
> > > > —
> > > > You are currently subscribed to ntdev as:
xxxxx@storagecraft.com To
> > > > unsubscribe send a blank email to %%email.unsub%%
> > > >
> > >
> > >
> > >—
> > >You are currently subscribed to ntdev as: xxxxx@hotmail.com
To
> > >unsubscribe send a blank email to %%email.unsub%%
> >
> >
> >

> >Get your FREE download of MSN Explorer at
> >http://explorer.msn.com/intl.asp.
> >
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@microsoft.com To
> >unsubscribe send a blank email to %%email.unsub%%
> >
> >—
> >You are currently subscribed to ntdev as: xxxxx@hotmail.com
> >To unsubscribe send a blank email to %%email.unsub%%
>
>
> _________________________________________________________________
> Join the world’s largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>

What I ended up doing was to define my own inline functions with similar names
that would expand into the real thing with default options, but into my own
functions in with other options.
Instead of keeping statistics, I reimplemented the lock functions inline,
since I was much more interested in time than count, and looked at the
result in VTune. VTUNE (kernprof.exe does essentially the same thing)
tells the kernel to sample the current PC
on a profile interrupt (a time based interrupt that is asynchronous
to the normal timer interrupt). The inlining was critical, or else the PC
just ended up in lock code, and you’d see only the lock primitives
with any time.

You could keep your own stats in a similar manner.

-DH
PS. The locking is trivial to do inline, but the IRL manipulation is not.

“Johnny D” wrote in message news:xxxxx@ntdev…
>
> Anybody knows if there is some equivalent of lockstat (solaris), on Win2k?.
>
> Thanks
> -Johnny
>
> -------
>
> DESCRIPTION
> lockstat gathers and displays statistics on kernel synchron-
> ization objects. lockstat allows you to specify which lock
> events to watch (for example, spin on adaptive mutex, block
> on read access to rwlock due to waiting writers, and so
> forth), how much data to gather for each event, and how to
> display that data. By default, lockstat monitors all lock
> contention events, gathers frequency and timing data about
> those events, and displays that data in order of decreasing
> frequency so that the most heavily contended locks appear
> first.
>
> lockstat gathers kernel locking statistics until the speci-
> fied command completes. For example, to gather statistics
> for a fixed time interval, specify sleep(1) as the command,
> as follows:
>
> example# lockstat sleep 5
>
>
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
>