Find most CPU-hungry threads under Linux
Fri, 14 Jun 2013 11:48:17 +0000
It's pretty easy to find CPU usage per process (top, ps), but If you want to find top CPU users per thread there's a method:
$ awk '{printf "TID: %6u %8u %8u %8u \t %s \n", $1, $14, $15, $14+$15, $2;}' /proc/*/task/*/stat | sort -n -k 5 | tail -10 TID: 3600 33700 11461 45161 (metacity) TID: 3612 38053 7716 45769 (nautilus) TID: 3634 65079 0 65079 (dconf TID: 3601 64168 4997 69165 (gnome-panel) TID: 17298 137525 15650 153175 (firefox) TID: 3840 168736 21351 190087 (skype) TID: 11622 76119 150472 226591 (multiload-apple) TID: 3616 492076 53810 545886 (gnome-terminal) TID: 3617 370649 220327 590976 (skype) TID: 1072 626086 1031732 1657818 (Xorg)
Results are sorted by cumulated CPU usage (user + system).