20

I have a low profile machine but with a lot of fast RAM, 4 Gb, which is really an amount of memory that i probably will never use, not even an half, since i just use this machine for coding and browsing the web.

The HDD is really slow and so the overall performance are bad when booting, caching or starting new program, I'm wondering if Ubuntu can provide some setting or utility to solve this situation and let my system rely more on the RAM usage.

3
  • 1
    Free RAM should already be used for caching, which is the default behavior. However, data still must be read from the relatively slow hdd first, and the only way to speed that up is to use a faster one or an ssd. Sorry, no magic today. PS: Ubuntu uses ureadahead to profile the boot process and make it as fast as possible. Oct 10, 2012 at 15:00
  • 2
    Also, 4GB is not much on a modern machine. Modern web sites are full of complex javascript and have a lot of data on them, which can cause the web browser to consume memory rather quickly. I have many times seen just Firefox approaching multiple GB of resident memory usage.
    – dobey
    Oct 10, 2012 at 15:24
  • @dobey in my experience javascript requires more CPU than RAM. Oct 10, 2012 at 15:25

4 Answers 4

13

You should install Preload which will preload the software you use the most in your RAM (it'll learn which software to preload on its own). That's very easy to setup:

sudo apt-get install preload

You probably don't need to touch it, but if you want you can edit the options in /etc/preload.conf

5
  • i also noticed the existance of this prelink utility, i will try this, thanks. Oct 10, 2012 at 15:01
  • 2
    @user1717079 - Keep in mind that Preload will not speed up your boot times, and most caching should already be done in RAM.
    – Shauna
    Oct 10, 2012 at 15:05
  • 1
    Preload will not speed up neither the boot nor the caching processes, because they depend heavily on the speed of the hdd. Oct 10, 2012 at 15:34
  • while we're on the subject of prelink, prelinking doesn't give any noticeable performance boost, see smackerelofopinion.blogspot.co.uk/2009/06/… Oct 10, 2012 at 17:05
  • @ColinIanKing i will be happy if only it could give me a small edge in terms of performance, boot times are not that bad, the problem is that is usually laggish or it takes just too much time to load a new program. I'm going to use preload and prelink for some days, let's see if things will change Oct 10, 2012 at 19:58
11

You can add the following line to /etc/fstab to mount your /tmp directory into the RAM.

tmpfs   /tmp       tmpfs   defaults,noatime,nodiratime,mode=1777   0  0

This can be done with other directories, too. E.g. when you are compiling your code you can put the folder where the object files are placed and linked into RAM.

But pay attention. Data in folders that are mounted this way will be lost on any case of shutdown. Keep that in mind.

Besides from my knowledge there are many other helpful ressources available on this topic. For example this thread.

2
  • thank you but a ramdisk is a slighlty different thing, but i appreciate your hint because it will be useful later on. My big problem right now is how run my applications faster, not how to make my filesytem faster. Oct 10, 2012 at 15:01
  • Yes but I found it worth mentioning because you have 4GB of RAM and using RAM folders would improve your browsing experience if you tell firefox to use them for cache and stuff.
    – cauon
    Oct 10, 2012 at 15:06
6

What is RAM?

RAM, or random access memory, is a type of storage system known as volatile storage. That is, it only holds data while it has power. In other words, any changes you make to it, if you don't write it to a persistent storage device, will be lost at any time the RAM loses power.

What is a hard drive?

Hard drives, or disk drives (or hard disk drives), are a different type of storage system known as persistent storage. This means that the data stays even when deprived of power. CDs, DVDs, floppy disks, and USB thumb drives also fall under this category.

What happens when I boot, write to cache, or start new programs?

In order to maintain your system between reboots, the OS has to write what it has in the RAM into a persistent storage device, usually the primary hard drive. Conversely, in order to restore that information, or to start applications, it has to load that data into the RAM from the storage device. This even happens with live CDs, even though everything is running in memory, it has to first read everything from the CD (or USB drive). It also happens even with the tools/ideas cauon and Ugo have suggested, because at some point or another, data has to be read from or written to a disk in order to persist between boots (specifically Preload will not improve boot time).

If you have fast RAM, then your bottleneck will be somewhere in the read from/write to disk process, usually either in the speed of the data connection or the speed of the drive.

What can I do to improve the speed of these operations?

To improve the speed of all three of your mentioned operations, you'll need to do some hardware upgrading.

Get a faster connection. Parallel ATA connections (PATA, the gray ribbon in older machines) is going to be slower than SATA connections (Serial ATA, the newer, smaller cables). If you can and haven't already, upgrade to a SATA drive. If you go the USB drive route (outlined below), then make sure you're using a USB 2.0 (or, even better, speed-wise, 3.0) drive and port. USB devices and ports will clock down to the speed of the slower thing, so even if you have a 3.0 port, if the device it 2.0, you will only get 2.0 speeds.

Get a faster storage device. Platter-based hard drives are measured in RPMs, and generally come in three speeds - 5400 rpm, 7200 rpm, and 10k rpm. If you have a 5400 rpm drive, upgrade to at least a 7200. Additionally, Solid State drives (including USB thumb drives) are faster than platter-based drives. If you can afford it, upgrade to a solid state drive. Alternatively, you can install Ubuntu on a USB drive and run it from there (keep in mind, though, that such a set up will be limited to the speed of your USB port, so make sure you use at least a USB 2.0 port and drive).

1

try zram (once called compcache), it is a compressed swap in the memory!

the package for ubuntu 12.10 is zram-config, no need to boot.

swapon -s will show something like:

Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       1023860 0       -1
/dev/sdc4                               partition       976892  0       -2
/dev/zram0                              partition       761876  0       5
/dev/zram1                              partition       761876  0       5
/dev/zram2                              partition       761876  0       5
/dev/zram3                              partition       761876  0       5

I have 6GB ram and 4 core cpu, so one swap for each core using half in a total, of the ram! (for a good reason)

Read what ppl is saying about compcache and zram!

well, if non zram are being used, boot or try to, IYKWYAD (if you know what you are doing), swapoff them, to see zram ones be filled and improve overall performace.

1
  • btw, my current setup has each of my zram swaps (for each core) with 250MB, so a total of 1GB for 4 cores. I found it to work better than allowing zram to use half (3GB) of my total memory, I think it is because it will swap less to the hard drives/ssd if I allow some memory hungry applications to use more of the real memory. I also close many other memory hungry apps that are not really needed to be running all the time. Feb 21, 2017 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .