Re: optimal build options?

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 14 Oct 2009 22:37:58 +0200


Hi Greg,

On Wed, Oct 14, 2009 at 04:21:13PM -0400, Greg Gard wrote:
> hi all,
>
> i recently started building haproxy and was a bit fuzzy on what the
> preferred options are for the build. i read the README, but still find
> myself wondering if i have the best set.
>
> here is what i did:
>
> first i edited the makefile:
> PREFIX = /usr/local/haproxy/1.3.20

You never have to edit the makefile, you can pass the same variable on the command line, it will override the makefile's one :

  make xxx PREFIX=/usr/local/haproxy/1.3.20

Also, I really discourage you from using the full version in the installation path, because you will quickly end up with a different version there just because some of your scripts or configs will reference this directory. Using "/1.3" however can be fine.

> then ran:
> make TARGET=linux26 USE_PCRE=1 USE_STATIC_PCRE=1
>
> i noticed in the makefile that regparm is recommended on x86, and i
> was unaware of the -g option described in an earlier email to this
> list today.

The -g option is to force keeping debugging symbols. It makes the binary huge but can be useful if you can a core and have a debugger installed on the machine. Quite honnestly, cores are so rare that you shouldn't care about this one. From my memories, we only had two cores reported in 7-8 years of production, the last one being today due to my faulty backport.

> anyway, what are the preferred options for production machines?

It is important that you set TARGET to match your operating system as closely as possible, as this is what determines which features and optimizations are available. Most users will set "linux26" here.

Enabling PCRE saves a lot of CPU when using regex, which is rarely used at the beginning but soon after a few months because you will inevitably start fixing application bugs on the LB, as everyone does it. Using it statically makes sense if you build your binary on a common machine for tens (or hundreds) of target machines and are not sure they all have libpcre installed. Otherwise, keep it dynamic, you'll ensure it gets upgraded as any other package.

The REGPARM parameter should only be used with recent GCC > 3, as older versions hand serious bugs when using this on function pointers. I'd say that if you're not sure, don't waste your time on this one, as it will save at most 1-2% of CPU.

If you're using a lot of memory you can be interested in trying DLMALLOC (you need to download the dlmalloc source too). It is very efficient and can rely on pure mmap even for small pages, which allows haproxy to release any unused memory area during a restart. This is especially important for people working with very long sessions (eg: TSE) who can have multiple haproxy processes running at the same time due to multiple reloads. Otherwise you don't need it.

So, if we summarize, generally you'll use :

    make TARGET=linux26 USE_PCRE=1

Hoping this helps!
Willy Received on 2009/10/14 22:37

This archive was generated by hypermail 2.2.0 : 2009/10/14 22:45 CEST