← Back to team overview

maria-discuss team mailing list archive

Re: mariadb runs at lowest priority (nice -n 19) - PBXT code causing problems

 

Hi!

>>>>> "Paul" == Paul McCullagh <paul.mccullagh@xxxxxxxxxxxxx> writes:

<cut>

>> Do you know of any system, except old obsolete linux systems, where  
>> one should
>> use setpriority() to set the priority for a thread?

Paul> I have done no research on this, so I think we should simply change  
Paul> the code to:

Paul>   if (pth_min_priority != pth_max_priority)
Paul>      pth_set_priority()

Paul> This would mean the thread priority is not changed, but that better  
Paul> than mistakingly changing the program priority.

Sounds good. I have now done this change in MariaDB 5.2
(I assume this is what you meant)

=== modified file 'storage/pbxt/src/pthread_xt.cc'
--- storage/pbxt/src/pthread_xt.cc	2011-05-26 11:38:17 +0000
+++ storage/pbxt/src/pthread_xt.cc	2011-06-13 13:39:43 +0000
@@ -547,44 +547,23 @@ xtPublic void xt_p_init_threading(void)
 
 xtPublic int xt_p_set_low_priority(pthread_t thr)
 {
-	if (pth_min_priority == pth_max_priority) {
-		/* Under Linux the priority of normal (non-runtime)
-		 * threads are set using the standard methods
-		 * for setting process priority.
-		 */
-
-		/* We could set who == 0 because it should have the same affect
-		 * as using the PID.
-		 */
-
-		/* -20 = highest, 20 = lowest */
-		if (setpriority(PRIO_PROCESS, getpid(), 20) == -1)
-			return errno;
-		return 0;
-	}
-	return pth_set_priority(thr, pth_min_priority);
+	if (pth_min_priority != pth_max_priority)
+          return pth_set_priority(thr, pth_min_priority);
+        return 0;
 }
 
 xtPublic int xt_p_set_normal_priority(pthread_t thr)
 {
-	if (pth_min_priority == pth_max_priority) {
-		if (setpriority(PRIO_PROCESS, getpid(), 0) == -1)
-			return errno;
-		return 0;
-	}
-	return pth_set_priority(thr, pth_normal_priority);
+	if (pth_min_priority != pth_max_priority)
+ 	  return pth_set_priority(thr, pth_normal_priority);
+        return 0;
 }
 
 xtPublic int xt_p_set_high_priority(pthread_t thr)
 {
-	if (pth_min_priority == pth_max_priority) {
-		if (setpriority(PRIO_PROCESS, getpid(), -20) == -1)
-			return errno;
-		return 0;
-	}
-	return pth_set_priority(thr, pth_max_priority);
+	if (pth_min_priority != pth_max_priority)
+	  return pth_set_priority(thr, pth_max_priority);
+        return 0;
 }
 
Regards,
Monty


References