Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Oct 2010 08:07:54 +0200
From:      David Naylor <naylor.b.david@gmail.com>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        freebsd-current@freebsd.org
Subject:   Re: geom_sched usage
Message-ID:  <201010190807.59491.naylor.b.david@gmail.com>
In-Reply-To: <20101018195125.GA46115@onelab2.iet.unipi.it>
References:  <201010180943.37042.naylor.b.david@gmail.com> <20101018195125.GA46115@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart4209501.PVuBcdrAFh
Content-Type: multipart/mixed;
  boundary="Boundary-01=_7WTvMoIkzLmYVWS"
Content-Transfer-Encoding: 7bit


--Boundary-01=_7WTvMoIkzLmYVWS
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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,
> >=20
> > 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).
> >=20
> > Thank you for all this work :-)
> >=20
> > Some questions I have:
> >  - with a gmirror should the gsched be attached to the underlying devic=
es
> >  (aka
> >=20
> > /dev/ad?) or to the mirror device (aka /dev/mirror/?)?
>=20
> always attach as close as possible to the hardware.

Thanks. =20

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

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

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

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

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

I do perceive some improvements in normal usage.  Thanks

> >  - gsched_as does not appear to be installed.
>=20
> 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

--Boundary-01=_7WTvMoIkzLmYVWS
Content-Type: text/plain;
  charset="ISO-8859-1";
  name="gsched.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="gsched.txt"

#!/bin/sh
#
# $FreeBSD$
#
# Specify gsched_enable=3D"YES" in /etc/rc.conf(.local) to activate schedul=
ing on
# storage devices. =20
#=20
# 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

=2E /etc/rc.subr

gsched_enable=3D${gsched_enable:-NO}

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

gsched_start_dev()
{
	local _gsched_dev _gsched_profile _gsched_args

	_gsched_dev=3D$1

	# Check if sched algo was specified
	#
	eval _gsched_profile=3D\$gsched_${_gsched_dev}
	if [ -n "${_gsched_profile}" ]; then
		_gsched_args=3D"-a ${_gsched_profile}"
	fi
=09
	# 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=3D$*
	if [ -z "${_gsched_devs}" ]; then
		# Use devices specified by gsched_devs
		_gsched_devs=3D${gsched_devs}
		# If no devices are specified then use all we can find
		if [ -z "${_gsched_devs}" ]; then
			_gsched_devs=3D`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=3D"${_gsched_devs_recon} ${_g}"
					;;
			esac
		done
		_gsched_devs=3D${_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=3D$1

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

gsched_stop() {
	local _gsched_devs _g

	_gsched_devs=3D$*
	if [ -z "${_gsched_devs}" ]; then
		# Use devices specified by gsched_devs
		_gsched_devs=3D${gsched_devs}
		# If no devices are specified then use all we can find
		if [ -z "${_gsched_devs}" ]; then
			_gsched_devs=3D`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 $*

--Boundary-01=_7WTvMoIkzLmYVWS--

--nextPart4209501.PVuBcdrAFh
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (FreeBSD)

iEYEABECAAYFAky9Nb8ACgkQUaaFgP9pFrJ14ACfRTmC+Z7Zw2VwWe02A93OcAdW
SOQAnRzJMtyMUd6eM0EVZLVG3/HNdpmm
=wvam
-----END PGP SIGNATURE-----

--nextPart4209501.PVuBcdrAFh--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010190807.59491.naylor.b.david>