19

I did

echo 8192 > /sys/block/md0/md/stripe_cache_size

to improve my RAID performance, and it did helped alot.

But I still can't figure out how to make it permanent.

I was trying to set it in /etc/rc.local - other commands are executed, but it was overwritten to 256 elsewhere... Any hints?

Jorge Castro
  • 73,717

9 Answers9

20

Add a udev rule, e.g. to /etc/udev/rules.d/60-md-stripe-cache.rules:

SUBSYSTEM=="block", KERNEL=="md*", ACTION=="change", TEST=="md/stripe_cache_size", ATTR{md/stripe_cache_size}="8192"

I haven't actually tried this so it might not be 100% right (may be some typos), but it should be close. Check man udev to understand more.

You may also want to run the following commands afterwards to immediately apply the new rule:

udevadm trigger
udevadm control --reload-rules
David Foerster
  • 36,890
  • 56
  • 97
  • 151
NeilBrown
  • 316
1

Increasing stripe_cache_size doesn't make sense for all RAID levels. E.g. on RAID0 or RAID1. If you have RAID5 or RAID6 check the current value:

   $ cat /sys/block/md1/md/stripe_cache_size
   256

In order to make the change permanent, create a config file, e.g. /etc/udev/rules.d/50-mdadm.rules:

SUBSYSTEM=="block", KERNEL=="md*", ACTION=="change", TEST=="md/stripe_cache_size", ATTR{md/stripe_cache_size}="4096"

And reload changes afterwards:

udevadm control --reload-rules && udevadm trigger

Also check stripe_size, this can be modified only when creating an array.

$ cat /sys/block/md1/md/stripe_size 
4096

Note that changing cache size from 256 to 8192 is rather big change. The maximum value is 327696, however in most cases you don't more than 4096.

stripe_cache_size equal to 256:

  • 3 disks: 3*256*4096 = 3 MiB RAM
  • 5 disks: 5*256*4096 = 5 MiB RAM

stripe_cache_size equal to 8192:

  • 3 disks: 3*8192*4096 = 96 MiB RAM
  • 5 disks: 5*8192*4096 = 160 MiB RAM

stripe_cache_size equal to 327696:

  • 3 disks: 3*327696*4096 = 384 MiB RAM
  • 5 disks: 5*327696*4096 = 640 MiB RAM

Depending on your workload, too many simultaneous requests can easily eat all you RAM. This article explains choosing optimal strip size.

Tombart
  • 999
1

Just to expand on the last post; the script underneath works for me. Just swap your details between the "<...>". Enjoy!


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#################NOTE######################
##  You are limited by CPU and memory too #
##  <Your Name> <Date of Modification>    #
##  stripe cache size and read-ahead      #
###########################################
echo 16384 > /sys/block/<Your RAID5 or 6 Volume>/md/stripe_cache_size
blockdev --setra 16384 /dev/<Your RAID5 or 6 Volume>

exit 0
0

Would the sysfsutils package help fix your problem?

ORIGINAL ANSWER:

I can't figure out how to comment on your question; I guess I'll edit this answer as I learn more about your problem.

Can you post (or pastebin, if it's long) the output of

grep -R md0 /etc/init.d
zpletan
  • 3,443
0

I am also trying to figure this out. I put mine in rc.local and no luck. I start it up manually after logging in. I suppose you could write a script to handle this and put it in your "Startup Applictions" but that doesn't help at all if you're not logged in to gnome.

0

I don't have a real answer for you, but maybe you could try creating a simple upstart startup script. Create a file in /etc/init with the .conf extension. In the file put:

start on started tty1

exec echo 8192 > /sys/block/md0/md/stripe_cache_size

My thinking is that that should run the command around the time that the terminal has started, which is probably around the same time you are running the command.

user1974
  • 765
0

Total shot in the dark as I don't have a RAID 5 setup to test with: Maybe add a line with

chmod -w /sys/block/md0/md/stripe_cache_size

in rc.local to remove the write permissions after it's set. Maybe that will stop it from getting changed elsewhere?

Ramón
  • 1,647
0

Append

echo 8192 > /sys/block/mdX/md/stripe_cache_size

to /etc/rc.local.

Kris Harper
  • 13,705
-1

This page suggests that stripe size (or width) should have been set up when the fs was set up. Maybe tunefs could help here?

TGM
  • 602