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: Joerg Sonnenberger <joerg@bec.de>
Cc: David Rowley <david.rowley@2ndquadrant.com>,
John Naylor <jcnaylor@gmail.com>, Andres Freund <andres@anarazel.de>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-01-07T21:11:04Z
Lists: pgsql-hackers
Attachments
- perfect-hash-keyword-lookup-1.patch (text/x-diff) patch
I wrote: > I took a quick look through the NetBSD nbperf sources at > http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/nbperf/ > and I concur with your judgment that we could manage translating > that into Perl, especially if we only implement the parts we need. Here's an implementation of that, using the hash functions you showed upthread. The speed of the Perl script seems to be pretty acceptable; less than 100ms to handle the main SQL keyword list, on my machine. Yeah, the C version might be less than 1ms, but I don't think that we need to put up with non-Perl build tooling for that. Using the same test case as before (parsing information_schema.sql), I get runtimes around 3560 ms, a shade better than my jury-rigged prototype. Probably there's a lot to be criticized about the Perl style below; anybody feel a need to rewrite it? 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