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

Conversation

iluuu1994
Copy link
Member

Cachegrind supports cg_annotate --diff, which makes it much easier to compare the performance of two patches.

Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iluuu1994
Copy link
Member Author

iluuu1994 commented Jul 14, 2024

I had to make a small adjustment for when the cachegrind header is not available, which apparently is a thing.

@iluuu1994 iluuu1994 requested a review from petk July 14, 2024 09:46
configure.ac Outdated
@@ -751,6 +751,10 @@ AS_VAR_IF([PHP_VALGRIND], [no],,
AC_DEFINE([HAVE_VALGRIND], [1],
[Define to 1 if Valgrind is enabled and supported.])])])

if test "$PHP_VALGRIND" = "yes"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just my 2 cents, might be possible to check it only when valgrind detection is succesful (above) no ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. The configure.ac syntax is so confusing to me that I decided to just create a new if. 😅 If Peter prefers refactoring this, I'll go ahead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree. This Autoconf shell-mixed full-of-portability-concerns syntax is so horrible, that it's not something to keep for too long. Hopefully this will be replaced one day with CMake. Another syntax, but just few levels less horrible :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙏 Thank you for all your work!

@petk
Copy link
Member

petk commented Jul 14, 2024

For the configure.ac part this can be done to wrap it inside a single "if" check (this [no] and checking if it is not no, there is for a minor BC because once there was possible to pass a directory to --with-valgrind=DIR).

To check the Valgrind header, also CFLAGS need to be adjusted a bit because the Valgrind headers might need additional include flags. So this will work:

diff --git a/configure.ac b/configure.ac
index 3ba5703871..b7c3e2ce78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -745,11 +745,16 @@ PHP_ARG_WITH([valgrind],
   [no],
   [no])
 
-AS_VAR_IF([PHP_VALGRIND], [no],,
-  [PKG_CHECK_MODULES([VALGRIND], [valgrind],
+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.])])])
+        [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
+])

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>
@iluuu1994 iluuu1994 force-pushed the cachegrind-cgi-support branch from dc2f12e to d05ead6 Compare July 14, 2024 17:11
@iluuu1994 iluuu1994 merged commit 20d8151 into php:master Jul 14, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants