Re: Large writable variables
Andres Freund <andres@anarazel.de>
Hi, On 2018-10-15 16:36:26 -0400, Tom Lane wrote: > Andres Freund <andres@anarazel.de> writes: > > So we have 500kb of not-initialized memory mapped into every > > process. That's, uh, not nothing. > > Bleah. Yea... > > 0000000008585088 0000000000131104 b hist_entries > > 0000000008716192 0000000000016384 b hist_start > > I'm unsure what fraction of processes would have use for these. Yea, I'm not sure either. Although I suspect that given the cost of compression having an "allocate on first use" check should be quite doable. > > 0000000008435040 0000000000085280 b DCHCache > > 0000000008391168 0000000000043840 b NUMCache > > We could surely allocate these on first use. yep. > > 0000000008560224 0000000000023440 b tzdefrules_s > > 0000000008536704 0000000000023440 b gmtmem.7009 > > I think that tzdefrules_s is not used in common cases (though I could be > wrong about that), so we could win by alloc-on-first-use. The same might > be true for gmtmem, but there's a sticking point: there is no provision > for failure there, so I'm unsure how we avoid crashing on OOM. I guess we could return false / NULL to the caller. Not perfect, but there's not that many callers. We could wrap them in wrappers that throw errors... > > 0000000008238336 0000000000008192 b PqRecvBuffer > > 0000000008734208 0000000000005136 B BackendWritebackContext > > 0000000008386368 0000000000003200 b held_lwlocks > > These are below my personal threshold of pain. Yea, agreed. PqRecvBuffer and held_lwlocks are common enough that it makes sense to pre-allocate them anyway. I guess you could argue that BackendWritebackContext should be dynamically allocated. > > I'm unclear as to why ScanKeywords, DCH_keywords aren't in a readonly > > section. > > I think it's the same problem: pointers can't be truly const because > they have to be changed if one relocates the executable. Right. It's, as I noticed when looking via objdupm, in .data.rel.ro, so I think it's not that bad. > We could possibly fix these by changing the data structure so that > what's in a ScanKeywords entry is an offset into some giant string > constant somewhere. No idea how that would affect performance, but > I do notice that we could reduce the sizeof(ScanKeyword), which can't > hurt. Yea, that might even help performancewise. Alternatively we could change ScanKeyword to store the keyword name inline, but that'd be a measurable size increase... Greetings, Andres Freund
Commits
-
Apply unconstify() in more places
- 0a8590b2a09e 12.0 landed
-
Improve unconstify() documentation
- f2898de98a54 12.0 landed
-
Drop const cast from dlsym() calls
- e6f5d1accd3a 12.0 landed
-
Const-ify a few more large static tables.
- 48d818ede15b 12.0 landed
-
Improve tzparse's handling of TZDEFRULES ("posixrules") zone data.
- fb38d9a2e1ed 9.5.15 landed
- ec5fe7f799a4 9.4.20 landed
- e7eb07f70951 12.0 landed
- db4f9c0258be 11.1 landed
- c776cd47245a 9.3.25 landed
- 312f632005f3 10.6 landed
- 1164389e12b0 9.6.11 landed
-
Avoid statically allocating statement cache in ecpglib/prepare.c.
- e15aae829e3e 12.0 landed
-
Reorder FmgrBuiltin members, saving 25% in size.
- 28d750c0cd5b 12.0 landed
-
Add macro to cast away const without allowing changes to underlying type.
- d1211c63f010 12.0 landed
-
Mark constantly allocated dest receiver as const.
- 93ca02e00560 12.0 landed
-
Avoid statically allocating formatting.c's format string caches.
- fd85e9f78d44 12.0 landed
-
Correct constness of system attributes in heap.c & prerequisites.
- 02a30a09f9e5 12.0 landed
-
Avoid statically allocating gmtsub()'s timezone workspace.
- baa94ebe2cc8 9.3.25 landed
- 5ef71d4bd322 9.6.11 landed
- 27ba589b745f 9.4.20 landed
- 18c725413fad 9.5.15 landed
- d64a54fb9c81 10.6 landed
- d11268237378 11.1 landed
- 3dfef0c519de 12.0 landed
-
Correct constness of a few variables.
- 62649bad831f 12.0 landed
-
Move the replication lag tracker into heap memory.
- e73ca79fc78d 12.0 landed