From e0f7b6acfd3829356b36905f6e7057b04a27919e Mon Sep 17 00:00:00 2001 From: Oliver Kurmis Date: Wed, 10 Apr 2013 12:14:16 +0300 Subject: [PATCH 1/5] call graph: changed color of arrows/edges to grey for readability call graph: changed color of arrows/edges to grey for better readability of the labels --- xhprof_lib/utils/callgraph_utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xhprof_lib/utils/callgraph_utils.php b/xhprof_lib/utils/callgraph_utils.php index b41eed6d..9cccc278 100644 --- a/xhprof_lib/utils/callgraph_utils.php +++ b/xhprof_lib/utils/callgraph_utils.php @@ -378,7 +378,7 @@ function xhprof_generate_dot_script($raw_data, $threshold, $source, $page, $result .= "N" . $sym_table[$parent]["id"] . " -> N" . $sym_table[$child]["id"]; - $result .= "[arrowsize=$arrow_size, style=\"setlinewidth($linewidth)\"," + $result .= "[arrowsize=$arrow_size, color=grey, style=\"setlinewidth($linewidth)\"," ." label=\"" .$label."\", headlabel=\"".$headlabel ."\", taillabel=\"".$taillabel."\" ]"; From 7130169a2229b44452ff3150eee9e78965b5f664 Mon Sep 17 00:00:00 2001 From: Erik Webb Date: Thu, 2 May 2013 10:49:40 -0400 Subject: [PATCH 2/5] Ignore build artifacts from Git --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..446d6de1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +extension/* +!extension/php_xhprof.h +!extension/xhprof.c From baf2db18470f086bdb0635f99bce3f289c32dad7 Mon Sep 17 00:00:00 2001 From: Erik Webb Date: Thu, 2 May 2013 11:03:27 -0400 Subject: [PATCH 3/5] Missing config.m4 and tests from Git ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 446d6de1..87f88c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ extension/* +!extension/config.m4 !extension/php_xhprof.h +!extension/tests/ !extension/xhprof.c From 12e9e7a3d406cb5ed9722afeb574b77326954b75 Mon Sep 17 00:00:00 2001 From: Sergei Turchanov Date: Mon, 20 Jan 2014 16:07:30 +1100 Subject: [PATCH 4/5] Made sampling interval and call-stack tracing depth configurable via INI-settings. --- extension/xhprof.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/extension/xhprof.c b/extension/xhprof.c index a053ede8..1dc31c8f 100644 --- a/extension/xhprof.c +++ b/extension/xhprof.c @@ -101,7 +101,8 @@ #define XHPROF_FLAGS_MEMORY 0x0004 /* gather memory usage for funcs */ /* Constants for XHPROF_MODE_SAMPLED */ -#define XHPROF_SAMPLING_INTERVAL 100000 /* In microsecs */ +#define XHPROF_DEFAULT_SAMPLING_INTERVAL 100000 /* In microsecs */ +#define XHPROF_MINIMAL_SAMPLING_INTERVAL 100 /* In microsecs */ /* Constant for ignoring functions, transparent to hierarchical profile */ #define XHPROF_MAX_IGNORED_FUNCTIONS 256 @@ -193,8 +194,10 @@ typedef struct hp_global_t { /* Global to track the time of the last sample in time and ticks */ struct timeval last_sample_time; uint64 last_sample_tsc; - /* XHPROF_SAMPLING_INTERVAL in ticks */ + uint64 sampling_interval; + /* sampling_interval in ticks */ uint64 sampling_interval_tsc; + int sampling_depth; /* This array is used to store cpu frequencies for all available logical * cpus. For now, we assume the cpu frequencies will not change for power @@ -349,6 +352,9 @@ zend_module_entry xhprof_module_entry = { STANDARD_MODULE_PROPERTIES }; +#define STRINGIFY_(X) #X +#define STRINGIFY(X) STRINGIFY_(X) + PHP_INI_BEGIN() /* output directory: @@ -359,6 +365,16 @@ PHP_INI_BEGIN() */ PHP_INI_ENTRY("xhprof.output_dir", "", PHP_INI_ALL, NULL) +/* sampling_interval: + * Sampling interval to be used by the sampling profiler + */ +STD_PHP_INI_ENTRY("xhprof.sampling_interval", STRINGIFY(XHPROF_DEFAULT_SAMPLING_INTERVAL), PHP_INI_ALL, OnUpdateLong, sampling_interval, hp_global_t, hp_globals) + +/* sampling_depth: + * Depth to trace call-chain by the sampling profiler + */ +STD_PHP_INI_ENTRY("xhprof.sampling_depth", STRINGIFY(INT_MAX), PHP_INI_ALL, OnUpdateLong, sampling_depth, hp_global_t, hp_globals) + PHP_INI_END() /* Init module */ @@ -476,6 +492,10 @@ PHP_MINIT_FUNCTION(xhprof) { hp_ignored_functions_filter_clear(); + if (hp_globals.sampling_interval < XHPROF_MINIMAL_SAMPLING_INTERVAL) { + hp_globals.sampling_interval = XHPROF_MINIMAL_SAMPLING_INTERVAL; + } + #if defined(DEBUG) /* To make it random number generator repeatable to ease testing. */ srand(0); @@ -542,6 +562,8 @@ PHP_MINFO_FUNCTION(xhprof) } php_info_print_table_end(); + + DISPLAY_INI_ENTRIES(); } @@ -1160,7 +1182,7 @@ void hp_sample_stack(hp_entry_t **entries TSRMLS_DC) { /* Init stats in the global stats_count hashtable */ hp_get_function_stack(*entries, - INT_MAX, + hp_globals.sampling_depth, symbol, sizeof(symbol)); @@ -1196,7 +1218,7 @@ void hp_sample_check(hp_entry_t **entries TSRMLS_DC) { hp_globals.last_sample_tsc += hp_globals.sampling_interval_tsc; /* bump last_sample_time - HAS TO BE UPDATED BEFORE calling hp_sample_stack */ - incr_us_interval(&hp_globals.last_sample_time, XHPROF_SAMPLING_INTERVAL); + incr_us_interval(&hp_globals.last_sample_time, hp_globals.sampling_interval); /* sample the stack */ hp_sample_stack(entries TSRMLS_CC); @@ -1482,7 +1504,7 @@ void hp_mode_sampled_init_cb(TSRMLS_D) { /* Find the microseconds that need to be truncated */ gettimeofday(&hp_globals.last_sample_time, 0); now = hp_globals.last_sample_time; - hp_trunc_time(&hp_globals.last_sample_time, XHPROF_SAMPLING_INTERVAL); + hp_trunc_time(&hp_globals.last_sample_time, hp_globals.sampling_interval); /* Subtract truncated time from last_sample_tsc */ truncated_us = get_us_interval(&hp_globals.last_sample_time, &now); @@ -1494,7 +1516,7 @@ void hp_mode_sampled_init_cb(TSRMLS_D) { /* Convert sampling interval to ticks */ hp_globals.sampling_interval_tsc = - get_tsc_from_us(XHPROF_SAMPLING_INTERVAL, cpu_freq); + get_tsc_from_us(hp_globals.sampling_interval, cpu_freq); } From 2e3ca277d3665e49b4420f522099fa47ab718f85 Mon Sep 17 00:00:00 2001 From: Sergei Turchanov Date: Sun, 2 Feb 2014 12:57:28 +1100 Subject: [PATCH 5/5] OnUpdateLong expects its argument to be of type "long" --- extension/xhprof.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/xhprof.c b/extension/xhprof.c index 1dc31c8f..e814cceb 100644 --- a/extension/xhprof.c +++ b/extension/xhprof.c @@ -194,7 +194,7 @@ typedef struct hp_global_t { /* Global to track the time of the last sample in time and ticks */ struct timeval last_sample_time; uint64 last_sample_tsc; - uint64 sampling_interval; + long sampling_interval; /* sampling_interval in ticks */ uint64 sampling_interval_tsc; int sampling_depth;