diff options
author | Konstantin Osipov <kostja@sun.com> | 2009-11-23 19:57:31 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2009-11-23 19:57:31 +0300 |
commit | 7edfae4e867358c76c3c21815a3f25b07372d319 (patch) | |
tree | 7a70289a8ca5b5d7d7f3e9081bdb69a4ed488e81 /include | |
parent | 777c3034017e3d90937e055e9928b42a48ad6adf (diff) | |
download | mariadb-git-7edfae4e867358c76c3c21815a3f25b07372d319.tar.gz |
Backport of:
-------------------------------------------------------------
revno: 2877
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: 35164-6.0
timestamp: Wed 2008-10-15 19:53:18 -0300
message:
Bug#35164: Large number of invalid pthread_attr_setschedparam calls
Bug#37536: Thread scheduling causes performance degradation at low thread count
Bug#12702: Long queries take 100% of CPU and freeze other applications under Windows
The problem is that although having threads with different priorities
yields marginal improvements [1] in some platforms [2], relying on some
statically defined priorities (QUERY_PRIOR and WAIT_PRIOR) to play well
(or to work at all) with different scheduling practices and disciplines
is, at best, a shot in the dark as the meaning of priority values may
change depending on the scheduling policy set for the process.
Another problem is that increasing priorities can hurt other concurrent
(running on the same hardware) applications (such as AMP) by causing
starvation problems as MySQL threads will successively preempt lower
priority processes. This can be evidenced by Bug#12702.
The solution is to not change the threads priorities and rely on the
system scheduler to perform its job. This also enables a system admin
to increase or decrease the scheduling priority of the MySQL process,
if intended.
Furthermore, the internal wrappers and code for changing the priority
of threads is being removed as they are now unused and ancient.
1. Due to unintentional side effects. On Solaris this could artificially
help benchmarks as calling the priority changing syscall millions of
times is more beneficial than the actual setting of the priority.
2. Where it actually works. It has never worked on Linux as the default
scheduling policy SCHED_OTHER only accepts the static priority 0.
Diffstat (limited to 'include')
-rw-r--r-- | include/config-netware.h | 1 | ||||
-rw-r--r-- | include/my_pthread.h | 35 |
2 files changed, 2 insertions, 34 deletions
diff --git a/include/config-netware.h b/include/config-netware.h index 4b9e1437170..adde3c4fbd2 100644 --- a/include/config-netware.h +++ b/include/config-netware.h @@ -73,7 +73,6 @@ extern "C" { #undef HAVE_FINITE #undef HAVE_GETPWNAM #undef HAVE_GETPWUID -#undef HAVE_PTHREAD_SETSCHEDPARAM #undef HAVE_READLINK #undef HAVE_STPCPY /* changes end */ diff --git a/include/my_pthread.h b/include/my_pthread.h index b6d9feae067..eff6d654f2e 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -35,7 +35,6 @@ typedef DWORD pthread_t; typedef struct thread_attr { DWORD dwStackSize ; DWORD dwCreatingFlag ; - int priority ; } pthread_attr_t ; typedef struct { int dummy; } pthread_condattr_t; @@ -110,7 +109,6 @@ int pthread_cond_broadcast(pthread_cond_t *cond); int pthread_cond_destroy(pthread_cond_t *cond); int pthread_attr_init(pthread_attr_t *connect_att); int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack); -int pthread_attr_setprio(pthread_attr_t *connect_att,int priority); int pthread_attr_destroy(pthread_attr_t *connect_att); struct tm *localtime_r(const time_t *timep,struct tm *tmp); struct tm *gmtime_r(const time_t *timep,struct tm *tmp); @@ -141,19 +139,18 @@ int pthread_join(pthread_t thread, void **value_ptr); #define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A)) #define pthread_mutex_unlock(A) LeaveCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A) -#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH) /* Dummy defines for easier code */ #define pthread_attr_setdetachstate(A,B) pthread_dummy(0) -#define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B) #define pthread_attr_setscope(A,B) #define pthread_detach_this_thread() #define pthread_condattr_init(A) #define pthread_condattr_destroy(A) -#define my_pthread_getprio(thread_id) pthread_dummy(0) +/* per the platform's documentation */ +#define pthread_yield() Sleep(0) #else /* Normal threads */ @@ -181,8 +178,6 @@ void my_pthread_exit(void *status); #define pthread_exit(A) my_pthread_exit(A) #endif -extern int my_pthread_getprio(pthread_t thread_id); - #define pthread_key(T,V) pthread_key_t V #define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V)) #define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V)) @@ -254,32 +249,6 @@ int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */ #define my_sigset(A,B) signal((A),(B)) #endif -#ifndef my_pthread_setprio -#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */ -#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B)) -#elif defined(HAVE_PTHREAD_SETPRIO) -#define my_pthread_setprio(A,B) pthread_setprio((A),(B)) -#elif defined(HAVE_PTHREAD_SETSCHEDPRIO) && !defined (__GNUC__) -/* - Workaround for bug on Solaris where pthread.h have bug in GNU - version of pthread.h => configure says yes, header files says - no. So not used with gcc and issue is Solaris only, so will - be used on Solaris using SunStudio. -*/ -#define my_pthread_setprio(A,B) pthread_setschedprio((A),(B)) -#else -extern void my_pthread_setprio(pthread_t thread_id,int prior); -#endif -#endif - -#ifndef my_pthread_attr_setprio -#ifdef HAVE_PTHREAD_ATTR_SETPRIO -#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B)) -#else -extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority); -#endif -#endif - #if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS) #define pthread_attr_setscope(A,B) #undef HAVE_GETHOSTBYADDR_R /* No definition */ |