MemoryContextStats tweak: show tree structure

Started by Neil Conwayalmost 19 years ago4 messagespatches
Jump to latest
#1Neil Conway
neilc@samurai.com

Previously, MemoryContextStats() simply emitted a line of output for
each MemoryContext. This is fine, but it makes it difficult to see the
shape of the MemoryContext hierarchy. Attached is a trivial patch to
indent each context by "4 * level" spaces, where "level" is the depth of
the node within the subtree printed by MemoryContextStats().

For example, suppose we have three contexts beneath TopMemoryContext:

TopMemoryContext (...)
FooContext (...)
BarContext (...)
BazContext (...)

With the patch, these might be printed as:

TopMemoryContext (...)
FooContext (...)
BarContext (...)
BazContext (...)

Assuming that's the parent/child relationship between them, of course.

Obviously this is just for debugging, but I've found it useful while
looking at some memory-related issues. Any comments or objections to
including this in HEAD?

-Neil

Attachments:

mcxt_stats_indent_pgdg-1.patchtext/x-patch; charset=UTF-8; name=mcxt_stats_indent_pgdg-1.patchDownload+23-11
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#1)
Re: MemoryContextStats tweak: show tree structure

Neil Conway <neilc@samurai.com> writes:

Previously, MemoryContextStats() simply emitted a line of output for
each MemoryContext. This is fine, but it makes it difficult to see the
shape of the MemoryContext hierarchy. Attached is a trivial patch to
indent each context by "4 * level" spaces, where "level" is the depth of
the node within the subtree printed by MemoryContextStats().

Seems reasonable except I'd vote for less indentation --- the lines are
too long already. How do you feel about 1 or 2 spaces per level?

regards, tom lane

#3Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#2)
Re: MemoryContextStats tweak: show tree structure

On Mon, 2007-08-06 at 20:56 -0400, Tom Lane wrote:

Seems reasonable except I'd vote for less indentation --- the lines are
too long already. How do you feel about 1 or 2 spaces per level?

Sure, 2 spaces per level is fine with me (1 makes it a bit hard to see
the tree structure, IMHO).

-Neil

#4Neil Conway
neilc@samurai.com
In reply to: Neil Conway (#1)
Re: MemoryContextStats tweak: show tree structure

On Mon, 2007-06-08 at 17:48 -0700, Neil Conway wrote:

Obviously this is just for debugging, but I've found it useful while
looking at some memory-related issues. Any comments or objections to
including this in HEAD?

Applied, with an indentation of two spaces per level.

-Neil