Skip to content

Commit 20d8151

Browse files
iluuu1994petk
andauthored
Add cachegrind support for php-cgi warmups (#14952)
Cachegrind supports cg_annotate --diff, which makes it much easier to compare the performance of two patches. Co-authored-by: Peter Kokot <peterkokot@gmail.com>
1 parent 0051b73 commit 20d8151

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

configure.ac

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,16 @@ PHP_ARG_WITH([valgrind],
745745
[no],
746746
[no])
747747

748-
AS_VAR_IF([PHP_VALGRIND], [no],,
749-
[PKG_CHECK_MODULES([VALGRIND], [valgrind],
750-
[PHP_EVAL_INCLINE([$VALGRIND_CFLAGS])
751-
AC_DEFINE([HAVE_VALGRIND], [1],
752-
[Define to 1 if Valgrind is enabled and supported.])])])
748+
AS_VAR_IF([PHP_VALGRIND], [no],, [
749+
PKG_CHECK_MODULES([VALGRIND], [valgrind],
750+
[PHP_EVAL_INCLINE([$VALGRIND_CFLAGS])
751+
AC_DEFINE([HAVE_VALGRIND], [1],
752+
[Define to 1 if Valgrind is enabled and supported.])])
753+
save_CFLAGS=$CFLAGS
754+
CFLAGS="$CFLAGS $VALGRIND_CFLAGS"
755+
AC_CHECK_HEADERS([valgrind/cachegrind.h])
756+
CFLAGS=$save_CFLAGS
757+
])
753758

754759
dnl General settings.
755760
dnl ----------------------------------------------------------------------------

sapi/cgi/cgi_main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
9393

9494
#ifdef HAVE_VALGRIND
9595
# include "valgrind/callgrind.h"
96+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
97+
# include "valgrind/cachegrind.h"
98+
# endif
9699
#endif
97100

98101
#ifndef PHP_WIN32
@@ -2249,6 +2252,10 @@ consult the installation file that came with this distribution, or visit \n\
22492252
CALLGRIND_STOP_INSTRUMENTATION;
22502253
/* We're not interested in measuring startup */
22512254
CALLGRIND_ZERO_STATS;
2255+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
2256+
CACHEGRIND_STOP_INSTRUMENTATION;
2257+
/* Zeroing stats is not supported for cachegrind. */
2258+
# endif
22522259
}
22532260
#endif
22542261
} else {
@@ -2461,6 +2468,9 @@ consult the installation file that came with this distribution, or visit \n\
24612468
#ifdef HAVE_VALGRIND
24622469
if (warmup_repeats == 0) {
24632470
CALLGRIND_START_INSTRUMENTATION;
2471+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
2472+
CACHEGRIND_START_INSTRUMENTATION;
2473+
# endif
24642474
}
24652475
#endif
24662476

@@ -2585,6 +2595,9 @@ consult the installation file that came with this distribution, or visit \n\
25852595
#ifdef HAVE_VALGRIND
25862596
/* We're not interested in measuring shutdown */
25872597
CALLGRIND_STOP_INSTRUMENTATION;
2598+
# ifdef HAVE_VALGRIND_CACHEGRIND_H
2599+
CACHEGRIND_STOP_INSTRUMENTATION;
2600+
# endif
25882601
#endif
25892602

25902603
if (!fastcgi) {

0 commit comments

Comments
 (0)