Re: reducing the footprint of ScanKeyword (was Re: Large writable variables)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: John Naylor <jcnaylor@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>,
Andrew Gierth <andrew@tao11.riddles.org.uk>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2018-12-27T20:19:50Z
Lists: pgsql-hackers
John Naylor <jcnaylor@gmail.com> writes: > On 12/27/18, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> +$kw_input_file =~ /((\w*)kwlist)\.h/; >> +my $base_filename = $1; >> +$prefix = $2 if !defined $prefix; >> >> Hmm, what happens if the input filename does not end with "kwlist.h"? > If that's a maintainability hazard, I can force every invocation to > provide a prefix instead. I don't mind allowing the prefix to default to empty. What I was concerned about was that base_filename could end up undefined. Probably the thing to do is to generate base_filename separately, say by stripping any initial ".*/" sequence and then substitute '_' for '.'. >> I looked very briefly at v4-0002, and I'm not very convinced about >> the "middle" aspect of that optimization. It seems unmaintainable, >> plus you've not exhibited how the preferred keywords would get selected >> in the first place (wiring them into the Perl script is surely not >> acceptable). > What if the second argument of the macro held this info? Yeah, you'd have to do something like that. But I'm still concerned about the maintainability aspect: if we mark say "commit" as the starting point in the "c" group, future additions or deletions of keywords starting with "c" might render that an increasingly poor choice. But most likely nobody would ever notice that the marking was getting more and more suboptimal. regards, tom lane
Commits
-
Use perfect hashing, instead of binary search, for keyword lookup.
- c64d0cd5ce24 12.0 landed
-
Reduce the size of the fmgr_builtin_oid_index[] array.
- 8ff5f824dca7 12.0 landed
-
Replace the data structure used for keyword lookup.
- afb0d0712f1a 12.0 landed