Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Dec 2012 13:31:51 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Gabor Kovesdan <gabor@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r244346 - head/usr.bin/sort
Message-ID:  <20121217113151.GA71906@kib.kiev.ua>
In-Reply-To: <201212170936.qBH9ah0V059357@svn.freebsd.org>
References:  <201212170936.qBH9ah0V059357@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--2VcK7Ezgm4IMdfSa
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Dec 17, 2012 at 09:36:43AM +0000, Gabor Kovesdan wrote:
> Author: gabor
> Date: Mon Dec 17 09:36:43 2012
> New Revision: 244346
> URL: http://svnweb.freebsd.org/changeset/base/244346
>=20
> Log:
>   - Use unsigned int for values obtained with sysctlbyname().  This fixes
>     sparc64 performance problems.
>  =20
>   Submitted by:	Oleg Moskalenko <oleg.moskalenko@citrix.com>
>   Tested by:	trasz
>=20
> Modified:
>   head/usr.bin/sort/sort.c
>   head/usr.bin/sort/sort.h
>=20
> Modified: head/usr.bin/sort/sort.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/usr.bin/sort/sort.c	Mon Dec 17 06:44:16 2012	(r244345)
> +++ head/usr.bin/sort/sort.c	Mon Dec 17 09:36:43 2012	(r244346)
> @@ -103,7 +103,7 @@ bool debug_sort;
>  bool need_hint;
> =20
>  #if defined(SORT_THREADS)
> -size_t ncpu =3D 1;
> +unsigned int ncpu =3D 1;
>  size_t nthreads =3D 1;
>  #endif
> =20
> @@ -268,14 +268,16 @@ set_hw_params(void)
>  #if defined(SORT_THREADS)
>  	size_t ncpusz;
>  #endif
> -	size_t pages, psize, psz, pszsz;
> +	unsigned int pages, psize;
> +	size_t psz, pszsz;
> =20
>  	pages =3D psize =3D 0;
>  #if defined(SORT_THREADS)
>  	ncpu =3D 1;
>  	ncpusz =3D sizeof(size_t);
>  #endif
> -	psz =3D pszsz =3D sizeof(size_t);
> +	psz =3D sizeof(pages);
> +	pszsz =3D sizeof(psize);
> =20
>  	if (sysctlbyname("vm.stats.vm.v_free_count", &pages, &psz,
>  	    NULL, 0) < 0) {
> @@ -299,6 +301,9 @@ set_hw_params(void)
> =20
>  	free_memory =3D (unsigned long long) pages * (unsigned long long) psize;
>  	available_free_memory =3D (free_memory * 9) / 10;
> +
> +	if (available_free_memory < 1024)
> +		available_free_memory =3D 1024;
>  }
Instead of direct use of sysctl interface for hw.ncpu, use
sysconf(_SC_NPROCESSORS_ONLN).

The 'query' for the available memory is absolutely wrong and is beyond
any repair, it must be removed.
> =20
>  /*
>=20
> Modified: head/usr.bin/sort/sort.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/usr.bin/sort/sort.h	Mon Dec 17 06:44:16 2012	(r244345)
> +++ head/usr.bin/sort/sort.h	Mon Dec 17 09:36:43 2012	(r244346)
> @@ -54,7 +54,7 @@ extern const char *nlsstr[];
> =20
>  #if defined(SORT_THREADS)
>  #define MT_SORT_THRESHOLD (10000)
> -extern size_t ncpu;
> +extern unsigned int ncpu;
>  extern size_t nthreads;
>  #endif
> =20

--2VcK7Ezgm4IMdfSa
Content-Type: application/pgp-signature

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

iQIcBAEBAgAGBQJQzwKmAAoJEJDCuSvBvK1Bb+YP/jcn4MhUCyLIxXZVK4TW7cUI
9yTk4jPRJl/pJMIj+oRizANPxGwJBQfDW3h+oCBO5CgwRkfM3vVm/TIs6OKGdNxU
utsNQeF17XvtBgoF2sMiff0VcecJgfGKzKve5ffgg8Z82Hvz28ae9/23P5MD5t7P
P9gwOsbYjKFdCoYL5ldGZlFJFR48OralcML+f86B7gudWhpU0eNBbAL5cnYGxobe
o1j8sS0+aZNQxzjSGnuMyf9t3G5sWpl4aTsbj96ZHYxOd06b6X8UXD+EbOIdSZnX
O/BlLkDy+E/nJxqdqk5RVbLE/nUBG9+kUKiptcN+TDVJzo6ctEiAmzFh9XmVuLaB
v1XUKt3ZmnOknl8ZiSqXscvBwEGYzKBvz6Dkv72BIvkUVJ0WduloruJne6QvKNSR
6sDx0EFRFZqhYaIX6tgXQMZOAmjcFQUeDcmuAZVaWL/8NEnciC1YViutaZjaT8H4
bZF0vWV43lgQPfveVdBh6lhtdtuxxBDKWeixZZLwVZTU83gPqL2K48KAb0aE0foY
ny7QUHXKSObtgEzXriwvYO4eQXWvUYmbWrzH08Aznwg7w04FkKAiYGcEe0OKuNeb
d2C6CxS0dWIistK2sRz4hFgS4MgkOzAspTWPI4bJuZuqm76OcNYmxp488y0a0izi
UsHrei63BY+k/AK66fqR
=yKDY
-----END PGP SIGNATURE-----

--2VcK7Ezgm4IMdfSa--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121217113151.GA71906>