Page MenuHomePhabricator

APCu support
Closed, ResolvedPublic

Description

PHP 5.5 has apc_ and apcu_. PHP 7 only has apcu_ (without installing apc-bc in pecl. Ugh). HHVM only has apc_

For HHVM supporting apcu_ see https://github.com/facebook/hhvm/issues/6784

For T140587 and https://gerrit.wikimedia.org/r/#/c/299498 I originally just replaced apc_ with apcu_, but for HHVM support, this isn't gonna work.

So, do we create an APCuBagOStuff, and add some if/elseif function_exists in MemoizedCallable as appropriate?

Or, do we "move" everything over to apcu_ calls, and add in GlobalFunctions some wrappers around apc_ per the Compatibility functions?

/**
 * Compatibility functions
 *
 * We support PHP 5.5.9 and up.
 * Re-implementations of newer functions or functions in non-standard
 * PHP extensions may be included here.
 */

As is, upgrading to PHP 7 can break login and other stuff if you're trying to use APC, as @Krenair found out... So, it could be suggested our PHP 7 support in REL1_27 is buggy at least

Event Timeline

From @PleaseStand on gerrit:

In APCu 5.1.0 and newer, there is a behavior change between apc_inc (as provided by older versions of APCu, as well as apcu-bc 1.0.2 and newer) and apcu_inc: a value is now initialized to zero with no TTL (prior to performing the operation) if it does not already exist. https://github.com/krakjoe/apcu/issues/166
The doc comment for RedisBagOStuff::incr() states:

  • Non-atomic implementation of incr(). *
  • Probably all callers actually want incr() to atomically initialise
  • values to zero if they don't exist, as provided by the Redis INCR
  • command. But we are constrained by the memcached-like interface to
  • return null in that case. Once the key exists, further increments are
  • atomic.

Actually, at least one caller, incrWithInit(), assumes that incr() will fail if the key does not exist (and expects false in that case, not null), in order to set the specified initial value and/or TTL.

P3531 for the basic back compat wrappers for globalfunctions

inc and dec MAY need some work to match the apcu spec...

T140587 is now fixed in master, just waiting on backport to REL1_27... Then both of these bugs can be closed in one go

Change 313756 had a related patch set uploaded (by Reedy):
Detect/use APCu properly

https://gerrit.wikimedia.org/r/313756

@Reedy by broken php7 in your description is that fixed in the above patches?

Change 313756 merged by jenkins-bot:
Detect/use APCu properly

https://gerrit.wikimedia.org/r/313756