Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba2a3c2

Browse files
committed
Add pg_buffercache_numa view with NUMA node info
Introduces a new view pg_buffercache_numa, showing NUMA memory nodesfor individual buffers. For each buffer the view returns an entry foreach memory page, with the associated NUMA node.The database blocks and OS memory pages may have different size - thedefault block size is 8KB, while the memory page is 4K (on x86). Butother combinations are possible, depending on configure parameters,platform, etc. This means buffers may overlap with multiple memorypages, each associated with a different NUMA node.To determine the NUMA node for a buffer, we first need to touch thememory pages using pg_numa_touch_mem_if_required, otherwise we might getstatus -2 (ENOENT = The page is not present), indicating the page iseither unmapped or unallocated.The view may be relatively expensive, especially when accessed for thefirst time in a backend, as it touches all memory pages to get reliableinformation about the NUMA node. This may also force allocation of theshared memory.Author: Jakub Wartak <jakub.wartak@enterprisedb.com>Reviewed-by: Andres Freund <andres@anarazel.de>Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Reviewed-by: Tomas Vondra <tomas@vondra.me>Discussion:https://postgr.es/m/CAKZiRmxh6KWo0aqRqvmcoaX2jUxZYb4kGp3N%3Dq1w%2BDiH-696Xw%40mail.gmail.com
1 parent8cc139b commitba2a3c2

File tree

10 files changed

+452
-4
lines changed

10 files changed

+452
-4
lines changed

‎contrib/pg_buffercache/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ OBJS = \
88
EXTENSION = pg_buffercache
99
DATA = pg_buffercache--1.2.sql pg_buffercache--1.2--1.3.sql\
1010
pg_buffercache--1.1--1.2.sql pg_buffercache--1.0--1.1.sql\
11-
pg_buffercache--1.3--1.4.sql pg_buffercache--1.4--1.5.sql
11+
pg_buffercache--1.3--1.4.sql pg_buffercache--1.4--1.5.sql\
12+
pg_buffercache--1.5--1.6.sql
1213
PGFILEDESC = "pg_buffercache - monitoring of shared buffer cache in real-time"
1314

14-
REGRESS = pg_buffercache
15+
REGRESS = pg_buffercache pg_buffercache_numa
1516

1617
ifdefUSE_PGXS
1718
PG_CONFIG = pg_config
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
SELECT NOT(pg_numa_available()) AS skip_test \gset
2+
\if :skip_test
3+
\quit
4+
\endif
5+
-- We expect at least one entry for each buffer
6+
select count(*) >= (select setting::bigint
7+
from pg_settings
8+
where name = 'shared_buffers')
9+
from pg_buffercache_numa;
10+
?column?
11+
----------
12+
t
13+
(1 row)
14+
15+
-- Check that the functions / views can't be accessed by default. To avoid
16+
-- having to create a dedicated user, use the pg_database_owner pseudo-role.
17+
SET ROLE pg_database_owner;
18+
SELECT count(*) > 0 FROM pg_buffercache_numa;
19+
ERROR: permission denied for view pg_buffercache_numa
20+
RESET role;
21+
-- Check that pg_monitor is allowed to query view / function
22+
SET ROLE pg_monitor;
23+
SELECT count(*) > 0 FROM pg_buffercache_numa;
24+
?column?
25+
----------
26+
t
27+
(1 row)
28+
29+
RESET role;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT NOT(pg_numa_available()) AS skip_test \gset
2+
\if :skip_test
3+
\quit

‎contrib/pg_buffercache/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ install_data(
2323
'pg_buffercache--1.2.sql',
2424
'pg_buffercache--1.3--1.4.sql',
2525
'pg_buffercache--1.4--1.5.sql',
26+
'pg_buffercache--1.5--1.6.sql',
2627
'pg_buffercache.control',
2728
kwargs: contrib_data_args,
2829
)
@@ -34,6 +35,7 @@ tests += {
3435
'regress': {
3536
'sql': [
3637
'pg_buffercache',
38+
'pg_buffercache_numa',
3739
],
3840
},
3941
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* contrib/pg_buffercache/pg_buffercache--1.5--1.6.sql*/
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use"ALTER EXTENSION pg_buffercache UPDATE TO '1.6'" to load this file. \quit
5+
6+
-- Register the new functions.
7+
CREATE OR REPLACEFUNCTIONpg_buffercache_numa_pages()
8+
RETURNS SETOF RECORD
9+
AS'MODULE_PATHNAME','pg_buffercache_numa_pages'
10+
LANGUAGE C PARALLEL SAFE;
11+
12+
-- Create a view for convenient access.
13+
CREATEVIEWpg_buffercache_numaAS
14+
SELECT P.*FROM pg_buffercache_numa_pages()AS P
15+
(bufferidinteger, os_page_num int4, numa_node int4);
16+
17+
-- Don't want these to be available to public.
18+
REVOKE ALLON FUNCTION pg_buffercache_numa_pages()FROM PUBLIC;
19+
REVOKE ALLON pg_buffercache_numaFROM PUBLIC;
20+
21+
GRANT EXECUTEON FUNCTION pg_buffercache_numa_pages() TO pg_monitor;
22+
GRANTSELECTON pg_buffercache_numa TO pg_monitor;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pg_buffercache extension
22
comment = 'examine the shared buffer cache'
3-
default_version = '1.5'
3+
default_version = '1.6'
44
module_pathname = '$libdir/pg_buffercache'
55
relocatable = true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp