Re: gcc: why optimize for size flag is not the default

From: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: gcc: why optimize for size flag is not the default
Date: 2009-03-11 19:31:33
Message-ID: EC649B6D-E52F-42EA-998F-40DD4D5024E1@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Mar 11, 2009, at 3:18 PM, Grzegorz Jaskiewicz wrote:

>
> On 11 Mar 2009, at 13:51, Marko Kreen wrote:
>
>> Linux kernel is moving to use -Os everywhere. AFAIK their argument
>> is
>> that kernel code should not be doing anything CPU-intensive, thus
>> minimal cache usage is more important than unrolled loops.
>>
>> This also seems to hint that -Os is not really appropriate to
>> Postgres.
>> Although it would be good fit for eg. PgBouncer.
>
> while it might be right in case of linux kernel (which I won't agree
> totally with personally), I don't see any reason to compare it with
> postgresql.
> Kernel is extensively use by everything in system, hence their
> reasoning. Postgresql is an application.

MacOS X defaults to and recommends -Os with the rationales that
smaller code causes less paging and less CPU instruction cache
thrashing.

http://developer.apple.com/ReleaseNotes/DeveloperTools/RN-GCC3/index.html
For deployment builds, the recommended setting is -Os, which produces
the smallest possible binary size. Generally, a binary that's smaller
is also faster. That's because a large application spends much of its
time paging its binary code in and out of memory. The smaller the
binary, the less the application needs to page. For example, say a
binary uses aggressive function inlining. That binary saves time with
fewer function calls, but it could easily spend far more time paging
the binary code containing those inlined functions in and out of memory.

-Os Optimize for size. -Os enables all -O2 optimizations that do not
typically increase code size. It also performs further optimizations
designed to reduce code size.

-Os is still "optimizing" but using a slightly different heuristic as
to what "optimization" means.

That said, if postgresql is paging out, the DBA probably has
postgresql or the server misconfigured.

Cheers,
M

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2009-03-11 20:09:06 Re: gcc: why optimize for size flag is not the default
Previous Message Grzegorz Jaskiewicz 2009-03-11 19:18:11 Re: gcc: why optimize for size flag is not the default