Web Hosting Talk







View Full Version : Freebsd Mysql CPU Fix


Kinko
08-05-2004, 04:41 PM
Hello.

Some of you use freebsd and mysql. Here is a fix for some of those high cpu usage under medium loads for mysql.

For use with ports:

make BUILD_STATIC=yes BUILD_OPTIMIZED=yes WITH_LINUXTHREADS=yes

Then ofcourse:

make install

I noticed mysql using 100% cpu under some simple queries. I tweaked mysql out as far as I could. Apparently, the native thread support in freebsd has issues with mysqld. Adding WITH_LINUXTHREADS=yes installs the linux threads port and speeds up mysqld.

This applys greatly to freebsd 4.9 Freebsd 5.2's native threads are much better than 4.9's but you'll still notice a decent difference.

Building statically (BUILD_STATIC=yes) makes the mysql compile with libraries inside the binary. The binary is larger, but according to mysql devs, it adds 13%~ performance.

I hope this keeps you from getting a headache when your server is using 100% cpu from mysqld.

oktagone
08-05-2004, 05:14 PM
Yeah, we have had heaps of SQL problems with FreeBSD. We did a similar thing to what you have posted above, and it seemed to fix most of the issues.

Linuxthreads is the key