View previous topic :: View next topic |
Author |
Message |
snake111 Tux's lil' helper
Joined: 18 Dec 2004 Posts: 117
|
Posted: Mon Aug 22, 2011 8:36 pm Post subject: Setting "read_ahead_kb" |
|
|
Hi all, I'd like to have a custom value for "read_ahead_kb" in order to improve read performance on my SSD.
I wrote this script and put it in /etc/local.d/
Code: |
#!/bin/sh
echo 2048 > /sys/block/sda/queue/read_ahead_kb
|
The new value is set correctly when I log in via shell, but as soon as I start X + gnome something reset it to 128!
Is there any other way to set this value permanently, or to re-set while gnome is up?
Thanks! |
|
Back to top |
|
|
snake111 Tux's lil' helper
Joined: 18 Dec 2004 Posts: 117
|
Posted: Sat Aug 27, 2011 1:58 pm Post subject: |
|
|
That's weird... created a script:
Code: |
#!/bin/sh
/bin/echo 2048 > /sys/block/sda/queue/read_ahead_kb
touch ~/aaa
|
saved as /usr/local/bin/read_ahead.sh
added the command to sudoers, so if I do:
Code: |
$ sudo /usr/local/bin/read_ahead.sh
|
the value in /sys/block/sda/queue/read_ahead_kb is correctly updated to 2048, and in /root a file called 'aaa' appears. So far so good.
In gnome I created an entry for sudo /usr/local/bin/read_ahead.sh in System -> Preferences -> Startup Applications, at next reboot I will correctly find a newly created file /root/aaa but read_ahead_kb is still at 128!!
I just can't understand why is not working, maybe there's something that change it again after my script runs? Any idea?
thanks |
|
Back to top |
|
|
ryszardzonk Apprentice
Joined: 18 Dec 2003 Posts: 225 Location: Rzeszów, POLAND
|
Posted: Sun Aug 28, 2011 7:31 pm Post subject: |
|
|
try placing that script into /etc/local.d directory
ps do You have any benchmark showing that setting helps performance? _________________ Sky is not the limit... |
|
Back to top |
|
|
snake111 Tux's lil' helper
Joined: 18 Dec 2004 Posts: 117
|
Posted: Sun Aug 28, 2011 9:15 pm Post subject: |
|
|
ryszardzonk wrote: | try placing that script into /etc/local.d directory
ps do You have any benchmark showing that setting helps performance? |
Thanks for reply. Placing a script in /etc/local.d was my first try, but works fine only if you don't start X + gnone, which reset back the value to 128.
That's my local.d:
Code: |
# cat /etc/local.d/10-read_ahead.start
#!/bin/sh
echo 2048 > /sys/block/sda/queue/read_ahead_kb
|
FYI that's the benchmark I run to choose the value:
Code: |
# for V in 128 256 512 1024 2048 4096 8192 16384; do echo $V; echo $V > /sys/block/sda/queue/read_ahead_kb && hdparm -t /dev/sda | grep "Timing"; done
128
Timing buffered disk reads: 1022 MB in 3.00 seconds = 340.13 MB/sec
256
Timing buffered disk reads: 1226 MB in 3.00 seconds = 408.58 MB/sec
512
Timing buffered disk reads: 1484 MB in 3.00 seconds = 494.38 MB/sec
1024
Timing buffered disk reads: 1536 MB in 3.00 seconds = 511.64 MB/sec
2048
Timing buffered disk reads: 1564 MB in 3.00 seconds = 520.76 MB/sec
4096
Timing buffered disk reads: 1578 MB in 3.00 seconds = 525.63 MB/sec
8192
Timing buffered disk reads: 1584 MB in 3.00 seconds = 527.57 MB/sec
16384
Timing buffered disk reads: 1586 MB in 3.00 seconds = 528.02 MB/sec
|
|
|
Back to top |
|
|
ryszardzonk Apprentice
Joined: 18 Dec 2003 Posts: 225 Location: Rzeszów, POLAND
|
Posted: Tue Aug 30, 2011 4:24 am Post subject: |
|
|
Results look promissing therefore I have made following script to get that running after X, but it turns out that it does not help either as when I login into Gnome Session it brings value back to 128...
/etc/init.d/ssd_drive-readahead
Code: | #!/sbin/runscript
description="Increase readahead on SSD drive"
depend()
{
need localmount
after xdm
}
start()
{
ebegin "Increasing readahead on SSD drive"
echo 512 > /sys/block/sda/queue/read_ahead_kb
eend $? "Failed to increase readahead on SSD drives"
}
stop()
{
ebegin "Decreasing readahead on SSD drive"
echo 128 > /sys/block/sda/queue/read_ahead_kb
eend $? "Failed to decrease readahead on SSD drive"
} |
_________________ Sky is not the limit... |
|
Back to top |
|
|
snake111 Tux's lil' helper
Joined: 18 Dec 2004 Posts: 117
|
Posted: Tue Aug 30, 2011 2:43 pm Post subject: |
|
|
Thanks for the support, nice done, a lot better then mine
I was tying to understand who/what is overwriting the file using sys-process/audit-2.0.5 but seems broken on my kernel (3.0.3).
Do you have any suggestion on how to log who's writing? |
|
Back to top |
|
|
jmartos Tux's lil' helper
Joined: 23 Mar 2008 Posts: 76
|
Posted: Sun Sep 11, 2011 3:21 pm Post subject: |
|
|
If you have pm-utils running then that could be what is changing your settings. Try changing the entry
Code: | DRIVE_READAHEAD_AC=${DRIVE_READAHEAD_AC:-1024} |
in /usr/lib64/pm-utils/power.d/readahead to what value you need. Mine is set to 1024. |
|
Back to top |
|
|
snake111 Tux's lil' helper
Joined: 18 Dec 2004 Posts: 117
|
Posted: Sun Jan 01, 2012 1:31 pm Post subject: |
|
|
Thanks, seen this only now. Don't seems to be related to pm-utils, I don't think it's running and in conf file the stardard value is 256.
So I think if pm-utils would change the value, should be set to 256 and not 128. |
|
Back to top |
|
|
kernelOfTruth Watchman
Joined: 20 Dec 2005 Posts: 6111 Location: Vienna, Austria; Germany; hello world :)
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3935 Location: Rasi, Finland
|
Posted: Fri Nov 04, 2016 2:03 pm Post subject: |
|
|
I wonder if this would affect the speed of hibernate image loading...
I have rather complex setup where I have put my hibernation swap on raid5 array (because Linux cannot read hibernate image from multiple swap partitions).
Of course I'd need to set the read_ahead in initramfs before loading the hibernation image...
I'm already getting bit over 400MB/s, so I wonder if it's worth it. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
kernelOfTruth Watchman
Joined: 20 Dec 2005 Posts: 6111 Location: Vienna, Austria; Germany; hello world :)
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3935 Location: Rasi, Finland
|
Posted: Fri Nov 04, 2016 7:01 pm Post subject: |
|
|
kernelOfTruth wrote: | Better have a recent backup of your data though | Only swap is on raid5. Rest are on btrfs "raid1" except /boot on (md)raid1. And on top of that backups are on my server. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
|