svn commit: r244346 - head/usr.bin/sort

Konstantin Belousov kostikbel at gmail.com
Mon Dec 17 11:31:59 UTC 2012


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
> 
> Log:
>   - Use unsigned int for values obtained with sysctlbyname().  This fixes
>     sparc64 performance problems.
>   
>   Submitted by:	Oleg Moskalenko <oleg.moskalenko at citrix.com>
>   Tested by:	trasz
> 
> Modified:
>   head/usr.bin/sort/sort.c
>   head/usr.bin/sort/sort.h
> 
> Modified: head/usr.bin/sort/sort.c
> ==============================================================================
> --- 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;
>  
>  #if defined(SORT_THREADS)
> -size_t ncpu = 1;
> +unsigned int ncpu = 1;
>  size_t nthreads = 1;
>  #endif
>  
> @@ -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;
>  
>  	pages = psize = 0;
>  #if defined(SORT_THREADS)
>  	ncpu = 1;
>  	ncpusz = sizeof(size_t);
>  #endif
> -	psz = pszsz = sizeof(size_t);
> +	psz = sizeof(pages);
> +	pszsz = sizeof(psize);
>  
>  	if (sysctlbyname("vm.stats.vm.v_free_count", &pages, &psz,
>  	    NULL, 0) < 0) {
> @@ -299,6 +301,9 @@ set_hw_params(void)
>  
>  	free_memory = (unsigned long long) pages * (unsigned long long) psize;
>  	available_free_memory = (free_memory * 9) / 10;
> +
> +	if (available_free_memory < 1024)
> +		available_free_memory = 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.
>  
>  /*
> 
> Modified: head/usr.bin/sort/sort.h
> ==============================================================================
> --- 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[];
>  
>  #if defined(SORT_THREADS)
>  #define MT_SORT_THRESHOLD (10000)
> -extern size_t ncpu;
> +extern unsigned int ncpu;
>  extern size_t nthreads;
>  #endif
>  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20121217/a3d71fb0/attachment.sig>


More information about the svn-src-all mailing list