Reorder FmgrBuiltin members, saving 25% in size.
authorAndres Freund <andres@anarazel.de>
Tue, 16 Oct 2018 21:51:18 +0000 (14:51 -0700)
committerAndres Freund <andres@anarazel.de>
Tue, 16 Oct 2018 21:51:18 +0000 (14:51 -0700)
That's worth it, as fmgr_builtins is frequently accessed, and as
fmgr_builtins is one of the biggest constant variables in a backend.

On most 64bit systems this will change the size of the struct from
32byte to 24bytes. While that could make indexing into the array
marginally more expensive, the higher cache hit ratio is worth more,
especially because these days fmgr_builtins isn't searched with a
binary search anymore (c.f. 212e6f34d5).

Discussion: https://postgr.es/m/20181016201145.aa2dfeq54rhqzron@alap3.anarazel.de

src/backend/utils/Gen_fmgrtab.pl
src/include/utils/fmgrtab.h

index fa30436895b25e6175f3db8e6c1b2dc1713dc68a..ca282913552ff53ae683ebbb31c5b61f337bd64c 100644 (file)
@@ -230,7 +230,7 @@ my $fmgr_count = 0;
 foreach my $s (sort { $a->{oid} <=> $b->{oid} } @fmgr)
 {
    print $tfh
-     "  { $s->{oid}, \"$s->{prosrc}\", $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, $s->{prosrc} }";
+     "  { $s->{oid}, $s->{nargs}, $bmap{$s->{strict}}, $bmap{$s->{retset}}, \"$s->{prosrc}\", $s->{prosrc} }";
 
    $fmgr_builtin_oid_index[ $s->{oid} ] = $fmgr_count++;
 
index d8317eb3eacb9ca0d539abfd81fe7474e0e5bd75..6122ed3e978f644db45ba233cc18632529f125e6 100644 (file)
 typedef struct
 {
    Oid         foid;           /* OID of the function */
-   const char *funcName;       /* C name of the function */
    short       nargs;          /* 0..FUNC_MAX_ARGS, or -1 if variable count */
    bool        strict;         /* T if function is "strict" */
    bool        retset;         /* T if function returns a set */
+   const char *funcName;       /* C name of the function */
    PGFunction  func;           /* pointer to compiled function */
 } FmgrBuiltin;