WL#1023: Check if we can get CPU time used by thread
Affects: Benchmarks-3.0
—
Status: Un-Assigned
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."
Copyright (c) 2000, 2024, Oracle Corporation and/or its affiliates. All rights reserved.