On Fri, Oct 9, 2020 at 5:40 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > > Looking a bit deeper into this, I'm wondering if in fact your > > EstimateStringSize() and EstimateNodeSize() functions should be using > > BUFFERALIGN() for EACH stored string/node (rather than just calling > > shm_toc_estimate_chunk() once at the end, after the length of packed > > strings and nodes has been estimated), to ensure alignment of start of > > each string/node. Other Postgres code appears to be aligning each > > stored chunk using shm_toc_estimate_chunk(). See the definition of > > that macro and its current usages. > > > > I am not sure if this required for the purpose of correctness. AFAIU, > we do store/estimate multiple parameters in same way at other places, > see EstimateParamListSpace and SerializeParamList. Do you have > something else in mind? >
The point I was trying to make is that potentially more efficient code can be used if the individual strings/nodes are aligned, rather than packed (as they are now), but as you point out, there are already cases (e.g. SerializeParamList) where within the separately-aligned chunks the data is not aligned, so maybe not a big deal. Oh well, without alignment, that means use of memcpy() cannot really be avoided here for serializing/de-serializing ints etc., let's hope the compiler optimizes it as best it can. Regards, Greg Nancarrow Fujitsu Australia