Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


System optimizations?
#58
Here's a bit of analysis :-)

Try the commands below to get a sense of the volume of context switches happening for just the MPD process and its associated threads.

1) Get the process (PID) and thread (TID) id's for MPD

ps H -q `pidof -s mpd` -o 'pid,tid,cls,rtprio,comm'
 PID   TID CLS RTPRIO COMMAND
 961   961  TS      - mpd
 961   965  TS      - io
 961   966  FF     50 rtio
 961  1222  TS      - player
 961  1223  TS      - decoder:flac
 961  1248  FF     50 output:ALSA def

2) Monitor the number of CPU context switches by PID/TID from above

watch -n.5 grep ctxt /proc/961/status
watch -n.5 grep ctxt /proc/965/status
watch -n.5 grep ctxt /proc/966/status
watch -n.5 grep ctxt /proc/1222/status
watch -n.5 grep ctxt /proc/1223/status
watch -n.5 grep ctxt /proc/1248/status

What you will see in the command output is the number of voluntary vs involuntary context switches. Here is what that means.

A context switch is voluntary if the process or thread gives up the CPU because it has nothing else to do for example while it is waiting for something external to happen like an I-O interrupt from the audio device requesting more data. A context switch is involuntary if the process or task would like to continue doing work but the OS decides it's time to switch to some other process or thread.

In my example above the MPD process (961) has no CPU context switches shortly after music starts playing. The output:ALSA def thread (1248) will continuously context switch but all are voluntary which suggests its simply waiting for hardware interrupts from the audio device requesting more data, as opposed to being preempted by some other thread or giving up its CPU time slice.

You should see something like below for the output:ALSA def thread where voluntary_ctxt_switches constantly increases while nonvoluntary_ctxt_switches remains 0.

Every 0.5s: grep ctxt /proc/1248/status                                                                                                                                             rp3: Fri Nov  9 20:44:32 2018

voluntary_ctxt_switches:        505754
nonvoluntary_ctxt_switches:     0

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Messages In This Thread
System optimizations? - by Mullet - 04-19-2018, 02:16 PM
RE: System optimizations? - by swizzle - 04-20-2018, 08:49 PM
RE: System optimizations? - by moodenigo - 06-06-2018, 12:53 PM
RE: System optimizations? - by TheOldPresbyope - 06-06-2018, 01:49 PM
RE: System optimizations? - by Bento - 08-14-2018, 09:09 PM
RE: System optimizations? - by moodenigo - 08-20-2018, 09:15 AM
RE: System optimizations? - by hifix - 08-20-2018, 02:45 PM
RE: System optimizations? - by Mullet - 04-24-2018, 11:37 PM
RE: System optimizations? - by Skip Pack - 04-25-2018, 05:21 PM
RE: System optimizations? - by rhizomusicosmos - 04-25-2018, 11:23 PM
RE: System optimizations? - by Skip Pack - 04-26-2018, 02:52 AM
RE: System optimizations? - by hifix - 05-01-2018, 08:08 AM
RE: System optimizations? - by Mullet - 05-01-2018, 02:12 AM
RE: System optimizations? - by rhizomusicosmos - 05-01-2018, 05:48 AM
RE: System optimizations? - by yannig - 04-28-2018, 02:38 AM
RE: System optimizations? - by moodenigo - 06-07-2018, 08:37 AM
RE: System optimizations? - by barryso - 08-05-2018, 11:48 PM
RE: System optimizations? - by hifix - 08-18-2018, 05:25 PM
RE: System optimizations? - by JST1963 - 08-18-2018, 09:19 PM
RE: System optimizations? - by hifix - 08-18-2018, 11:18 PM
RE: System optimizations? - by kvik2 - 08-20-2018, 12:39 PM
RE: System optimizations? - by swizzle - 08-25-2018, 12:18 AM
RE: System optimizations? - by jayce996 - 09-04-2018, 08:49 AM
RE: System optimizations? - by Deenoo - 09-06-2018, 03:51 PM
RE: System optimizations? - by jayce996 - 09-05-2018, 04:22 PM
RE: System optimizations? - by Tim Curtis - 09-05-2018, 09:56 PM
RE: System optimizations? - by swizzle - 09-06-2018, 02:35 AM
RE: System optimizations? - by jayce996 - 09-07-2018, 06:59 PM
RE: System optimizations? - by Tim Curtis - 09-07-2018, 07:16 PM
RE: System optimizations? - by Vhond - 09-24-2018, 12:54 PM
RE: System optimizations? - by hifix - 09-25-2018, 05:23 PM
RE: System optimizations? - by Vhond - 10-28-2018, 12:00 PM
RE: System optimizations? - by mactolinux - 10-08-2018, 10:37 AM
RE: System optimizations? - by rikardo1979 - 10-08-2018, 12:31 PM
RE: System optimizations? - by jonners - 10-08-2018, 12:50 PM
RE: System optimizations? - by rikardo1979 - 10-08-2018, 01:47 PM
RE: System optimizations? - by mactolinux - 10-08-2018, 04:46 PM
RE: System optimizations? - by Strider - 11-15-2018, 03:12 PM
RE: System optimizations? - by jonners - 10-09-2018, 06:59 PM
RE: System optimizations? - by mactolinux - 10-10-2018, 07:24 AM
RE: System optimizations? - by rikardo1979 - 10-10-2018, 08:33 AM
RE: System optimizations? - by mactolinux - 10-10-2018, 09:28 AM
RE: System optimizations? - by mactolinux - 10-10-2018, 09:31 AM
RE: System optimizations? - by rikardo1979 - 10-10-2018, 10:17 AM
RE: System optimizations? - by mactolinux - 10-10-2018, 10:08 AM
RE: System optimizations? - by mactolinux - 10-10-2018, 10:49 AM
RE: System optimizations? - by rikardo1979 - 10-10-2018, 10:56 AM
RE: System optimizations? - by mactolinux - 10-10-2018, 11:03 AM
RE: System optimizations? - by Gervasutti - 10-14-2018, 12:27 PM
RE: System optimizations? - by mactolinux - 10-15-2018, 08:10 AM
RE: System optimizations? - by Gervasutti - 10-15-2018, 01:14 PM
RE: System optimizations? - by mactolinux - 10-15-2018, 01:17 PM
RE: System optimizations? - by Gervasutti - 10-15-2018, 02:49 PM
RE: System optimizations? - by Tim Curtis - 11-04-2018, 11:36 PM
RE: System optimizations? - by TheOldPresbyope - 11-07-2018, 02:10 PM
RE: System optimizations? - by mactolinux - 11-06-2018, 03:31 PM
RE: System optimizations? - by Vhond - 11-07-2018, 01:51 PM
RE: System optimizations? - by swizzle - 11-09-2018, 10:00 PM
RE: System optimizations? - by Tim Curtis - 11-10-2018, 02:07 AM
RE: System optimizations? - by mactolinux - 11-15-2018, 03:13 PM
RE: System optimizations? - by Strider - 11-15-2018, 03:17 PM
RE: System optimizations? - by 4mayday - 11-16-2018, 09:16 AM
RE: System optimizations? - by DRONE7 - 11-16-2018, 10:06 AM
RE: System optimizations? - by 4mayday - 11-16-2018, 10:12 AM
RE: System optimizations? - by energyi - 09-14-2021, 02:51 AM
RE: System optimizations? - by the_bertrum - 09-14-2021, 08:23 AM
RE: System optimizations? - by vinnn - 09-20-2021, 02:50 PM
RE: System optimizations? - by Gekel - 09-29-2021, 07:42 AM
RE: System optimizations? - by Tim Curtis - 01-31-2022, 11:53 PM
RE: System optimizations? - by Tim Curtis - 02-01-2022, 04:18 AM
RE: System optimizations? - by cryptout - 02-15-2022, 05:51 AM

Forum Jump: