summaryrefslogtreecommitdiff
path: root/mysys/my_pthread.c
diff options
context:
space:
mode:
authorKonstantin Osipov <kostja@sun.com>2009-11-23 19:57:31 +0300
committerKonstantin Osipov <kostja@sun.com>2009-11-23 19:57:31 +0300
commitbae0e813106d5cd6505b07bd1b682c5eef2ee9d8 (patch)
tree7a70289a8ca5b5d7d7f3e9081bdb69a4ed488e81 /mysys/my_pthread.c
parent9f49582531b7a3a9b74973f0534f9430f7fee75c (diff)
downloadmariadb-git-bae0e813106d5cd6505b07bd1b682c5eef2ee9d8.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. configure.in: Remove checks for functions that are not used anymore. include/config-netware.h: Remove unused define. include/my_pthread.h: Remove thread priority changing wrappers. mysys/my_pthread.c: Remove thread priority changing wrappers. They do not work properly and their implementations were incorrectly protected by a check for HAVE_PTHREAD_SETSCHEDPARAM. mysys/thr_alarm.c: Remove meaningless (100) increase of a thread priority. sql/mysql_priv.h: Remove meaningless thread priority values. sql/mysqld.cc: Don't change thread priorities. sql/slave.cc: Don't change thread priorities. sql/slave.h: Update function prototype. sql/sql_parse.cc: Don't change thread priorities. sql/sql_prepare.cc: Don't change thread priorities. sql/unireg.h: Mark flag as obsolete. storage/innobase/handler/ha_innodb.cc: Remove use of obsolete flag and associated behavior. storage/innobase/include/srv0srv.h: Remove use of obsolete flag and associated variables. storage/innobase/os/os0thread.c: Remove use of obsolete flag and associated behavior. storage/innobase/srv/srv0srv.c: Remove use of obsolete flag and associated variables.
Diffstat (limited to 'mysys/my_pthread.c')
-rw-r--r--mysys/my_pthread.c46
1 files changed, 2 insertions, 44 deletions
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index aba3e47d754..ee839e5567e 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -30,47 +30,6 @@
#endif
uint thd_lib_detected= 0;
-
-#ifndef my_pthread_setprio
-void my_pthread_setprio(pthread_t thread_id,int prior)
-{
-#ifdef HAVE_PTHREAD_SETSCHEDPARAM
- struct sched_param tmp_sched_param;
- bzero((char*) &tmp_sched_param,sizeof(tmp_sched_param));
- tmp_sched_param.sched_priority=prior;
- VOID(pthread_setschedparam(thread_id,SCHED_POLICY,&tmp_sched_param));
-#endif
-}
-#endif
-
-#ifndef my_pthread_getprio
-int my_pthread_getprio(pthread_t thread_id)
-{
-#ifdef HAVE_PTHREAD_SETSCHEDPARAM
- struct sched_param tmp_sched_param;
- int policy;
- if (!pthread_getschedparam(thread_id,&policy,&tmp_sched_param))
- {
- return tmp_sched_param.sched_priority;
- }
-#endif
- return -1;
-}
-#endif
-
-#ifndef my_pthread_attr_setprio
-void my_pthread_attr_setprio(pthread_attr_t *attr, int priority)
-{
-#ifdef HAVE_PTHREAD_SETSCHEDPARAM
- struct sched_param tmp_sched_param;
- bzero((char*) &tmp_sched_param,sizeof(tmp_sched_param));
- tmp_sched_param.sched_priority=priority;
- VOID(pthread_attr_setschedparam(attr,&tmp_sched_param));
-#endif
-}
-#endif
-
-
/* To allow use of pthread_getspecific with two arguments */
#ifdef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC
@@ -364,9 +323,8 @@ int sigwait(sigset_t *setp, int *sigp)
pthread_attr_setscope(&thr_attr,PTHREAD_SCOPE_PROCESS);
pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&thr_attr,8196);
- my_pthread_attr_setprio(&thr_attr,100); /* Very high priority */
- VOID(pthread_create(&sigwait_thread_id,&thr_attr,sigwait_thread,setp));
- VOID(pthread_attr_destroy(&thr_attr));
+ pthread_create(&sigwait_thread_id,&thr_attr,sigwait_thread,setp);
+ pthread_attr_destroy(&thr_attr);
}
pthread_mutex_lock(&LOCK_sigwait);