Thank you for your donation!


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


System optimizations?
#51
OK, I really didn't know how it works and IF I needed it... thank you!
Reply
#52
(09-25-2018, 05:23 PM)hifix Wrote:
(09-24-2018, 12:54 PM)Vhond Wrote:
(08-20-2018, 02:45 PM)hifix Wrote:
(06-06-2018, 12:53 PM)moodenigo Wrote: The only tweaks I have applied are the following:

- added in /boot/cmdline.txtisolcpus=2,3
- changed options in /lib/systemd/system/mpd.service
    CPUSchedulingPolicy=fifo
    CPUSchedulingPriority=70
    Nice=-15
    ExecStart=/usr/bin/taskset -c 2,3 /usr/local/bin/mpd --no-daemon $MPDCONF

I did not change anything else. This made some difference!  In fact, because of the fact that mpd and its subprocesses run on two reserved cores, and nothing else runs on those cores, you should get all the advantages of LL and RT kernels.

  Roberto

Its all sounding very nice now Big Grin

Has anyone been game to try the whole list of tweaks from the DIY forum as swizzle has pointed out ?
http://www.diyaudio.com/forums/pc-based/...ost5398891

Also tried this tweak (3.8.4), it worked (it sounded more open) but I couldn't reboot / shutdown the RPI/Moode anymore using the menu functionality from the GUI...

Sorry to hear about the reboot issue.
I have been playing around with some of the parameters and i've not experienced a loss of functionality (i'm running an audiophonics power management script which is needed for my setup - but i dont think this changes anything).

Have you made any other changes ?
No I didn't but as said I am using 3.8.4 (not 4.x) on a RPI 2B
Reply
#53
Enjoy some new out-of-the-box MPD optimizations coming with moOde 4.4 courtesy of the newly released MPD 0.21 series :-) Kudos to Max Kellermann for his wonderful software engineering.

Code:
Authenticated to rp3 ([192.168.1.157]:22).
Linux kernel 4.14.78-v7+ running on armv7l architecture
                         ____     __  
             __ _  ___  / __ \___/ /__
            /  ' \/ _ \/ /_/ / _  / -_)
           /_/_/_/\___/\____/\_,_/\__/
                                         
                moOde audio player
               (C) 2014 Tim Curtis


The programs included with Moode are free software; the
exact distribution terms for each program are described
in the individual files in /usr/share/doc/*/copyright.
Moode comes with absolutely no warranties expressed or
implied, or any other guarantees.

pi@rp3:~ $ ps H -q `pidof -s mpd` -o 'pid,tid,cls,rtprio,comm'
 PID   TID CLS RTPRIO COMMAND
 805   805  TS      - mpd
 805   809  TS      - io
 805   810  FF     50 rtio
 805  1068  TS      - player
 805  1069  TS      - decoder:mad
 805  1094  FF     50 output:ALSA def
pi@rp3:~ $
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#54
Intrigue! Awaiting for it... When do you plan to go?
Reply
#55
Interesting

MPD changelog
Reply
#56
(11-04-2018, 11:36 PM)Tim Curtis Wrote: Enjoy some new out-of-the-box MPD optimizations coming with moOde 4.4 courtesy of the newly released MPD 0.21 series :-) Kudos to Max Kellermann for his wonderful software engineering.

Code:
Authenticated to rp3 ([192.168.1.157]:22).
Linux kernel 4.14.78-v7+ running on armv7l architecture
                         ____     __  
             __ _  ___  / __ \___/ /__
            /  ' \/ _ \/ /_/ / _  / -_)
           /_/_/_/\___/\____/\_,_/\__/
                                         
                moOde audio player
               (C) 2014 Tim Curtis


The programs included with Moode are free software; the
exact distribution terms for each program are described
in the individual files in /usr/share/doc/*/copyright.
Moode comes with absolutely no warranties expressed or
implied, or any other guarantees.

pi@rp3:~ $ ps H -q `pidof -s mpd` -o 'pid,tid,cls,rtprio,comm'
 PID   TID CLS RTPRIO COMMAND
 805   805  TS      - mpd
 805   809  TS      - io
 805   810  FF     50 rtio
 805  1068  TS      - player
 805  1069  TS      - decoder:mad
 805  1094  FF     50 output:ALSA def
pi@rp3:~ $

Woot! Real-time scheduling "for some threads that benefit from it" [a quote from the MPD manual], in this case the rtio and output threads.

There's an important note about this in the MPD manual:

Quote:Note

There is a rumor that real-time scheduling improves audio quality. That is not true. All it does is reduce the probability of skipping (audio buffer xruns) when the computer is under heavy load.

Regards,
Kent
Reply
#57
The other advantage of rt (or isolating cores as mentioned earlier in the thread, which accomplishes much the same thing) is it reduces the likelihood that other processes will interrupt the audio rendering thread which could increase jitter (a slightly time-misaligned audio frame). That doesn’t usually manifest as missing samples but as the music not sounding as accurate as it otherwise would (and lack of accuracy is usually expressed as it not sounding natural). MPD moving to some processes being rt is a welcome move and should have moode sounding better than ever even without config file hacking.
Reply
#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
#59
(10-08-2018, 04:46 PM)mactolinux Wrote: Mine, as a combination from different sources. Please note, I isolated one core for MPD, but didn't try more.
I would say now the power quality is more important.

1.
sudo nano /boot/cmdline.txt

net.ifnames=0 console=serial0,115200 console=tty1 root=PARTUUID=4d3ee428-02 rootfstype=ext4 fsck.repair=yes rootwait dwc_otg.microframe_schedule=0 dwc_otg.nak_holdoff_enable=1 dwc_otg.fiq_fix_enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 elevator=noop isolcpus=3

2.
sudo nano /boot/config.txt

disable_splash=1
hdmi_drive=2
dtparam=i2c_arm=off
dtparam=i2s=off
dtparam=audio=on
#dtoverlay=pi3-disable-wifi
dtoverlay=pi3-disable-bt
start_x=0

max_usb_current=1

# memory options
gpu_mem=16

# Overclocking options
force_turbo=1
initial_turbo=60

avoid_pwm_pll=1
arm_freq=666
over_voltage=-6
gpu_freq=333

# sdram overclock
sdram_freq=333

sdram_schmoo=0x02000020
over_voltage_sdram_p=-5
over_voltage_sdram_i=-14
over_voltage_sdram_c=-6

disable_pvt=1

# HDMI disable
hdmi_blanking=2

3.
sudo nano /lib/systemd/system/mpd.service

[Service]
# Real-time / Low latency params
# ps -e -o class,rtprio,pri,nice,cmd
# for real-time scheduling policies the "nice" param is ignored and the pri column is not relevant
ExecStart=/usr/bin/taskset -c 3 /usr/local/bin/mpd --no-daemon $MPDCONF
Restart=always


--------------  (note) At the very end of original script add # once at ExecStart:
# Launch params
EnvironmentFile=/etc/default/mpd
#ExecStart=/usr/local/bin/mpd --no-daemon $MPDCONF

#CPUSchedulingPolicy=other
CPUSchedulingPolicy=fifo
#CPUSchedulingPriority=43
CPUSchedulingPriority=70
Nice=-18


Updated: forgot core isolation line here, just added. Sorry.

My apologies for sounding a little dim, can the above changes be made by using Putty to SSH to the RPi?
 Kind regards, 
Mark
Reply
#60
ssh via terminal on Mac
Reply


Forum Jump: