User avatar
RobinJ
Posts: 68
Joined: Mon Aug 08, 2011 4:21 pm
Location: Belgium
Contact: Website

I/O terribly slow

Wed Nov 07, 2012 3:04 pm

I'm running a few things on my Raspberry Pi, and one of them is an IRC bot. I have noticed that most of the times when the script has to read/write -- not every time, though -- from/to the SD card, the script will just hang for 10 to 20 seconds, before it even begins reading/writing. I have noticed the same when running commands. Sometimes it just works, and other times I have to wait 10 seconds for it to start running the command (ls or pacman for example).
I'm running Arch Linux on a 16 GB class 4 SD card.

Read-only benchmark:
[[email protected] ~]$ sudo hdparm -Tt /dev/mmcblk0

/dev/mmcblk0:
Timing cached reads: 304 MB in 2.01 seconds = 151.59 MB/sec
Timing buffered disk reads: 44 MB in 3.10 seconds = 14.21 MB/sec
Load averages:
[[email protected] ~]$ uptime
15:03:05 up 5 days, 17:01, 2 users, load average: 1.59, 2.19, 2.01
The average CPU usage is 4%, while the average RAM usage is 32MB so I figured it really can't be anything else than the I/O. The problem is mainly noticable when a script needs to run a simple INSERT query into an SQLite database. The script will simply hang for 20 seconds until the query completes, and then continue as if nothing special has happened.
Rule #1: If a human tries to argue with a logical device like a computer, the device always wins.
Rule #2: A big bucket of water, window, or hammer can nullify Rule #1.

User avatar
RobinJ
Posts: 68
Joined: Mon Aug 08, 2011 4:21 pm
Location: Belgium
Contact: Website

Re: I/O terribly slow

Fri Nov 09, 2012 10:57 pm

... Nobody? :cry:
Rule #1: If a human tries to argue with a logical device like a computer, the device always wins.
Rule #2: A big bucket of water, window, or hammer can nullify Rule #1.

Patros
Posts: 4
Joined: Fri Aug 17, 2012 4:57 am

Re: I/O terribly slow

Mon Nov 12, 2012 3:25 am

RobinJ wrote:The average CPU usage is 4%, while the average RAM usage is 32MB so I figured it really can't be anything else than the I/O. The problem is mainly noticable when a script needs to run a simple INSERT query into an SQLite database. The script will simply hang for 20 seconds until the query completes, and then continue as if nothing special has happened.
Sounds like the SQLite database is waiting for changes to be flushed to disk before continuing. SQLite has a very robust procedure in place to ensure the database state can survive power failures, etc. Unfortunately it can also make inserts really slow. You can disable this feature of SQLite on a per connection basis. What IRC bot are you running?

The other thing worth looking at would be to get a class 10 sd card which will perform much faster for writes. Minimum rated speed for writes of 10Mb/s versus 4Mb/s.

Wendo
Posts: 142
Joined: Sun Jun 10, 2012 8:27 pm

Re: I/O terribly slow

Mon Nov 12, 2012 7:00 am

Class 4's traditionally have better random I/O patterns though, as there is a minimum specified in the class 4 spec, but none specified in the class 10 spec

User avatar
RobinJ
Posts: 68
Joined: Mon Aug 08, 2011 4:21 pm
Location: Belgium
Contact: Website

Re: I/O terribly slow

Mon Nov 12, 2012 6:59 pm

Patros wrote:
RobinJ wrote:The average CPU usage is 4%, while the average RAM usage is 32MB so I figured it really can't be anything else than the I/O. The problem is mainly noticable when a script needs to run a simple INSERT query into an SQLite database. The script will simply hang for 20 seconds until the query completes, and then continue as if nothing special has happened.
Sounds like the SQLite database is waiting for changes to be flushed to disk before continuing. SQLite has a very robust procedure in place to ensure the database state can survive power failures, etc. Unfortunately it can also make inserts really slow. You can disable this feature of SQLite on a per connection basis. What IRC bot are you running?
Written from scratch. I don't use someone else's code for something I can do better myself :p
Wendo wrote:Class 4's traditionally have better random I/O patterns though, as there is a minimum specified in the class 4 spec, but none specified in the class 10 spec
That's what I thought...

--
My SD card died a few days ago. I put a small microSD into a microSD-SD adapter, and it worked fine all of a sudden.
<RobinJ> !uptime
<RaspberryDroid> 18:59:07 up 1 day, 20:34, 0 users, load average: 0.00, 0.01, 0.05
These load averages look a lot better, don't they? Appart from the SD card, the only difference is that I'm running Raspbian now in stead of Arch Linux (I couldn't be bothered doing the whole Arch setup again, while Debian is so much easier).
Rule #1: If a human tries to argue with a logical device like a computer, the device always wins.
Rule #2: A big bucket of water, window, or hammer can nullify Rule #1.

Return to “Troubleshooting”