On Monday 18 October 2010 21:51:25 Luigi Rizzo wrote:
> On Mon, Oct 18, 2010 at 09:43:28AM +0200, David Naylor wrote:
> > Hi,
> > 
> > I've used geom_sched to some success.  Normally I do not notice anything
> > but today I was copying big files over a gigabit ethernet and my laptop
> > was not very responsive.  I loaded gsched and the responsiveness
> > improved (although still rather bad for anything requiring something
> > from the HDD).
> > 
> > Thank you for all this work :-)
> > 
> > Some questions I have:
> >  - with a gmirror should the gsched be attached to the underlying devices
> >  (aka
> > 
> > /dev/ad?) or to the mirror device (aka /dev/mirror/?)?
> 
> always attach as close as possible to the hardware.

Thanks.  

> >  - is there anyway to automatically attach gsched to a device on startup
> >  (i.e.
> > 
> > in rc.conf)?
> 
> no, you have to build some script yourself.

Would there be any interest in having a rc.d/ script?  I would find it 
conveniant to specify a single rc.conf line and get scheduling for all my 
devices.  PC-BSD might find such functionality useful.  

See attached for my first draft at such a script, I'm willing to hash it into 
shape.  

> >  - is there a way to prioritise random IO (vs sequential reads from big
> > 
> > files)?
> 
> no way to do that, but you can modify the quantum size and time to
> let sequential reads get shorter chunks
> 
> kern.geom.sched.rr.quantum_kb: 8192
> kern.geom.sched.rr.quantum_ms: 100
> kern.geom.sched.rr.wait_ms: 10
> 
> e.g. on a laptop it might make sense to set
> quantum_ms=50 and quantum_kb=2048

Is there a manual page that describes these sysctls?  It looks like, in my 
case, scp just hogs resources.  

I do perceive some improvements in normal usage.  Thanks

> >  - gsched_as does not appear to be installed.
> 
> true, gsched_as was just a proof of concept and gsched_rr
> includes anticipation and round robin, so it is a superset of gsched_as

Thanks for clarity.

Regards,

David
#!/bin/sh
#
# $FreeBSD$
#
# Specify gsched_enable="YES" in /etc/rc.conf(.local) to activate scheduling on
# storage devices.  
# 
# gsched_devs is a space separated list of accepted devices.  If empty all
# storage devices are used
#
# gsched_$dev specifies the sheduling algorithm to use (e.g. `rr')

# TODO:
# - add gsched profiles, such as `desktop' for kern.geom.sched.rr tunables

# PROVIDE: gsched
# KEYWORD: nojail

. /etc/rc.subr

gsched_enable=${gsched_enable:-NO}

name="gsched"
rcvar=`set_rcvar`
command="/sbin/${name}"
start_cmd="gsched_start"
stop_cmd="gsched_stop"

gsched_start_dev()
{
        local _gsched_dev _gsched_profile _gsched_args

        _gsched_dev=$1

        # Check if sched algo was specified
        #
        eval _gsched_profile=\$gsched_${_gsched_dev}
        if [ -n "${_gsched_profile}" ]; then
                _gsched_args="-a ${_gsched_profile}"
        fi
        
        # Start gsched for ${_gsched_dev}
        ${command} insert ${_gsched_args} ${_gsched_dev}

}

gsched_all_devs()
{
        local _dev
        # Only supports upto 100 devices per device class
        # XXX: what other storage devices are there?
        for _dev in `cd /dev; echo *`; do
                case ${_dev} in
                        ad[0-9]|ad[0-9][0-9])
                                echo ${_dev}
                                ;;
                        ada[0-9]|ada[0-9][0-9])
                                echo ${_dev}
                                ;;
                        da[0-9]|da[0-9][0-9])
                                echo ${_dev}
                                ;;
                esac
        done
}

gsched_start()
{
        local _gsched_devs _g _gsched_devs_recon

        _gsched_devs=$*
        if [ -z "${_gsched_devs}" ]; then
                # Use devices specified by gsched_devs
                _gsched_devs=${gsched_devs}
                # If no devices are specified then use all we can find
                if [ -z "${_gsched_devs}" ]; then
                        _gsched_devs=`gsched_all_devs`
                fi
        elif [ -n "${gsched_devs}" ]; then
                # Make sure the custom device is one of the accepted
                for _g in ${_gsched_devs}; do
                        case ${gsched_devs} in
                                # _g is either by itself, at the start, middle
                                # or the end of gsched_devs
                                ${_g}|${_g}\ *|*\ ${_g}\ *|*\ ${_g})
                                        
_gsched_devs_recon="${_gsched_devs_recon} ${_g}"
                                        ;;
                        esac
                done
                _gsched_devs=${_gsched_devs_recon}
        fi

        echo -n "Starting gsched devices:"

        for _g in ${_gsched_devs}; do
                echo -n " $_g"
                gsched_start_dev $_g
        done

        echo "."
}

gsched_stop_dev() {
        local _gsched_dev

        _gsched_dev=$1

        ${command} destroy ${_gsched_dev}.sched.
}

gsched_stop() {
        local _gsched_devs _g

        _gsched_devs=$*
        if [ -z "${_gsched_devs}" ]; then
                # Use devices specified by gsched_devs
                _gsched_devs=${gsched_devs}
                # If no devices are specified then use all we can find
                if [ -z "${_gsched_devs}" ]; then
                        _gsched_devs=`gsched_all_devs`
                fi
        fi

        echo -n "Stopping gsched devices:"

        for _g in ${_gsched_devs}; do
                echo -n " $_g"
                gsched_stop_dev $_g
        done

        echo "."
}

load_rc_config $name
run_rc_command $*

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to