How to Speed Up Amarok – Part 1 04/14/08

One of our articles was posted on Reddit (Top 10 Must Have Applications for Ubuntu.) and one user, made the following comment on:

Anyone know how to speed up Amarok when trying to listen to a library on a share? My Music library is about 17,000 songs which is stored on my NAS. It takes about 10 minutes to start listening to music from start up of Amarok. I’ve switch Amarok to use MySQL instead of SQL Lite which helped a bit but [not] nearly enough.

One thing to consider, that will help, is to “Improve Ubuntu Linux Operating Speed Performance.”

I had the same issue but with files (but not nearly as many files as that poster), stored on the local PC. I switched to MySQL stored on a small server (in the same network). While I did see an improvement, it was not as much as I expected. And I was disappointed because it took most of the day to copy the files across the network to the server. After playing and tweaking, I realized four things:

1) The NIC on that server was only 10mbps (while everywhere else it was 100mbps),
2) Too many PC’s were trying to send files back and forth across the newtork and out to the Internet,
3) Maybe I could improve the response on the server, on my PC or both (in other words provide some speed tweaks) and
4) Maybe if I had MySQL running on my local unit (Ubuntu) it might be faster (because it’s not using the network)?

It was time to fix this (as best I could)! Ideally it would be nice to have a 1000mbps network, but I can’t afford that. So I upgraded the NIC on the server (that was a no brainer). And I saw a substantial improvement. I was still not too happy, I thought it could be better?

As a result, I’m posting this to help other people who might have similar issues. Perhaps this reference can help (I hope so).

1. Avoid Network Bottlenecks

One way to help improve Amarok’s speed when files are stored on a server is to eliminate as many bottlenecks as possible. What’s a “bottleneck”? This is a bottleneck:

The delay in transmission (of files/data) through a PC’s CPU or through a network. This happens when a system’s bandwidth cannot support the amount of information being relayed at the speed it is being processed.

Several things can create a bottleneck in a system.
Bottlenecks affect CPU performance by slowing down the transmission of data back and forth from the CPU and the RAM (memory). If all of the components (devices) of a PC are not able to handle the same amount of data at the same speed, a delay (bottleneck) is created. For example, a 3GB Quad Core CPU will be (very badly) bottlenecked by an 800MB memory bandwidth capability. (In other words, use RAM that has a higher MHz rating so it can communicate faster with the CPU).
Bottlenecks are also found on the network, where data (file) transmission could be slowed down. In this case an example would be one PC that has a 1000gbps NIC trying to send or receive data from a 100mbps NIC. The speed would be bottlenecked down to the 100mpbs

Having said that, the obvious issues we can try to avoid here are:

2. Hardware:

Amarok should be installed on a PC with faster quality RAM so that the (faster) CPU can function more efficiently. (I think that is obvious!)

If Amarok is on another PC, ensure that the network hardware is not mismatched. In other words all NIC’s are 100mpbs not a mix of 10 and 100mbps. Ensure the switch or router connecting the two is also rated for your fastest bandwidth. If more that one router/switch is used, try to reduce that. Each connection includes some overhead to process, try reducing the number of “hops” (through network devices).

3. Network:

One issue I had was several PC’s using the Internet (Watching youTube, download, uploads, using webcam, etc.) and that seriously effected connections to the music files via Amarok. If possible try physically segmenting your network. The image below shows the network I created (and it did improve speed for me!)

Segmented Network for Amarok

Needless to say, the above shows an example that worked for me. Nothing fancy, just three routers and a broadband cable modem (for Internet connections). The point here is that the “Amarok Network” had much less traffic on it, so the response was greatly improved!

Warning: Some of the tweaks and information here might destroy your data if you are not a savvy Linux user (tweaker). ALWAYS BACKUP any valuable date before configuring, tweaking or making any changes to your system. If you are not sure about anything written in this post here or it’s comments, then DO NOT perform the activity,

4. Speed Tweaks:

Another issue I tried to resolve was improving the speed of my PC and the MySQL server. Here are some of the things I did…

For the Ubuntu Linux desktop PC:

A) Improve the “swappiness” of my system. Swappiness refers to the performance of Linux’s virtual memory subsystem. (I think Windows users would call this the Paging File).

A very good tweak is to make the desktop interface lighter. One thing you could do is use Fluxbox: http://fluxbox.sourceforge.net/ or even IceWM: http://www.icewm.org/. Both do a good job and are much lighter on your systems. However, if that’s not an option, we can still tweak swappiness.

The default value of swappiness is 60 and we can edit that for better performance. There are two fast ways to edit this value. One is just a straight echo like this:

echo 60 > /proc/sys/vm/swappiness

(You can echo if the following does not work) and the other uses sysctl like this:

sysctl -w vm.swappiness=60

After some googling, I found out that a lot of recommendations say “25″ is a good value to begin tweaking. That’s where I started and worked my way down. The system that has the Amarok player on it I finally set as:

sysctl -w vm.swappiness=0

Yes, that’s a zero. Why? It’s a bit newer and has 4GB of RAM so I thought I’d try at zero – And it worked!

I’ve since turned swappiness off (so that all needed things are in RAM):

sudo swapoff -a

(Turning it back on is just the reverse: sudo swapon -a).
Reboot the desktop and the setting will apply. I’d hazard a guess that systems with less RAM (1024MB or lower) would be better to start with the “25″ setting and tweak from there.

One tool you can use on the command line (which is how I found out I could go to zero), is called “free” and here’s the comand:

free -m

Look at the column titled “Free” that will tell youhow much memory is still available. Also running:

B) If you don’t want to use Fluxbox, IceWM, etc. we can still make (Gnome) response (menus) feel faster by changing the delay for when you click a menu item, by adding this:

gtk-menu-popup-delay = 0

to the bottom of this file: .gtkrc-2.0
I did a bit of searching but could not find the file, so had to create it here:

/home/ubplay/.gtkrc-2.0
(“ubplay” is the account name – so your’s will be different.

On this machine, it did make the menu more “zippy” than usual, but I think this tweak simply made things feel faster (than they really were).

c) If your system is earlier than Feisty (7.04 – https://wiki.ubuntu.com/DevelopmentCodeNames) then you may be able to improve application launch by using “prelinking”.

In general prelinking loads the libraries up so that when you want to launch an application (like Amarok) it will load faster, because the libraries don’t have to be linked during load time (it’s already been done). To get prelink working (ONLY on systems older than Feisty – Feisty already uses it’s own prelinking system), make sure your repository has the “universe” added.

More on repositories here: http://ubuntulinuxhelp.com/the-best-ubuntu-linux-repository-list/

Install prelink (only for systems earlier than feisty):

sudo apt-get install prelink

And edit the file:

sudo nano /etc/default/prelink

Find and change this:

PRELINKING=unknown

to look like this:

PRELINKING=yes

Now we need to start prelinking, first do this:

sudo nano /etc/cron.daily/prelink

Then to make sure new installations (apt-get install <whatever>) are use prelinking, do this:

sudo nano /etc/apt/apt.conf

Add this line to the bottom of the conf file:

DPkg::Post-Invoke {"echo One moment, I am running prelink...;/etc/cron.daily/prelink";}

D) Disable unneeded services from running. I found an awesome guide for that here:

How To: Speed up ubuntu boot process – the way you can feel it.
http://ubuntuforums.org/showthread.php?t=89491
Use it! It works! :-)

Stay tuned for Part 2, where we will look at “Tweaking the Ubuntu Linux MySQL Server”

As always… I hope this helps some of you. :)

Care to Share?


You can leave a response, or trackback from your own site.

One Responses to this article

 
Bob February 22, 2010 Reply

The basic problem is that Amarok is a resource hog. Efforts should be focused on improving Amarok, not a handful of minor tweaks outside thge program that won’t make much difference.

Leave a Reply

close comment popup

Leave A Reply