WL#1023: Check if we can get CPU time used by thread

Affects: Benchmarks-3.0 — Status: Un-Assigned — Priority: Medium

Check if there are a way (at least on primary platforms ) to account real
(possibly CPU+System) CPU utilization by the thread.

For process it is available in getrusage() as well in clock() function

If it is possible it shall be added to per thread performance counters.
Some other items from getrusage() are possibly good candidates to be available as 
global system statistics items.


[ Peter Gulutzan comment 2007-05-24 ]

It is possible with some operating systems using non-standard flags:
Solaris getrusage(RUSAGE_LWP) (LWP = "Light Weight Process")
http://docs.sun.com/app/docs/doc/816-5168/6mbb3hrcu?a=view
AIX getrusage(RUSAGE_THREAD)
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/getrusage_64.htm

It is not possible with NPTL thread library and Linux.
There has been some discussion about the possibility for later
Linux versions:
fa.linux.kernel thread "per-thread rusage"
http://groups.google.ca/group/fa.linux.kernel/browse_thread/thread/73202a7a81dd1f46/932c257a98ac91c0?lnk=gst&q=per-thread+rusage&rnum=1&hl=en#932c257a98ac91c0
[ Update 2008-10-29 ] Davi Arnaut says
"Linux supports per-thread resource usage since 2.6.25.
The RUSAGE_THREAD flag appeared in a later glibc version."

The analogous Windows function is GetThreadTimes
http://msdn2.microsoft.com/en-us/library/ms683237.aspx
On some (older?) Windows versions GetThreadTimes may not be useful though:
http://blog.kalmbachnet.de/?postid=28

Oracle uses a connection-per-process model for Unix-like systems while
MySQL uses a connection-per-thread model. That's why Oracle can take
advantage of getrusage in places that MySQL can't.

On some computers (e.g. testing with sol9x86) getrusage takes 2-3
microseconds. So be cautious about the suggestion of adding to
"per thread performance counters".

There is a contributed patch (SHOW PROFILE etc. in 5.0-community) which
depends on getrusage. See also dev-private thread
"BUG#28288 Query Profiler not available in MySQL 5.1 and 6.0"
[mysql intranet]/secure/mailarchive/mail.php?folder=4&mail=25818

On Dec 11, 2008 @ 16:42, Mark Callaghan wrote on mysql forge:
"This would be nice to have but you need new versions of Linux and/or
glibc to get this on Linux. And just because the getrusage interfaces
are there doesn't mean that you will get per-thread results.
We learned this the hard way."

You must be logged in to tag this worklog

Always finding that the CPU on my linux server hosting

I don't use Linux, but some of my friends do and they complaint about the complicated configuration, lol.. I think Linux is more complex to learn. cheap car insurance

FETCH statements that bring in exactly the number of columns in the 'SELECT' result set, instead of the fixed number that MySQL has now with "FETCH c INTO v1,v2,v3;".

BE degree AND diploma AND Accounting degree

Variable definition of variables, that is, "DECLARE variable data_type" statements (or something equivalent), for as many variables as there are in the 'SELECT' variable, with declared-variable data types the same as data types of the columns of the 'SELECT' result set.

Music degree AND diploma science

This would be nice to have but you need new versions of Linux and/or glibc to get this on Linux. And just because the getrusage interfaces are there doesn't mean that you will get per-thread results. We learned this the hard way.

Votes

  • Rated 5.00 out of 5
Rated 5.00 out of 5 with 1 votes cast.
You must be logged in to vote.

Watches

2 members are watching this worklog
You must be logged in to track this worklog.

Provide Feedback

Please note:
HTML will be purified, but we allow for a number of HTML tags so that you have the flexibility to decorate your comment text to some extent. The comments allow the following HTML tags:

strong, b, em, blockquote, a, code, pre

To put code into your comment, simply encapsulate your code with
[code language="XXX"][/code], where XXX is any common language, for instance "PHP", "SQL", "C", etc.



You must be logged in to comment