summaryrefslogtreecommitdiff
path: root/src/include/utils/memutils.h
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2025-05-23 15:44:54 +0200
committerDaniel Gustafsson <dgustafsson@postgresql.org>2025-05-23 15:44:54 +0200
commitfb844b9f06568aa29303122ac0bb7b4c3cce2542 (patch)
tree66efe16dbf2d81153330a37d899f36f4524e338e /src/include/utils/memutils.h
parent70a13c528b6e382a381ff95c15a4989e2dd9360b (diff)
Revert function to get memory context stats for processes
Due to concerns raised about the approach, and memory leaks found in sensitive contexts the functionality is reverted. This reverts commits 45e7e8ca9, f8c115a6c, d2a1ed172, 55ef7abf8 and 042a66291 for v18 with an intent to revisit this patch for v19. Discussion: https://postgr.es/m/594293.1747708165@sss.pgh.pa.us
Diffstat (limited to 'src/include/utils/memutils.h')
-rw-r--r--src/include/utils/memutils.h82
1 files changed, 0 insertions, 82 deletions
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index c0987dca155..8abc26abce2 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -18,9 +18,6 @@
#define MEMUTILS_H
#include "nodes/memnodes.h"
-#include "storage/condition_variable.h"
-#include "storage/lmgr.h"
-#include "utils/dsa.h"
/*
@@ -51,23 +48,6 @@
#define AllocHugeSizeIsValid(size) ((Size) (size) <= MaxAllocHugeSize)
-/*
- * Memory Context reporting size limits.
- */
-
-/* Max length of context name and ident */
-#define MEMORY_CONTEXT_IDENT_SHMEM_SIZE 64
-/* Maximum size (in bytes) of DSA area per process */
-#define MEMORY_CONTEXT_REPORT_MAX_PER_BACKEND ((size_t) (1 * 1024 * 1024))
-
-/*
- * Maximum size per context. Actual size may be lower as this assumes the worst
- * case of deepest path and longest identifiers (name and ident, thus the
- * multiplication by 2). The path depth is limited to 100 like for memory
- * context logging.
- */
-#define MAX_MEMORY_CONTEXT_STATS_SIZE (sizeof(MemoryStatsEntry) + \
- (100 * sizeof(int)) + (2 * MEMORY_CONTEXT_IDENT_SHMEM_SIZE))
/*
* Standard top-level memory contexts.
@@ -339,66 +319,4 @@ pg_memory_is_all_zeros(const void *ptr, size_t len)
return true;
}
-/* Dynamic shared memory state for statistics per context */
-typedef struct MemoryStatsEntry
-{
- dsa_pointer name;
- dsa_pointer ident;
- dsa_pointer path;
- NodeTag type;
- int path_length;
- int levels;
- int64 totalspace;
- int64 nblocks;
- int64 freespace;
- int64 freechunks;
- int num_agg_stats;
-} MemoryStatsEntry;
-
-/*
- * Static shared memory state representing the DSA area created for memory
- * context statistics reporting. A single DSA area is created and used by all
- * the processes, each having its specific DSA allocations for sharing memory
- * statistics, tracked by per backend static shared memory state.
- */
-typedef struct MemoryStatsCtl
-{
- dsa_handle memstats_dsa_handle;
- LWLock lw_lock;
-} MemoryStatsCtl;
-
-/*
- * Per backend static shared memory state for memory context statistics
- * reporting.
- */
-typedef struct MemoryStatsBackendState
-{
- ConditionVariable memcxt_cv;
- LWLock lw_lock;
- int proc_id;
- int total_stats;
- bool summary;
- dsa_pointer memstats_dsa_pointer;
- TimestampTz stats_timestamp;
-} MemoryStatsBackendState;
-
-
-/*
- * Used for storage of transient identifiers for pg_get_backend_memory_contexts
- */
-typedef struct MemoryStatsContextId
-{
- MemoryContext context;
- int context_id;
-} MemoryStatsContextId;
-
-extern PGDLLIMPORT MemoryStatsBackendState *memCxtState;
-extern PGDLLIMPORT MemoryStatsCtl *memCxtArea;
-extern PGDLLIMPORT dsa_area *MemoryStatsDsaArea;
-extern void ProcessGetMemoryContextInterrupt(void);
-extern const char *ContextTypeToString(NodeTag type);
-extern void HandleGetMemoryContextInterrupt(void);
-extern Size MemoryContextReportingShmemSize(void);
-extern void MemoryContextReportingShmemInit(void);
-extern void AtProcExit_memstats_cleanup(int code, Datum arg);
#endif /* MEMUTILS_H */