From 690a21552b58a9967cfcec480c651973de3fcfd8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 9 Jan 2016 10:39:35 +0100 Subject: php-pecl-apcu: 5.1.2-2, upstream patches for apcu_inc / apcu_dec --- REFLECTION-PHP7 | 177 +------------------------------------ apcu-pr.patch | 78 ----------------- apcu-upstream.patch | 227 ++++++++++++++++++++++++++++++++++++++++++++++++ php-pecl-apcu-php7.spec | 12 ++- 4 files changed, 241 insertions(+), 253 deletions(-) delete mode 100644 apcu-pr.patch create mode 100644 apcu-upstream.patch diff --git a/REFLECTION-PHP7 b/REFLECTION-PHP7 index 9b0f981..91fafcd 100644 --- a/REFLECTION-PHP7 +++ b/REFLECTION-PHP7 @@ -1,4 +1,4 @@ -Extension [ extension #70 apcu version 5.1.0 ] { +Extension [ extension #56 apcu version 5.1.2 ] { - INI { Entry [ apc.enabled ] @@ -23,7 +23,7 @@ Extension [ extension #70 apcu version 5.1.0 ] { Current = '0' } Entry [ apc.mmap_file_mask ] - Current = '/tmp/apc.PaEi1m' + Current = '/tmp/apc.FeiOLJ' } Entry [ apc.enable_cli ] Current = '1' @@ -49,7 +49,7 @@ Extension [ extension #70 apcu version 5.1.0 ] { } - Constants [16] { - Constant [ integer ] { 139697376948720 } + Constant [ integer ] { 140593052737952 } Constant [ integer APC_LIST_ACTIVE ] { 1 } Constant [ integer APC_LIST_DELETED ] { 2 } Constant [ integer APC_ITER_TYPE ] { 1 } @@ -243,174 +243,3 @@ Extension [ extension #70 apcu version 5.1.0 ] { } } -Extension [ extension #71 apc version 5.1.0 ] { - - - Dependencies { - Dependency [ apcu (Required) ] - } - - - Functions { - Function [ function apc_cache_info ] { - - - Parameters [2] { - Parameter #0 [ $ignored ] - Parameter #1 [ $limited ] - } - } - Function [ function apc_clear_cache ] { - - - Parameters [1] { - Parameter #0 [ $ignored ] - } - } - Function [ function apc_store ] { - - - Parameters [3] { - Parameter #0 [ $key ] - Parameter #1 [ $var ] - Parameter #2 [ $ttl ] - } - } - Function [ function apc_fetch ] { - - - Parameters [2] { - Parameter #0 [ $key ] - Parameter #1 [ &$success ] - } - } - Function [ function apc_enabled ] { - - - Parameters [0] { - } - } - Function [ function apc_delete ] { - - - Parameters [1] { - Parameter #0 [ $keys ] - } - } - Function [ function apc_add ] { - - - Parameters [3] { - Parameter #0 [ $key ] - Parameter #1 [ $var ] - Parameter #2 [ $ttl ] - } - } - Function [ function apc_sma_info ] { - - - Parameters [1] { - Parameter #0 [ $limited ] - } - } - Function [ function apc_inc ] { - - - Parameters [3] { - Parameter #0 [ $key ] - Parameter #1 [ $step ] - Parameter #2 [ &$success ] - } - } - Function [ function apc_dec ] { - - - Parameters [3] { - Parameter #0 [ $key ] - Parameter #1 [ $step ] - Parameter #2 [ &$success ] - } - } - Function [ function apc_cas ] { - - - Parameters [3] { - Parameter #0 [ $key ] - Parameter #1 [ $old ] - Parameter #2 [ $new ] - } - } - Function [ function apc_exists ] { - - - Parameters [1] { - Parameter #0 [ $keys ] - } - } - } - - - Classes [1] { - Class [ class APCIterator extends APCuIterator implements Traversable, Iterator ] { - - - Constants [0] { - } - - - Static properties [0] { - } - - - Static methods [0] { - } - - - Properties [0] { - } - - - Methods [9] { - Method [ public method __construct ] { - - - Parameters [5] { - Parameter #0 [ $ignored ] - Parameter #1 [ $search ] - Parameter #2 [ $format ] - Parameter #3 [ $chunk_size ] - Parameter #4 [ $list ] - } - } - - Method [ public method rewind ] { - - - Parameters [0] { - } - } - - Method [ public method current ] { - - - Parameters [0] { - } - } - - Method [ public method key ] { - - - Parameters [0] { - } - } - - Method [ public method next ] { - - - Parameters [0] { - } - } - - Method [ public method valid ] { - - - Parameters [0] { - } - } - - Method [ public method getTotalHits ] { - - - Parameters [0] { - } - } - - Method [ public method getTotalSize ] { - - - Parameters [0] { - } - } - - Method [ public method getTotalCount ] { - - - Parameters [0] { - } - } - } - } - } -} - diff --git a/apcu-pr.patch b/apcu-pr.patch deleted file mode 100644 index 434d9df..0000000 --- a/apcu-pr.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 896b1643b4295a37fba4e0fb5cb8ffb3c10da851 Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Tue, 9 Jun 2015 14:34:23 +0200 -Subject: [PATCH 1/2] use ['info'] instead of undefined ['key'] - ---- - apc.php | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/apc.php b/apc.php -index cedf096..119d74e 100644 ---- a/apc.php -+++ b/apc.php -@@ -915,7 +915,6 @@ function block_sort($array1, $array2) - } - $fieldname='info'; - $fieldheading='User Entry Label'; -- $fieldkey='key'; - - $cols=6; - echo <<'; -- echo '[Delete Now]'; -+ echo '[Delete Now]'; - echo ''; - } else { - echo '   '; - -From 20c53f1ee86a659d5316977096efe5edf03eb958 Mon Sep 17 00:00:00 2001 -From: Remi Collet -Date: Tue, 9 Jun 2015 14:36:25 +0200 -Subject: [PATCH 2/2] silent the fetch, to hide "Warning: Class - __PHP_Incomplete_Class has no unserializer in..." - ---- - apc.php | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/apc.php b/apc.php -index 119d74e..47debee 100644 ---- a/apc.php -+++ b/apc.php -@@ -1048,7 +1048,7 @@ function block_sort($array1, $array2) - echo ''; - if ($sh == $MYREQUEST["SH"]) { - echo ''; -- echo '
'.htmlentities(print_r(apcu_fetch($entry['info']), 1)).'
'; -+ echo '
'.htmlentities(print_r(@apcu_fetch($entry['info']), 1)).'
'; - echo ''; - } - $i++; -From f095923ecaa46a6e3c64bee913cf527077393539 Mon Sep 17 00:00:00 2001 -From: Stanislav Khromov -Date: Fri, 17 Oct 2014 15:44:20 +0200 -Subject: [PATCH] Scroll to cache entry when clicking on it - ---- - apc.php | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/apc.php b/apc.php -index efc7eec..cedf096 100644 ---- a/apc.php -+++ b/apc.php -@@ -1020,8 +1020,8 @@ function block_sort($array1, $array2) - $sh=md5($entry["info"]); - $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8'); - echo -- '', -- "",$field_value,'', -+ '', -+ "",$field_value,'', - '',$entry['num_hits'],'', - '',$entry['mem_size'],'', - '',date(DATE_FORMAT,$entry['access_time']),'', diff --git a/apcu-upstream.patch b/apcu-upstream.patch new file mode 100644 index 0000000..b21aeb6 --- /dev/null +++ b/apcu-upstream.patch @@ -0,0 +1,227 @@ +diff --git a/apc_globals.h b/apc_globals.h +index 40509f0..a0de234 100644 +--- a/apc_globals.h ++++ b/apc_globals.h +@@ -41,12 +41,12 @@ + ZEND_BEGIN_MODULE_GLOBALS(apcu) + /* configuration parameters */ + zend_bool enabled; /* if true, apc is enabled (defaults to true) */ +- long shm_segments; /* number of shared memory segments to use */ +- long shm_size; /* size of each shared memory segment (in MB) */ +- long entries_hint; /* hint at the number of entries expected */ +- long gc_ttl; /* parameter to apc_cache_create */ +- long ttl; /* parameter to apc_cache_create */ +- long smart; /* smart value */ ++ zend_long shm_segments; /* number of shared memory segments to use */ ++ zend_long shm_size; /* size of each shared memory segment (in MB) */ ++ zend_long entries_hint; /* hint at the number of entries expected */ ++ zend_long gc_ttl; /* parameter to apc_cache_create */ ++ zend_long ttl; /* parameter to apc_cache_create */ ++ zend_long smart; /* smart value */ + + #if APC_MMAP + char *mmap_file_mask; /* mktemp-style file-mask to pass to mmap */ +diff --git a/php_apc.c b/php_apc.c +index c35ede1..83fd758 100644 +--- a/php_apc.c ++++ b/php_apc.c +@@ -118,11 +118,11 @@ static PHP_INI_MH(OnUpdateShmSize) /* {{{ */ + return FAILURE; + } + +- if (s < 1048576L) { ++ if (s < Z_L(1048576)) { + /* if it's less than 1Mb, they are probably using the old syntax */ + php_error_docref( + NULL, E_WARNING, "apc.shm_size now uses M/G suffixes, please update your ini files"); +- s = s * 1048576L; ++ s = s * Z_L(1048576); + } + + APCG(shm_size) = s; +@@ -526,60 +526,46 @@ PHP_FUNCTION(apcu_add) { + /* {{{ php_inc_updater */ + + struct php_inc_updater_args { +- zend_long step; +- zend_long lval; ++ zval step; ++ zval rval; + }; + + static zend_bool php_inc_updater(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) { + struct php_inc_updater_args *args = (struct php_inc_updater_args*) data; + + if (Z_TYPE(entry->val) == IS_LONG) { +- while (args->step--) { +- fast_long_increment_function(&entry->val); +- } +- args->lval = Z_LVAL(entry->val); ++ fast_long_add_function(&entry->val, &entry->val, &args->step); ++ ZVAL_COPY_VALUE(&args->rval, &entry->val); + return 1; + } + + return 0; + } + +-static zend_bool php_dec_updater(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) { +- struct php_inc_updater_args *args = (struct php_inc_updater_args*) data; +- +- if (Z_TYPE(entry->val) == IS_LONG) { +- while (args->step--) { +- fast_long_decrement_function(&entry->val); +- } +- args->lval = Z_LVAL(entry->val); +- return 1; +- } +- +- return 0; +-} +-/* }}} */ +- + /* {{{ proto long apc_inc(string key [, long step [, bool& success]]) + */ + PHP_FUNCTION(apcu_inc) { + zend_string *key; +- struct php_inc_updater_args args = {1L, -1}; ++ struct php_inc_updater_args args; ++ zend_long step = 1; + zval *success = NULL; + +- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &(args.step), &success) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) { + return; + } +- ++ + if (success) { + ZVAL_DEREF(success); + zval_ptr_dtor(success); + } + ++ ZVAL_LONG(&args.step, step); ++ + if (php_apc_update(key, php_inc_updater, &args)) { + if (success) { + ZVAL_TRUE(success); + } +- RETURN_LONG(args.lval); ++ RETURN_ZVAL(&args.rval, 0, 0); + } + + if (success) { +@@ -594,24 +580,27 @@ PHP_FUNCTION(apcu_inc) { + */ + PHP_FUNCTION(apcu_dec) { + zend_string *key; +- struct php_inc_updater_args args = {1L, -1}; ++ struct php_inc_updater_args args; ++ zend_long step = 1; + zval *success = NULL; + +- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &(args.step), &success) == FAILURE) { ++ if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|lz", &key, &step, &success) == FAILURE) { + return; + } +- ++ + if (success) { + ZVAL_DEREF(success); + zval_ptr_dtor(success); + } + +- if (php_apc_update(key, php_dec_updater, &args)) { ++ ZVAL_LONG(&args.step, 0 - step); ++ ++ if (php_apc_update(key, php_inc_updater, &args)) { + if (success) { + ZVAL_TRUE(success); + } + +- RETURN_LONG(args.lval); ++ RETURN_ZVAL(&args.rval, 0, 0); + } + + if (success) { +@@ -662,9 +651,7 @@ PHP_FUNCTION(apcu_cas) { + PHP_FUNCTION(apcu_fetch) { + zval *key; + zval *success = NULL; +- apc_cache_entry_t* entry; + time_t t; +- apc_context_t ctxt = {0,}; + + if (!APCG(enabled)) { + RETURN_FALSE; +diff --git a/tests/apc_012.phpt b/tests/apc_012.phpt +index e7844ef..0d3b050 100644 +--- a/tests/apc_012.phpt ++++ b/tests/apc_012.phpt +@@ -10,25 +10,28 @@ apc.enable_cli=1 + $key="testkey"; + $i=PHP_INT_MAX; + apcu_store($key, $i); +-$j=apcu_fetch($key); ++var_dump($j=apcu_fetch($key)); + var_dump($i==$j); + + apcu_inc($key, 1); + $i++; +-$j=apcu_fetch($key); ++var_dump($j=apcu_fetch($key)); + var_dump($i==$j); + + $i=PHP_INT_MIN; + apcu_store($key, $i); + apcu_dec($key, 1); + $i--; +-$j=apcu_fetch($key); ++var_dump($j=apcu_fetch($key)); + var_dump($i==$j); + ?> + ===DONE=== + +---EXPECT-- ++--EXPECTF-- ++int(%d) + bool(true) ++float(%s) + bool(true) ++float(%s) + bool(true) + ===DONE=== +diff --git a/tests/apc_inc_perf.phpt b/tests/apc_inc_perf.phpt +new file mode 100644 +index 0000000..8f082f1 +--- /dev/null ++++ b/tests/apc_inc_perf.phpt +@@ -0,0 +1,28 @@ ++--TEST-- ++APC: apcu_inc/apcu_dec performance test (gh#164) ++--SKIPIF-- ++ ++--INI-- ++apc.enabled=1 ++apc.enable_cli=1 ++apc.file_update_protection=0 ++--FILE-- ++ ++===DONE=== ++ ++--EXPECTF-- ++int(1985229329) ++int(1) ++int(1000000000) ++int(1) ++bool(true) ++===DONE=== diff --git a/php-pecl-apcu-php7.spec b/php-pecl-apcu-php7.spec index 7f988ac..0a9b2ab 100644 --- a/php-pecl-apcu-php7.spec +++ b/php-pecl-apcu-php7.spec @@ -41,13 +41,16 @@ Version: 5.1.2 Release: 0.2.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz %else -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz %endif Source1: %{pecl_name}-5.1.2.ini Source2: %{pecl_name}-panel.conf Source3: %{pecl_name}.conf.php +# Patch from master, for apcu_in / apcu_dec issues +Patch1: %{pecl_name}-upstream.patch + License: PHP Group: Development/Languages URL: http://pecl.php.net/package/APCu @@ -154,6 +157,8 @@ mv %{pecl_name}-%{version} NTS %endif cd NTS +%patch1 -p1 -b .upstream + # Sanity check, really often broken extver=$(sed -n '/#define PHP_APCU_VERSION/{s/.* "//;s/".*$//;p}' php_apc.h) if test "x${extver}" != "x%{version}%{?prever}%{?gh_date:dev}"; then @@ -321,6 +326,11 @@ fi %changelog +* Sat Jan 9 2016 Remi Collet - 5.1.2-2 +- add upstream patches to fix issues with apcu_inc / apcu_dec + https://github.com/krakjoe/apcu/issues/158 - negative step hangs + https://github.com/krakjoe/apcu/issues/164 - huge step performance + * Mon Dec 7 2015 Remi Collet - 5.1.2-1 - Update to 5.1.2 (stable) -- cgit