-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Measure startup, each bench run and shutdown separately #13162
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
base: master
Are you sure you want to change the base?
Changes from all commits
61db456
6a47d3b
48c1057
66c27d7
5ac6812
74ae907
c92fa3c
3a718b3
25f33f7
b338be1
eff4cfb
ba44c9f
eef3071
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,12 +231,12 @@ jobs: | |
sudo apt-get update | ||
sudo apt-get install \ | ||
bison \ | ||
libgmp-dev \ | ||
libonig-dev \ | ||
libsqlite3-dev \ | ||
openssl \ | ||
re2c \ | ||
valgrind | ||
valgrind \ | ||
debuginfod | ||
- name: ccache | ||
uses: hendrikmuhs/[email protected] | ||
with: | ||
|
@@ -255,7 +255,6 @@ jobs: | |
--enable-werror \ | ||
--prefix=/usr \ | ||
--with-config-file-scan-dir=/etc/php.d \ | ||
--with-gmp \ | ||
--with-mysqli=mysqlnd \ | ||
--with-openssl \ | ||
--with-pdo-sqlite \ | ||
|
@@ -287,7 +286,9 @@ jobs: | |
ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} | ||
path: benchmark/repos/data | ||
- name: Benchmark | ||
run: php benchmark/benchmark.php true | ||
run: | | ||
export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com" | ||
php benchmark/benchmark.php true | ||
- name: Store result | ||
if: github.event_name == 'push' | ||
run: | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1696,6 +1696,16 @@ PHP_FUNCTION(apache_response_headers) /* {{{ */ | |
} | ||
/* }}} */ | ||
|
||
#ifdef HAVE_VALGRIND | ||
static inline void callgrind_dump_stats(void) | ||
{ | ||
char *tmp = getenv("BENCHMARK_DUMP_SEPARATE_PROFILES"); | ||
if (tmp && ZEND_ATOL(tmp)) { | ||
CALLGRIND_DUMP_STATS; | ||
} | ||
} | ||
#endif | ||
|
||
static zend_module_entry cgi_module_entry = { | ||
STANDARD_MODULE_HEADER, | ||
"cgi-fcgi", | ||
|
@@ -2216,13 +2226,6 @@ consult the installation file that came with this distribution, or visit \n\ | |
if (comma) { | ||
warmup_repeats = atoi(php_optarg); | ||
repeats = atoi(comma + 1); | ||
#ifdef HAVE_VALGRIND | ||
if (warmup_repeats > 0) { | ||
CALLGRIND_STOP_INSTRUMENTATION; | ||
/* We're not interested in measuring startup */ | ||
CALLGRIND_ZERO_STATS; | ||
} | ||
#endif | ||
} else { | ||
repeats = atoi(php_optarg); | ||
} | ||
|
@@ -2264,6 +2267,13 @@ consult the installation file that came with this distribution, or visit \n\ | |
} | ||
#endif | ||
while (!fastcgi || fcgi_accept_request(request) >= 0) { | ||
#ifdef HAVE_VALGRIND | ||
if (benchmark) { | ||
/* measure startup and each benchmark run separately */ | ||
callgrind_dump_stats(); | ||
} | ||
#endif | ||
|
||
SG(server_context) = fastcgi ? (void *)request : (void *) 1; | ||
init_request_info(request); | ||
|
||
|
@@ -2430,12 +2440,6 @@ consult the installation file that came with this distribution, or visit \n\ | |
} | ||
} /* end !cgi && !fastcgi */ | ||
|
||
#ifdef HAVE_VALGRIND | ||
if (warmup_repeats == 0) { | ||
CALLGRIND_START_INSTRUMENTATION; | ||
} | ||
#endif | ||
|
||
/* request startup only after we've done all we can to | ||
* get path_translated */ | ||
if (php_request_startup() == FAILURE) { | ||
|
@@ -2554,11 +2558,6 @@ consult the installation file that came with this distribution, or visit \n\ | |
SG(request_info).query_string = NULL; | ||
} | ||
|
||
#ifdef HAVE_VALGRIND | ||
/* We're not interested in measuring shutdown */ | ||
CALLGRIND_STOP_INSTRUMENTATION; | ||
#endif | ||
|
||
if (!fastcgi) { | ||
if (benchmark) { | ||
if (warmup_repeats) { | ||
|
@@ -2586,6 +2585,12 @@ consult the installation file that came with this distribution, or visit \n\ | |
script_file = NULL; | ||
goto do_repeat; | ||
} | ||
|
||
#ifdef HAVE_VALGRIND | ||
/* measure shutdown separately */ | ||
callgrind_dump_stats(); | ||
#endif | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned, I don't think dumping stats to stdout/stderr repeatedly is a good solution, because it makes Valgrind useless for all other use-cases where this script is not used. A better solution would be if we could calculate the mean or whatever metric we find most useful, from C, and output that when the script terminates. Valgrind allows specifying the output file using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, What do you want to achive, does
This is not possible with Valgrind and also probably not wanted, as having multiple Callgrind files is helpful to investigate time differences. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean is that Dmitry and others use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In 9d77734 I have put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @iluuu1994 can I ask you to review this PR |
||
break; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea how to convince
callgrind_annotate
to resolve all symbols, especially all the onces defined in Sqlite lib?libsqlite3-dev
is installed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to compile with
CFLAGS="-g -O2"
to get debug symbols. But with multiple repetitions we don't generally care about startup/shutdown. It's not very meaningful for applications ran with opcache. If you want to provide startup/shutdown you can do so without repetitions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the example you can see some examples of unresolved functions (from
callgrind.symfony-demo.0
profile). WillCFLAGS="-g -O2"
really help if other functions are resolved well?All unresolved functions are listed in the end of each annotated profile file (like
callgrind.symfony-demo.0.txt
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for SQLite, since we're not compiling its source files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug symbols for Debian packages are commonly available via the corresponding
-dbgsym
package.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Ubuntu docker, after apt update, I get only these:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://wiki.ubuntu.com/Debug%20Symbol%20Packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!! That link brought me to https://valgrind.org/docs/manual/manual-core.html#manual-core.debuginfod . Commited in d4fe3ef.
Now I still see some missing source for the core linux libs:
any idea?