From 3b78b2f1cd99bf4e0a73d034e9a9f47b45f20e21 Mon Sep 17 00:00:00 2001 From: longxinhui Date: Wed, 4 Aug 2021 11:15:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=87=BD=E6=95=B0=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E7=BC=93=E5=86=B2=E5=8C=BA=E8=AE=BE=E7=BD=AE=20#14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持函数长度缓冲区设置 #14 --- README_CN.md | 2 ++ extension/php_xhprof_apm.h | 4 +++- extension/xhprof_apm.c | 19 ++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README_CN.md b/README_CN.md index 1751b9e..ccf9cde 100644 --- a/README_CN.md +++ b/README_CN.md @@ -130,6 +130,7 @@ array { |apm.ignored  | array的可选选项 |忽略性能分析中的某些函数 | |apm.rate  | 0 - 100 |频率设置,按照0到100的百分比,如果auto设为0,此选项不会生效,如设置大于100会每次开启,等于0则不开启。当不需要此选项时,请注释掉| |apm.debug  | GET参数名 |此选项可通过特定的GET参数开启性能分析,注释即可关闭。如设置auto = 0,同时GET参数中带有设置值 (例如 http://localhost/?apm_debug) ,也会开启性能分析,优先级高于auto。| +|apm.scratch_buf  | 函数长度缓冲区大小 |默认值:512 | ``` apm.auto = 1 @@ -146,6 +147,7 @@ apm.ignored[] = md5 ;apm.rate = 30 apm.debug = apm_debug +apm.scratch_buf = 1024 ``` ## 日志管理界面 diff --git a/extension/php_xhprof_apm.h b/extension/php_xhprof_apm.h index 6b5237a..df97331 100644 --- a/extension/php_xhprof_apm.h +++ b/extension/php_xhprof_apm.h @@ -41,7 +41,7 @@ extern zend_module_entry xhprof_apm_module_entry; */ /* XHProf_APM version */ -#define XHPROF_APM_VERSION "1.0.0" +#define XHPROF_APM_VERSION "1.1.0" #define APM_FUNC_HASH_COUNTERS_SIZE 1024 @@ -208,6 +208,8 @@ ZEND_BEGIN_MODULE_GLOBALS(apm) int debug; + int scratch_buf; + /* counter table indexed by hash value of function names. */ zend_ulong func_hash_counters[APM_FUNC_HASH_COUNTERS_SIZE]; diff --git a/extension/xhprof_apm.c b/extension/xhprof_apm.c index 8222c7f..73923a5 100644 --- a/extension/xhprof_apm.c +++ b/extension/xhprof_apm.c @@ -98,6 +98,7 @@ PHP_GINIT_FUNCTION(apm) apm_globals->trace_callbacks = NULL; apm_globals->ignored_functions = NULL; apm_globals->debug = 0; + apm_globals->scratch_buf = SCRATCH_BUF_LEN; ZVAL_UNDEF(&apm_globals->stats_count); @@ -294,6 +295,7 @@ void hp_clean_profiler_state() APM_G(entries) = NULL; APM_G(ever_enabled) = 0; APM_G(debug) = 0; + APM_G(scratch_buf) = SCRATCH_BUF_LEN; hp_clean_profiler_options_state(); } @@ -602,11 +604,11 @@ void hp_mode_hier_beginfn_cb(hp_entry_t **entries, hp_entry_t *current) void hp_mode_hier_endfn_cb(hp_entry_t **entries) { hp_entry_t *top = (*entries); - zval *counts, files_stack; - char symbol[SCRATCH_BUF_LEN]; - long int mu_end; - long int pmu_end; - double wt, cpu; + zval *counts, files_stack; + char symbol[APM_G(scratch_buf)]; + long int mu_end; + long int pmu_end; + double wt, cpu; /* Get end tsc counter */ wt = cycle_timer() - top->tsc_start; @@ -1494,6 +1496,7 @@ int hp_rshutdown_php(zval *data, int debug) size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp) { + return 0; } int hp_rshutdown_curl(zval *data, int debug) @@ -1643,6 +1646,12 @@ PHP_RINIT_FUNCTION(xhprof_apm) } } + pzval = hp_zval_at_key("scratch_buf", apm_config); + if (pzval) { + convert_to_long(pzval); + APM_G(scratch_buf) = Z_LVAL_P(pzval); + } + if (!enable) { zval_ptr_dtor(&configs); return SUCCESS;