From: | Wim Lewis <wiml(at)omnigroup(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Make various variables read-only (const) |
Date: | 2014-01-03 01:30:25 |
Message-ID: | 52C612B1.5080706@omnigroup.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
By an odd coincidence, I also decided to try to const-ify libpq
recently, and noticed this thread as I was cleaning up my patch for
submission. For what it's worth, I've attached my patch to this message.
It doesn't move as much data into the text segment as Oskari Saarenmaa's
patch does, but it is less intrusive (simply adding const modifiers here
and there). I just went after the low-hanging fruit in libpq.
As an aside, it might make sense to make pg_encname_tbl and
pg_encname_tbl_sz static, since as far as I can tell those symbols are
never used outside of encnames.c nor are they likely to be. I didn't
make that change in this patch though.
On Mon, Dec 23, 2013, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> And how much does this really affect data sharing? Doesn't copy-on-write do the same thing for writable data?
It can have a surprisingly large effect if read-only data gets
intermixed on pages with actual read-write data and can get COWd
unnecessarily.
My motivation, though, was more about code correctness than memory
sharing, though sharing is a nice benefit--- I was examining unexpected
symbols in .data/.bss in case they represented a thread-safety problem
for my program linked against libpq. (They didn't, FWIW, except for the
known and documented issue with PQoidStatus(). Not that I really
expected to find a problem in libpq, but marking those structures const
makes it nice and clear that they're not mutable.)
Attachment | Content-Type | Size |
---|---|---|
libpq-constify.patch | text/plain | 6.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2014-01-03 01:46:17 | Re: BUG #8673: Could not open file "pg_multixact/members/xxxx" on slave during hot_standby |
Previous Message | Robert Haas | 2014-01-03 01:19:23 | Re: truncating pg_multixact/members |