Re: Memory Accounting
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Melanie Plageman <melanieplageman@gmail.com>, Soumyadeep Chakraborty
<sochakraborty@pivotal.io>, Robert Haas <robertmhaas@gmail.com>, Pg Hackers
<pgsql-hackers@postgresql.org>, soumyadeep2007@gmail.com
Date: 2019-10-04T14:32:21Z
Lists: pgsql-hackers
On Fri, 2019-10-04 at 10:26 +0200, Tomas Vondra wrote: > On Fri, Oct 04, 2019 at 12:36:01AM -0400, Tom Lane wrote: > > So ... why exactly did this patch define > > MemoryContextData.mem_allocated > > as int64? That seems to me to be doubly wrong: it is not the right > > width > > on 32-bit machines, and it is not the right signedness anywhere. I > > think > > that field ought to be of type Size (a/k/a size_t, but memnodes.h > > always > > calls it Size). > > > > Yeah, I think that's an oversight. Maybe there's a reason why Jeff > used > int64, but I can't think of any. I had chosen a 64-bit value to account for the situation Tom mentioned: that, in theory, Size might not be large enough to represent all allocations in a memory context. Apparently, that theoretical situation is not worth being concerned about. The patch has been floating around for a very long time, so I don't remember exactly why I chose a signed value. Sorry. Regards, Jeff Davis
Commits
-
Change MemoryContextMemAllocated to return Size
- 36425ece5d6c 13.0 landed
-
Use Size instead of int64 to track allocated memory
- f2369bc610a1 13.0 landed
-
Add transparent block-level memory accounting
- 5dd7fc151946 13.0 landed
-
Change the way pre-reading in external sort's merge phase works.
- e94568ecc10f 10.0 cited
-
Improve memory management for external sorts.
- 0011c0091e88 9.6.0 cited
-
In array_agg(), don't create a new context for every group.
- b419865a814a 9.5.0 cited