Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Setting "read_ahead_kb"
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
snake111
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2004
Posts: 117

PostPosted: Mon Aug 22, 2011 8:36 pm    Post subject: Setting "read_ahead_kb" Reply with quote

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
View user's profile Send private message
snake111
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2004
Posts: 117

PostPosted: Sat Aug 27, 2011 1:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
ryszardzonk
Apprentice
Apprentice


Joined: 18 Dec 2003
Posts: 225
Location: Rzeszów, POLAND

PostPosted: Sun Aug 28, 2011 7:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
snake111
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2004
Posts: 117

PostPosted: Sun Aug 28, 2011 9:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
ryszardzonk
Apprentice
Apprentice


Joined: 18 Dec 2003
Posts: 225
Location: Rzeszów, POLAND

PostPosted: Tue Aug 30, 2011 4:24 am    Post subject: Reply with quote

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
View user's profile Send private message
snake111
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2004
Posts: 117

PostPosted: Tue Aug 30, 2011 2:43 pm    Post subject: Reply with quote

Thanks for the support, nice done, a lot better then mine :wink:

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
View user's profile Send private message
jmartos
Tux's lil' helper
Tux's lil' helper


Joined: 23 Mar 2008
Posts: 76

PostPosted: Sun Sep 11, 2011 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
snake111
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2004
Posts: 117

PostPosted: Sun Jan 01, 2012 1:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
kernelOfTruth
Watchman
Watchman


Joined: 20 Dec 2005
Posts: 6111
Location: Vienna, Austria; Germany; hello world :)

PostPosted: Thu Nov 03, 2016 10:42 pm    Post subject: Reply with quote

http://wiki.osnexus.com/index.php?title=IO_Performance_Tuning#Storage_Pool_IO_Tuning_Overview

Quote:
With SSD, there are no mechanical rotational latency issues so the SSD profile uses a small 4k read-ahead.


makes sense
_________________
https://github.com/kernelOfTruth/ZFS-for-SystemRescueCD/tree/ZFS-for-SysRescCD-4.9.0
https://github.com/kernelOfTruth/pulseaudio-equalizer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3935
Location: Rasi, Finland

PostPosted: Fri Nov 04, 2016 2:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
kernelOfTruth
Watchman
Watchman


Joined: 20 Dec 2005
Posts: 6111
Location: Vienna, Austria; Germany; hello world :)

PostPosted: Fri Nov 04, 2016 2:30 pm    Post subject: Reply with quote

That sounds like a rather "exotic" setup, especially with hibernation + raid5,

but why not give it a try ?


It sounds like it could benefit, especially since (assuming it's linear reading) it's an continuous image


Better have a recent backup of your data though :)
_________________
https://github.com/kernelOfTruth/ZFS-for-SystemRescueCD/tree/ZFS-for-SysRescCD-4.9.0
https://github.com/kernelOfTruth/pulseaudio-equalizer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3935
Location: Rasi, Finland

PostPosted: Fri Nov 04, 2016 7:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum