Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8b5a78c

Browse files
author
Commitfest Bot
committed
[CF 5558] v25 - Draft for basic NUMA observability
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5558 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/ce8903b2-8cf7-43c9-bd50-9675c256da39@vondra.me Author(s): Jakub Wartak
2 parents d9c7911 + 826d492 commit 8b5a78c

37 files changed

+1179
-11
lines changed

.cirrus.tasks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ task:
471471
--enable-cassert --enable-injection-points --enable-debug \
472472
--enable-tap-tests --enable-nls \
473473
--with-segsize-blocks=6 \
474+
--with-libnuma \
474475
--with-liburing \
475476
\
476477
${LINUX_CONFIGURE_FEATURES} \
@@ -523,6 +524,7 @@ task:
523524
-Dllvm=disabled \
524525
--pkg-config-path /usr/lib/i386-linux-gnu/pkgconfig/ \
525526
-DPERL=perl5.36-i386-linux-gnu \
527+
-Dlibnuma=disabled \
526528
build-32
527529
EOF
528530

configure

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ XML2_LIBS
708708
XML2_CFLAGS
709709
XML2_CONFIG
710710
with_libxml
711+
LIBNUMA_LIBS
712+
LIBNUMA_CFLAGS
713+
with_libnuma
711714
LIBCURL_LIBS
712715
LIBCURL_CFLAGS
713716
with_libcurl
@@ -872,6 +875,7 @@ with_liburing
872875
with_uuid
873876
with_ossp_uuid
874877
with_libcurl
878+
with_libnuma
875879
with_libxml
876880
with_libxslt
877881
with_system_tzdata
@@ -906,6 +910,8 @@ LIBURING_CFLAGS
906910
LIBURING_LIBS
907911
LIBCURL_CFLAGS
908912
LIBCURL_LIBS
913+
LIBNUMA_CFLAGS
914+
LIBNUMA_LIBS
909915
XML2_CONFIG
910916
XML2_CFLAGS
911917
XML2_LIBS
@@ -1588,6 +1594,7 @@ Optional Packages:
15881594
--with-uuid=LIB build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)
15891595
--with-ossp-uuid obsolete spelling of --with-uuid=ossp
15901596
--with-libcurl build with libcurl support
1597+
--with-libnuma build with libnuma support
15911598
--with-libxml build with XML support
15921599
--with-libxslt use XSLT support when building contrib/xml2
15931600
--with-system-tzdata=DIR
@@ -1629,6 +1636,10 @@ Some influential environment variables:
16291636
C compiler flags for LIBCURL, overriding pkg-config
16301637
LIBCURL_LIBS
16311638
linker flags for LIBCURL, overriding pkg-config
1639+
LIBNUMA_CFLAGS
1640+
C compiler flags for LIBNUMA, overriding pkg-config
1641+
LIBNUMA_LIBS
1642+
linker flags for LIBNUMA, overriding pkg-config
16321643
XML2_CONFIG path to xml2-config utility
16331644
XML2_CFLAGS C compiler flags for XML2, overriding pkg-config
16341645
XML2_LIBS linker flags for XML2, overriding pkg-config
@@ -9063,6 +9074,182 @@ $as_echo "$as_me: WARNING: *** OAuth support tests require --with-python to run"
90639074
fi
90649075

90659076

9077+
#
9078+
# libnuma
9079+
#
9080+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with libnuma support" >&5
9081+
$as_echo_n "checking whether to build with libnuma support... " >&6; }
9082+
9083+
9084+
9085+
# Check whether --with-libnuma was given.
9086+
if test "${with_libnuma+set}" = set; then :
9087+
withval=$with_libnuma;
9088+
case $withval in
9089+
yes)
9090+
9091+
$as_echo "#define USE_LIBNUMA 1" >>confdefs.h
9092+
9093+
;;
9094+
no)
9095+
:
9096+
;;
9097+
*)
9098+
as_fn_error $? "no argument expected for --with-libnuma option" "$LINENO" 5
9099+
;;
9100+
esac
9101+
9102+
else
9103+
with_libnuma=no
9104+
9105+
fi
9106+
9107+
9108+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_libnuma" >&5
9109+
$as_echo "$with_libnuma" >&6; }
9110+
9111+
9112+
if test "$with_libnuma" = yes ; then
9113+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for numa_available in -lnuma" >&5
9114+
$as_echo_n "checking for numa_available in -lnuma... " >&6; }
9115+
if ${ac_cv_lib_numa_numa_available+:} false; then :
9116+
$as_echo_n "(cached) " >&6
9117+
else
9118+
ac_check_lib_save_LIBS=$LIBS
9119+
LIBS="-lnuma $LIBS"
9120+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9121+
/* end confdefs.h. */
9122+
9123+
/* Override any GCC internal prototype to avoid an error.
9124+
Use char because int might match the return type of a GCC
9125+
builtin and then its argument prototype would still apply. */
9126+
#ifdef __cplusplus
9127+
extern "C"
9128+
#endif
9129+
char numa_available ();
9130+
int
9131+
main ()
9132+
{
9133+
return numa_available ();
9134+
;
9135+
return 0;
9136+
}
9137+
_ACEOF
9138+
if ac_fn_c_try_link "$LINENO"; then :
9139+
ac_cv_lib_numa_numa_available=yes
9140+
else
9141+
ac_cv_lib_numa_numa_available=no
9142+
fi
9143+
rm -f core conftest.err conftest.$ac_objext \
9144+
conftest$ac_exeext conftest.$ac_ext
9145+
LIBS=$ac_check_lib_save_LIBS
9146+
fi
9147+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_numa_numa_available" >&5
9148+
$as_echo "$ac_cv_lib_numa_numa_available" >&6; }
9149+
if test "x$ac_cv_lib_numa_numa_available" = xyes; then :
9150+
cat >>confdefs.h <<_ACEOF
9151+
#define HAVE_LIBNUMA 1
9152+
_ACEOF
9153+
9154+
LIBS="-lnuma $LIBS"
9155+
9156+
else
9157+
as_fn_error $? "library 'libnuma' is required for NUMA support" "$LINENO" 5
9158+
fi
9159+
9160+
9161+
pkg_failed=no
9162+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for numa" >&5
9163+
$as_echo_n "checking for numa... " >&6; }
9164+
9165+
if test -n "$LIBNUMA_CFLAGS"; then
9166+
pkg_cv_LIBNUMA_CFLAGS="$LIBNUMA_CFLAGS"
9167+
elif test -n "$PKG_CONFIG"; then
9168+
if test -n "$PKG_CONFIG" && \
9169+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"numa\""; } >&5
9170+
($PKG_CONFIG --exists --print-errors "numa") 2>&5
9171+
ac_status=$?
9172+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
9173+
test $ac_status = 0; }; then
9174+
pkg_cv_LIBNUMA_CFLAGS=`$PKG_CONFIG --cflags "numa" 2>/dev/null`
9175+
test "x$?" != "x0" && pkg_failed=yes
9176+
else
9177+
pkg_failed=yes
9178+
fi
9179+
else
9180+
pkg_failed=untried
9181+
fi
9182+
if test -n "$LIBNUMA_LIBS"; then
9183+
pkg_cv_LIBNUMA_LIBS="$LIBNUMA_LIBS"
9184+
elif test -n "$PKG_CONFIG"; then
9185+
if test -n "$PKG_CONFIG" && \
9186+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"numa\""; } >&5
9187+
($PKG_CONFIG --exists --print-errors "numa") 2>&5
9188+
ac_status=$?
9189+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
9190+
test $ac_status = 0; }; then
9191+
pkg_cv_LIBNUMA_LIBS=`$PKG_CONFIG --libs "numa" 2>/dev/null`
9192+
test "x$?" != "x0" && pkg_failed=yes
9193+
else
9194+
pkg_failed=yes
9195+
fi
9196+
else
9197+
pkg_failed=untried
9198+
fi
9199+
9200+
9201+
9202+
if test $pkg_failed = yes; then
9203+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9204+
$as_echo "no" >&6; }
9205+
9206+
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
9207+
_pkg_short_errors_supported=yes
9208+
else
9209+
_pkg_short_errors_supported=no
9210+
fi
9211+
if test $_pkg_short_errors_supported = yes; then
9212+
LIBNUMA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "numa" 2>&1`
9213+
else
9214+
LIBNUMA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "numa" 2>&1`
9215+
fi
9216+
# Put the nasty error message in config.log where it belongs
9217+
echo "$LIBNUMA_PKG_ERRORS" >&5
9218+
9219+
as_fn_error $? "Package requirements (numa) were not met:
9220+
9221+
$LIBNUMA_PKG_ERRORS
9222+
9223+
Consider adjusting the PKG_CONFIG_PATH environment variable if you
9224+
installed software in a non-standard prefix.
9225+
9226+
Alternatively, you may set the environment variables LIBNUMA_CFLAGS
9227+
and LIBNUMA_LIBS to avoid the need to call pkg-config.
9228+
See the pkg-config man page for more details." "$LINENO" 5
9229+
elif test $pkg_failed = untried; then
9230+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9231+
$as_echo "no" >&6; }
9232+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
9233+
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
9234+
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
9235+
is in your PATH or set the PKG_CONFIG environment variable to the full
9236+
path to pkg-config.
9237+
9238+
Alternatively, you may set the environment variables LIBNUMA_CFLAGS
9239+
and LIBNUMA_LIBS to avoid the need to call pkg-config.
9240+
See the pkg-config man page for more details.
9241+
9242+
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
9243+
See \`config.log' for more details" "$LINENO" 5; }
9244+
else
9245+
LIBNUMA_CFLAGS=$pkg_cv_LIBNUMA_CFLAGS
9246+
LIBNUMA_LIBS=$pkg_cv_LIBNUMA_LIBS
9247+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9248+
$as_echo "yes" >&6; }
9249+
9250+
fi
9251+
fi
9252+
90669253
#
90679254
# XML
90689255
#

configure.ac

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,20 @@ if test "$with_libcurl" = yes ; then
10531053
fi
10541054

10551055

1056+
#
1057+
# libnuma
1058+
#
1059+
AC_MSG_CHECKING([whether to build with libnuma support])
1060+
PGAC_ARG_BOOL(with, libnuma, no, [build with libnuma support],
1061+
[AC_DEFINE([USE_LIBNUMA], 1, [Define to build with NUMA support. (--with-libnuma)])])
1062+
AC_MSG_RESULT([$with_libnuma])
1063+
AC_SUBST(with_libnuma)
1064+
1065+
if test "$with_libnuma" = yes ; then
1066+
AC_CHECK_LIB(numa, numa_available, [], [AC_MSG_ERROR([library 'libnuma' is required for NUMA support])])
1067+
PKG_CHECK_MODULES(LIBNUMA, numa)
1068+
fi
1069+
10561070
#
10571071
# XML
10581072
#

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
ifdef USE_PGXS
1718
PG_CONFIG = pg_config
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
SELECT NOT(pg_numa_available()) AS skip_test \gset
2+
\if :skip_test
3+
\quit
4+
\endif
5+
select count(*) = (select setting::bigint
6+
from pg_settings
7+
where name = 'shared_buffers')
8+
from pg_buffercache_numa;
9+
?column?
10+
----------
11+
t
12+
(1 row)
13+
14+
-- Check that the functions / views can't be accessed by default. To avoid
15+
-- having to create a dedicated user, use the pg_database_owner pseudo-role.
16+
SET ROLE pg_database_owner;
17+
SELECT count(*) > 0 FROM pg_buffercache_numa;
18+
ERROR: permission denied for view pg_buffercache_numa
19+
RESET role;
20+
-- Check that pg_monitor is allowed to query view / function
21+
SET ROLE pg_monitor;
22+
SELECT count(*) > 0 FROM pg_buffercache_numa;
23+
?column?
24+
----------
25+
t
26+
(1 row)
27+
28+
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 REPLACE FUNCTION pg_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+
CREATE OR REPLACE VIEW pg_buffercache_numa AS
14+
SELECT P.* FROM pg_buffercache_numa_pages() AS P
15+
(bufferid integer, page_num int4, node_id int4);
16+
17+
-- Don't want these to be available to public.
18+
REVOKE ALL ON FUNCTION pg_buffercache_numa_pages() FROM PUBLIC;
19+
REVOKE ALL ON pg_buffercache_numa FROM PUBLIC;
20+
21+
GRANT EXECUTE ON FUNCTION pg_buffercache_numa_pages() TO pg_monitor;
22+
GRANT SELECT ON 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)