pg_hba.conf caching

Started by Bruce Momjianabout 25 years ago7 messagespatches
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Attached is a patch that caches the non-comment contents of pg_hba.conf
as a List of list of tokens. It uses that to test each authentication
request. SIGHUP reloads from the file, and a cache of pg_ident.conf.

I replaced the File reading code with token storage and list traveral.

The only tricky part was moving the Postmaster memory clearing later in
the code so I had the file contents in postgres.c.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Attachments:

/pgpatches/hbatext/plainDownload+854-857
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: pg_hba.conf caching

It seems that the vast bulk of this patch is trivial reformatting of
the existing pg_hba code. I'm having difficulty seeing what the actual
code changes were --- any chance that you could extract and post just
those diffs?

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: Re: pg_hba.conf caching

It seems that the vast bulk of this patch is trivial reformatting of
the existing pg_hba code. I'm having difficulty seeing what the actual
code changes were --- any chance that you could extract and post just
those diffs?

Yes, I agree it looks that way. Every access to 'buf' became an access
to 'token'. I did move the comments to the top of each function rather
than being after the function header. Not sure how to better present
it.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#4Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: pg_hba.conf caching

It seems that the vast bulk of this patch is trivial reformatting of
the existing pg_hba code. I'm having difficulty seeing what the actual
code changes were --- any chance that you could extract and post just
those diffs?

Also, as you can see, the actual patch has not appeared on the patches
list yet after two days.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#5Karel Zak
zakkr@zf.jcu.cz
In reply to: Bruce Momjian (#1)
Re: pg_hba.conf caching

On Fri, Jul 20, 2001 at 08:31:02PM -0400, Bruce Momjian wrote:

Attached is a patch that caches the non-comment contents of pg_hba.conf
as a List of list of tokens. It uses that to test each authentication

Means it cached are tokens only (and it save lexical analyze for
postmaster children), and final parsing (syntax analyze) running always?

If I'm right: why not store to memory some final structs with config
file content? And for example things like 'strcmp(token, "password")'
run only once during postmaster startup.

Karel

--
Karel Zak <zakkr@zf.jcu.cz>
http://home.zf.jcu.cz/~zakkr/

C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Karel Zak (#5)
Re: pg_hba.conf caching

Karel Zak <zakkr@zf.jcu.cz> writes:

If I'm right: why not store to memory some final structs with config
file content?

That was the original suggestion, but Bruce realized that it's way more
work than it's worth. Eliminating I/O for the comment lines was the big
point for this change --- in a typical pg_hba.conf, there aren't going
to be enough non-comment lines for parsing them to cost anything
noticeable.

regards, tom lane

#7Bruce Momjian
bruce@momjian.us
In reply to: Karel Zak (#5)
Re: pg_hba.conf caching

On Fri, Jul 20, 2001 at 08:31:02PM -0400, Bruce Momjian wrote:

Attached is a patch that caches the non-comment contents of pg_hba.conf
as a List of list of tokens. It uses that to test each authentication

Means it cached are tokens only (and it save lexical analyze for
postmaster children), and final parsing (syntax analyze) running always?

If I'm right: why not store to memory some final structs with config
file content? And for example things like 'strcmp(token, "password")'
run only once during postmaster startup.

The patch will tokenize the file, discard comments, and store the tokens
as a List of Lists, one List per line. We could go with data structures
and eliminate the strncmp of fixed strings and conversion of inet
addresses to inet values but it doesn't seemw worth it. Certainly, now
that the code is completed overhauled, doing something like that will be
easier. The hba.c code clearly needed an overhaul anyway.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026