Linux Format

ACCELERATE CORE COMPONENTS

-

Your distro should be in quite a good condition if you’ve followed the steps on the previous pages. The good news is that there’s still scope for improvemen­t. On the downside, however, the tricks from here on are more involved and come with a disclaimer: if applied recklessly, they can have serious repercussi­ons on your installati­on.

Track stragglers

In addition to startup apps (which we’ve already pruned earlier in the feature), a typical Linux distro also runs a large number of services. You don’t need all of them and starting them every time you boot your computer wastes resources. Even if you have the resources to spare, remember that services can be exploited and running ones you don’t need is, in effect, an additional security risk.

But before you axe them, it’s best to get a picture of what’s happening while your distro boots up. Bootchart is a handy utility that enables you to profile your Linux boot process and measure the loading times of different services. In fact it’s so useful that it’s now rolled inside Systemd. To use it, fire up a terminal and enter systemdana­lyze time to reveal the time taken to boot your machine. Similarly, systemd-analyze blame lists all running units, ordered by the time they took to start.

To generate an image of the boot process, type systemd-analyze plot > boot.svg . From this image you can find all active processes and remove the ones you don’t need. For example, if you print occasional­ly, you can disable CUPS from starting at boot time. The image also helps you to identify processes that take control of all resources and force the others to wait, effectivel­y blocking the boot process. Now that you understand how your computer boots up and the services that are started, it’s time to tailor the boot process to your requiremen­ts and shave off some time. Use systemctl disable to turn off any service that you don’t require.

Wondering why your Ram-laden machine is still slow off the blocks? Chances are it’s because your distro is still using swap space on the hard disk, which has a far slower read/write speed than RAM.

If your system has enough memory to handle whatever you throw at it, you should minimise the use of swap space. The swappiness parameter governs the kernel’s ability to move processes out of physical memory and onto the swap disk, which in certain situations can increase applicatio­n response times.

The command cat /proc/sys/vm/swappiness will display the current level of swappiness set by your distro. Ubuntu’s default swappiness value is 60. The parameter will accept any value between 0 and 100. Set a lower value if you want to avoid swapping-out processes. If you set a value of 0 the kernel will stop swapping processes out of physical memory to the swap partition for as long as possible. Ubuntu’s default value means that the kernel will begin swapping when your computer uses up 40 per cent of the physical RAM.

Use the sudo sysctl vm.swappiness=10 command to temporaril­y change the swappiness value to 10, which tells the kernel to only use swap space when 90 per cent or more of the RAM is used up. This change will be lost when you restart the computer. If you notice a spring in the step of your distro, you can preserve the value by editing the /etc/sysctl.conf file in a text editor. Look for the vm.swappiness parameter in the file and change its value. If it doesn’t exist, you can add it at the end of the file.

Fabricate memory

On the other hand, if your problem is a lack of RAM, you can make better use of it with the help of your fast processor. In our experience this works best with top-ofthe-line netbooks and virtual machines. On such computers you can use the ZRAM kernel module to create a device in RAM and compress it. Thanks to this compressio­n factor you effectivel­y increase your RAM.

When you use ZRAM, you are taxing your processor since it will have to constantly compress and decompress memory. Even with this handicap, the use of ZRAM turns out to be more efficient and quicker than swapping memory to a hard drive.

On Ubuntu, you can install the module with sudo apt install zram-config and then reboot your computer. The package installs a script to run it as a service and doesn’t require any configurat­ion. Use the cat /proc/ swaps command to check if it’s online. If ZRAM is working perfectly, the command should list one or more /dev/zram partitions. If you find that your processor is unable to cope with the added load and your computer’s usability has taken a hit as a result, you can disable and remove the ZRAM module with sudo apt autoremove zram-config .

Speed governors

To understand this next section, you need to know a little bit about Linux internals – but don’t worry, it isn’t really all that technical.

The kernel uses Process Schedulers and I/O Schedulers. Process schedulers help manage how the kernel switches between different computatio­nal tasks. Kernel hacker Con Kolivas’ work on fair scheduling led to Ingo Mólnar’s Completely Fair Scheduler (CFS), which is the default scheduler on most Linux distros. Kolivas is involved with several other kernel-level enhancemen­ts including the Brain F**k Scheduler (BFS) and the Multiple Queue Skiplist Scheduler (MUQSS).

Then there are I/O Schedulers. Two of the most popular I/O schedulers are the Completely Fair Queueing (CFQ) and the Budget Fair Queueing (BFQ) schedulers. On systems with mechanical hard drives, you should use BFQ and CFQ, these help minimise I/O interactio­ns. SSDS, meanwhile, are better at handling I/O operations and you can avoid wasting computatio­nal resources on them using the NOOP scheduler. You can check which I/O Scheduler you’re running with cat /sys/block/sda/queue/scheduler .

To take advantage of the new schedulers for a smoother desktop experience, you’ll get better mileage with the Liquorix kernel. It includes the MUQSS scheduler instead of CFS, and BFQ instead of CFQ, and also includes quite a few other tweaks to make your installati­on more responsive. The kernel is available via a PPA that you can install with: sudo add-apt-repository ppa:damentz/liquorix sudo apt-get update

After adding the PPA, install the kernel with: sudo apt install linux-image-liquorix-amd64 linuxheade­rs-liquorix-amd64 Besides the Liquorix kernel, there are several performanc­e-optimised kernel patches available. Con Koliva has compiled several of these patches into the -ck kernel patch that you can use to compile your own performanc­e-enhanced kernel. After you’ve installed it, you’ll notice performanc­e improvemen­ts in everyday desktop tasks, as well as while playing games and producing multimedia.

To install the -ck kernel patch, use your distro’s package manager to first download the kernel source for the version the patch applies to, along with all the tools for building your kernel. Then download the patch from Koliva’s website (www.users.on.net/~%20ckolivas/ kernel) and use the patch command in the kernel source folder to apply the changes, such as: sudo patch -p1 < patch-5.*-ck1

Now proceed to build the kernel according to your distributi­on’s instructio­ns. If you don’t know what that means, you can safely ignore this section!

 ??  ?? You can use the systemd bootmap to see the order in which services start and the time they spent initialisi­ng.
You can use the systemd bootmap to see the order in which services start and the time they spent initialisi­ng.
 ??  ?? Instead of top, use the htop utility, which can easily sort processes by various useful parameters.
Instead of top, use the htop utility, which can easily sort processes by various useful parameters.
 ??  ?? Preload won’t be of much use if you launch an app and continue using it instead of loading different apps and libraries.
Preload won’t be of much use if you launch an app and continue using it instead of loading different apps and libraries.

Newspapers in English

Newspapers from Australia