0

I have a 10 year old HP laptop. Despite a fresh install of 22.04 LTS, it takes minutes to boot before I can log-in, Firefox takes minutes before I can type (I can see pages, but can't use the browser), and some sites e.g. Facebook, run really slow. I've also tried in Chromium.

Here's the spec from Settings -> About

laptop spec

I'm wondering if the laptop is just too old a variety to deal with the way some things are done these days?

Or maybe there are some things I can do to improve this?

Following suggestion of @user535733, output of free -h when system running ok:

free -h ok

output of free -h when running poorly straight after reboot:

free-h when system running poorly

Following suggestion of @user-whose-name-i-can't-see-when editing, output of `top as soon as I can open a terminal after logging in (about 30 seconds after login, 2.5 minutes after powering up the machine):

top output

And output of topafter waiting for machine to calm down, then opening Firefox:

top output

So, yeah, there seems to be alot of waiting for the disk ...

  • Firefox loads a lot of files on startup unless you clear browsing data. The slow boot before login is also from this. Try uninstalling or disabling systemd services that start on boot. Also defragment the disk to reduce file access times : https://askubuntu.com/q/221079/1004020 – Daniel T Feb 11 '24 at 11:15
  • this looks like a hardware problem you will not fix with software, Get an SSD? that will increase oveall perfomance. – Rinzwind Feb 11 '24 at 11:24
  • Open a terminal. Run free -h when your system is running fast. Run it again when your system is running slow. Add both sets of output to your question above. – user535733 Feb 11 '24 at 13:02
  • 1
    As expected, your system runs OK when the buff/cache number is high. When the buff/cache is low and not yet loaded, your system is slow. This is caused by slow disk access. Either buy a SSD as suggested by Rinzwind, defrag, or try to emulate what ureadahead used to do by moving files to the start of the disk – Daniel T Feb 11 '24 at 13:19
  • I can't see much diff myself (but aren't too sure what I'm looking at). But yes. I take the points about SSD, I shall investigate; thank you all for your help :) – minisaurus Feb 11 '24 at 13:28
  • I just noticed - the disk capacity in the "Settings -> About" output is wrong - it says 750 GB; but the disk is actually 500 GB (some of which is Windows); could that play a part in this? – minisaurus Feb 11 '24 at 13:37
  • @graham, not really, my machine appears to meet the minimum requirements for Ubuntu 22.04 – minisaurus Feb 11 '24 at 17:41
  • Does this answer your question? How to defrag an ext4 filesystem – Daniel T Feb 11 '24 at 18:06
  • @DanielT - the os installation is fresh so shouldn't be fragmented yet maybe? I ran e4defrag on my ~ home directory and got the "does not need defragmentation" message. I guess you mean I should do it on / maybe? – minisaurus Feb 11 '24 at 19:26
  • Yes, you should do it on / to see if that fixes boot and login lag, as those will read a lot of files from /usr. If your home directory doesn't need it, then I don't know how to improve Firefox startup lag except deleting history. – Daniel T Feb 11 '24 at 20:30

1 Answers1

2

A good starting point is to monitor what the system is doing while it's slow. For example, is the problem due to high CPU load, slow disk access, other unexpected processes, etc.

Try running 'top' from a Term window. This will show the "top" processes (those taking up the most CPU) along with various system statistics. For example :

top - 15:42:30 up 8 min,  1 user,  load average: 2.53, 2.47, 1.48
Tasks: 371 total,   3 running, 367 sleeping,   0 stopped,   1 zombie
%Cpu(s):  1.6 us,  0.8 sy, 16.5 ni, 79.2 id,  0.2 wa,  0.0 hi,  1.8 si,  0.0 st
MiB Mem :  63634.2 total,  50837.3 free,   8354.5 used,   4442.5 buff/cache
MiB Swap:  15625.0 total,  15625.0 free,      0.0 used.  54229.4 avail Mem
PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND  

4845 boinc 39 19 78420 37620 2048 R 99.3 0.1 7:58.23 wcgrid_+ 4846 boinc 39 19 78260 37564 2048 R 99.3 0.1 7:58.26 wcgrid_+ 2180 rich 20 0 5358744 565044 394320 S 13.3 0.9 0:27.14 gnome-s+ 2987 rich 20 0 12.3g 1.0g 487620 S 6.0 1.6 2:04.64 firefox
4366 rich 20 0 2857076 276612 115116 S 5.0 0.4 0:33.28 Isolate+ 3410 rich 20 0 2687148 235732 108324 S 2.3 0.4 0:18.82 Isolate+ 2649 rich 20 0 25008 14720 7040 S 1.7 0.0 0:08.54 python3
3362 rich 20 0 10.7g 297136 95552 S 1.7 0.5 0:08.85 WebExte+ 1170 root 20 0 263824 19328 16512 S 1.3 0.0 0:05.81 openrgb
6165 rich 20 0 274116 98404 52096 S 1.3 0.2 0:07.33 MainThr+ 2009 rich 9 -11 1910216 31944 22600 S 1.0 0.0 0:03.63 pulseau+

The "load average" effectively shows "how many CPUs are fully busy" with the 3 values showing over the 'short-term', 'medium-term' and 'long-term'.

The Cpu(s) line shows what the current workload is. High 'us' is "usertime" - ie, your processes. High 'sy' is "systemtime" (the operating system). 'id' is the idle time (how much the spare CPU capacity is and 'wa' is "waiting for I/O".

If you have high "wa" then it's likely that you either have a slow disk (consider replacing it with an SSD) or you have some process that's doing lots of disk activity.

There are a lot of other features in 'top' to allow you to drill into different aspects. Press 'h' for help. Press 'q' to quit.

Find the things that are taking up most of the time and this might give you some clues as to what you can tweak or improve to give you better performance.

For a Linux system that you're just using for web browsing I'd say a 10-year-old 6Gb-memory quad-core system should be fine (much less overhead from the O/S than your typical Windows installation!).


EDIT : You have high "waiting for IO" and this could either be a symptom of a problem with your disk (eg, bad sectors) causing each disk access to be slow (eg, due to repeated retries) or could be due to processes performing lots of disk operations.

For the disk operations, run 'sudo iotop'. This is similar to the 'top' command but concentrates on the Input/Output operations rather than processes. Hit 'a' to show 'accumulated' operations if that helps (rather than it refreshing each second). If this shows a particular process that you aren't expecting to performing lots of operations then that could be a likely issue.

If the issue is a problem with the drive itself then you might see some messages in /var/log/syslog. To see this try 'sudo tail -1000 /var/log/syslog|more' and page through, looking for messages that indicate a problem with reads/writes on the device (eg, /dev/sda1, etc.).

I don't have enough reputation to comment but I wouldn't try defragging the ext4 partition. Ext4 is pretty good at keeping itself efficient and since it's a fresh install there will be very little fragmentation. However, if there is a disk problem the defragging is likely to cause more issues (since it will be attempting to move sectors to/from bad sectors). In my experience, you generally never need to defrag ext4.

Also, buff/cache isn't a problem and just shows the amount of memory that is used to store data that has previously been read from (or written to) disk. As you aren't using any swap space there is no problem with buffers or cache and it's doing just what it's supposed to (storing things in memory in case they're needed again). Generally you want as much as possible buffered/cached as that means the system doesn't need to access the disk.

Another thing worth looking at (if you have multiple disk devices) is 'sar -d 5'. This will output the disk access statistics every 5 seconds (change the interval if you need to), showing which devices are actually being accessed. If, for example, you're seeing activity on a slow USB drive it could point to a cause.

  • Thanks @Rich Sedman, I've updated my question to show some top outputs – minisaurus Feb 11 '24 at 17:38
  • Thanks again @Rich Sedman, I’ll have a look at that both those things and report back. Other matters in life have unfortunately pressed in on my free time just now :) – minisaurus Feb 16 '24 at 09:38