Re: Large writable variables

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org, Thomas Munro <thomas.munro@enterprisedb.com>
Date: 2018-10-15T21:19:03Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On 2018-10-15 16:54:53 -0400, Tom Lane wrote:
>> Yeah.  It also seems like doing it this way would improve locality of
>> access: the pieces of the giant string would presumably be in the same
>> order as the ScanKeywords entries, whereas with the current setup,
>> who knows where the compiler has put 'em or in what order.

> I assume you're talking about the offset approach. Performancewise I
> assume that my suggestion of inlining the names into the struct would be
> faster.  Are there many realistic cases where performance matters enough
> to warrant the size increase?

Doubt it, because there'd be an awful lot of wasted space due to the need
to set the struct size large enough for the longest keyword.  (Plus it
would likely not come out to be a power-of-2 size, slowing array
indexing.)  If you want this to be cache-friendly, I'd think the smaller
the better.

			regards, tom lane


Commits

  1. Apply unconstify() in more places

  2. Improve unconstify() documentation

  3. Drop const cast from dlsym() calls

  4. Const-ify a few more large static tables.

  5. Improve tzparse's handling of TZDEFRULES ("posixrules") zone data.

  6. Avoid statically allocating statement cache in ecpglib/prepare.c.

  7. Reorder FmgrBuiltin members, saving 25% in size.

  8. Add macro to cast away const without allowing changes to underlying type.

  9. Mark constantly allocated dest receiver as const.

  10. Avoid statically allocating formatting.c's format string caches.

  11. Correct constness of system attributes in heap.c & prerequisites.

  12. Avoid statically allocating gmtsub()'s timezone workspace.

  13. Correct constness of a few variables.

  14. Move the replication lag tracker into heap memory.