Skip to content

Add cachegrind support for php-cgi warmups #14952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -745,11 +745,16 @@ PHP_ARG_WITH([valgrind],
[no],
[no])

AS_VAR_IF([PHP_VALGRIND], [no],,
[PKG_CHECK_MODULES([VALGRIND], [valgrind],
[PHP_EVAL_INCLINE([$VALGRIND_CFLAGS])
AC_DEFINE([HAVE_VALGRIND], [1],
[Define to 1 if Valgrind is enabled and supported.])])])
AS_VAR_IF([PHP_VALGRIND], [no],, [
PKG_CHECK_MODULES([VALGRIND], [valgrind],
[PHP_EVAL_INCLINE([$VALGRIND_CFLAGS])
AC_DEFINE([HAVE_VALGRIND], [1],
[Define to 1 if Valgrind is enabled and supported.])])
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $VALGRIND_CFLAGS"
AC_CHECK_HEADERS([valgrind/cachegrind.h])
CFLAGS=$save_CFLAGS
])

dnl General settings.
dnl ----------------------------------------------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions sapi/cgi/cgi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;

#ifdef HAVE_VALGRIND
# include "valgrind/callgrind.h"
# ifdef HAVE_VALGRIND_CACHEGRIND_H
# include "valgrind/cachegrind.h"
# endif
#endif

#ifndef PHP_WIN32
Expand Down Expand Up @@ -2249,6 +2252,10 @@ consult the installation file that came with this distribution, or visit \n\
CALLGRIND_STOP_INSTRUMENTATION;
/* We're not interested in measuring startup */
CALLGRIND_ZERO_STATS;
# ifdef HAVE_VALGRIND_CACHEGRIND_H
CACHEGRIND_STOP_INSTRUMENTATION;
/* Zeroing stats is not supported for cachegrind. */
# endif
}
#endif
} else {
Expand Down Expand Up @@ -2461,6 +2468,9 @@ consult the installation file that came with this distribution, or visit \n\
#ifdef HAVE_VALGRIND
if (warmup_repeats == 0) {
CALLGRIND_START_INSTRUMENTATION;
# ifdef HAVE_VALGRIND_CACHEGRIND_H
CACHEGRIND_START_INSTRUMENTATION;
# endif
}
#endif

Expand Down Expand Up @@ -2585,6 +2595,9 @@ consult the installation file that came with this distribution, or visit \n\
#ifdef HAVE_VALGRIND
/* We're not interested in measuring shutdown */
CALLGRIND_STOP_INSTRUMENTATION;
# ifdef HAVE_VALGRIND_CACHEGRIND_H
CACHEGRIND_STOP_INSTRUMENTATION;
# endif
#endif

if (!fastcgi) {
Expand Down
Loading