diff options
author | Remi Collet <remi@remirepo.net> | 2025-06-30 09:48:02 +0200 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2025-06-30 09:48:02 +0200 |
commit | 9f62e861d77db6ec137a8450ee0651dfc5ddbc24 (patch) | |
tree | 5aa36bbd57b850d50b408121b33013fe2a9de0c2 |
initial package
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | PHPINFO | 21 | ||||
-rw-r--r-- | REFLECTION | 67 | ||||
-rw-r--r-- | php-noisebynorthwest-php-spx.spec | 169 |
5 files changed, 270 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f0400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +clog +package-*.xml +*.tgz +*.tar.bz2 +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13af741 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile + @@ -0,0 +1,21 @@ + +SPX + +SPX Support => enabled +SPX Version => 0.4.19 + +Directive => Local Value => Master Value +spx.debug => 0 => 0 +spx.data_dir => /tmp/spx => /tmp/spx +spx.http_enabled => 0 => 0 +spx.http_key => no value => no value +spx.http_ip_var => REMOTE_ADDR => REMOTE_ADDR +spx.http_trusted_proxies => 127.0.0.1 => 127.0.0.1 +spx.http_ip_whitelist => no value => no value +spx.http_ui_assets_dir => /usr/share/php-noisebynorthwest-php-spx/assets/web-ui => /usr/share/php-noisebynorthwest-php-spx/assets/web-ui +spx.http_profiling_enabled => no value => no value +spx.http_profiling_auto_start => no value => no value +spx.http_profiling_builtins => no value => no value +spx.http_profiling_sampling_period => no value => no value +spx.http_profiling_depth => no value => no value +spx.http_profiling_metrics => no value => no value diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..134299c --- /dev/null +++ b/REFLECTION @@ -0,0 +1,67 @@ +Extension [ <persistent> extension #140 SPX version 0.4.19 ] { + + - INI { + Entry [ spx.debug <SYSTEM> ] + Current = '0' + } + Entry [ spx.data_dir <SYSTEM> ] + Current = '/tmp/spx' + } + Entry [ spx.http_enabled <SYSTEM> ] + Current = '0' + } + Entry [ spx.http_key <SYSTEM> ] + Current = '' + } + Entry [ spx.http_ip_var <SYSTEM> ] + Current = 'REMOTE_ADDR' + } + Entry [ spx.http_trusted_proxies <SYSTEM> ] + Current = '127.0.0.1' + } + Entry [ spx.http_ip_whitelist <SYSTEM> ] + Current = '' + } + Entry [ spx.http_ui_assets_dir <SYSTEM> ] + Current = '/usr/share/php-noisebynorthwest-php-spx/assets/web-ui' + } + Entry [ spx.http_profiling_enabled <SYSTEM> ] + Current = '' + } + Entry [ spx.http_profiling_auto_start <SYSTEM> ] + Current = '' + } + Entry [ spx.http_profiling_builtins <SYSTEM> ] + Current = '' + } + Entry [ spx.http_profiling_sampling_period <SYSTEM> ] + Current = '' + } + Entry [ spx.http_profiling_depth <SYSTEM> ] + Current = '' + } + Entry [ spx.http_profiling_metrics <SYSTEM> ] + Current = '' + } + } + + - Functions { + Function [ <internal:SPX> function spx_profiler_start ] { + + - Parameters [0] { + } + } + Function [ <internal:SPX> function spx_profiler_stop ] { + + - Parameters [0] { + } + } + Function [ <internal:SPX> function spx_profiler_full_report_set_custom_metadata_str ] { + + - Parameters [1] { + Parameter #0 [ <required> string $customMetadataStr ] + } + } + } +} + diff --git a/php-noisebynorthwest-php-spx.spec b/php-noisebynorthwest-php-spx.spec new file mode 100644 index 0000000..6285d37 --- /dev/null +++ b/php-noisebynorthwest-php-spx.spec @@ -0,0 +1,169 @@ +# remirepo spec file for php-noisebynorthwest-php-spx +# +# SPDX-FileCopyrightText: Copyright 2025 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +# +# Please, preserve the changelog entries +# + +%{?scl:%scl_package php-noisebynorthwest-php-spx} + +%bcond_without tests + +# Extension +%global ext_name spx +%global ini_name 40-%{ext_name}.ini +%global upstream_version 0.4.19 +#global upstream_prever RC1 +# PIE / packagist +%global pie_vend noisebynorthwest +%global pie_proj php-spx +# Github forge +%global gh_vend NoiseByNorthwest +%global gh_proj php-spx +%global forgeurl https://github.com/%{gh_vend}/%{gh_proj} +#global commit b3ae87353da524f33374ee0418ad48f704bb6af1 +%global tag v%{upstream_version}%{?upstream_prever} +# for EL-8 to avoid TAG usage +%global archivename %{gh_proj}-%{upstream_version}%{?upstream_prever} + +Summary: PHP profiling extension +Name: %{?scl_prefix}php-%{pie_vend}-%{pie_proj} +Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} +%forgemeta +Release: 1%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} +# GPL-3.0-only: php-spx +# GPL-3.0-or-later: jscolor.js dataTable.js fmt.js layoutSplitter.js math.js profileData.js svg.js utils.js widget.js +# MIT: jquery +License: GPL-3.0-only AND GPL-3.0-or-later AND MIT +URL: %{forgeurl} +Source0: %{forgesource} + +BuildRequires: make +BuildRequires: gcc +BuildRequires: zlib-devel +BuildRequires: %{?scl_prefix}php-devel + +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} + +Provides: bundled(js-jscolor) +Provides: bundled(js-jquery) = 3.2.1 +Provides: %{?scl_prefix}php-%{ext_name} = %{version} +Provides: %{?scl_prefix}php-%{ext_name}%{?_isa} = %{version} +Provides: %{?scl_prefix}php-pie(%{pie_vend}/%{pie_proj}) = %{version} + + +%description +SPX, which stands for Simple Profiling eXtension, is just another profiling +extension for PHP. + +It differentiates itself from other similar extensions as being: + +* totally free and confined to your infrastructure + (i.e. no data leaks to a SaaS). +* very simple to use: just set an environment variable (command line) or + switch on a radio button (web request) to profile your script. + Thus, you are free of: + * manually instrumenting your code (Ctrl-C a long running command line + script is even supported). + * using a dedicated browser extension or command line launcher. + multi metrics capable: 22 are currently supported (various time & memory + metrics, included files, objects in use, I/O...). +* able to collect data without losing context. For example Xhprof (and + potentially its forks) aggregates data per caller / callee pairs, which + implies the loss of the full call stack and forbids timeline or Flamegraph + based analysis. +* shipped with its web UI which allows to: + * enable / configure profiling for the current browser session + * list profiled script reports + * select a report for in-depth analysis, featuring these interactive + visualizations: + * timeline (scale to millions of function calls) + * flat profile + * Flamegraph + +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}. + + +%prep +%forgesetup + +: Sanity check, really often broken +extver=$(sed -n '/#define PHP_SPX_VERSION/{s/.* "//;s/".*$//;p}' src/php_spx.h) +if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}"; then + : Error: Upstream extension version is ${extver}, expecting %{version}. + exit 1 +fi + +: Create configuration file +cat << 'EOF' | tee %{ini_name} +; Enable the %{summary} +extension=%{ext_name}.so +;spx.debug = 0 +;spx.data_dir = /tmp/spx +;spx.http_enabled =0 +;spx.http_key = +;spx.http_ip_var = REMOTE_ADDR +;spx.http_trusted_proxies =127.0.0.1 +;spx.http_ip_whitelist = +;spx.http_ui_assets_dir = /usr/share/%{name}/assets/web-ui +;spx.http_profiling_enabled = +;spx.http_profiling_auto_start = +;spx.http_profiling_builtins = +;spx.http_profiling_sampling_period = +;spx.http_profiling_depth = +;spx.http_profiling_metrics = +EOF + +: RPM build options and layout +sed -e 's/CFLAGS/IGNORED_CFLAGS/' -i config.m4 +sed -e 's:misc/php-spx:%{name}:' -i Makefile.frag + +%build +%{__phpize} +[ -f Makefile.global ] && GLOBAL=Makefile.global || GLOBAL=build/Makefile.global +sed -e 's/INSTALL_ROOT/DESTDIR/' -i $GLOBAL Makefile.frag + +%configure \ + --enable-spx \ + --with-libdir=%{_lib} \ + --with-php-config=%{__phpconfig} + +%make_build + + +%install +%make_install + +# install config file +install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} + + +%check +: Minimal load test for the extension +%{__php} --no-php-ini \ + --define extension=%{buildroot}/%{php_extdir}/%{ext_name}.so \ + --modules | grep -i '^%{ext_name}$' + +%if %{with tests} +: Upstream test suite for the extension +REPORT_EXIT_STATUS=1 \ +TEST_PHP_ARGS="-n -d extension=%{buildroot}/%{php_extdir}/%{ext_name}.so" \ +%{__php} -n run-tests.php -P -q --show-diff +%endif + + +%files +%license LICENSE +%doc composer.json +%doc *.md +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{ext_name}.so +%{_datadir}/%{name} + + +%changelog +* Mon Jun 30 2025 Remi Collet <remi@remirepo.net> - 0.4.19-1 +- initial package |