Skip to content

PowerPC compile-time improvements - #1838

Merged
antirez merged 3 commits into
redis:unstablefrom
mattsta:powerpc-fixes
Jun 26, 2014
Merged

antirez merged 3 commits into
redis:unstablefrom
mattsta:powerpc-fixes

Conversation

@mattsta

@mattsta mattsta commented Jun 26, 2014

Copy link
Copy Markdown
Contributor

Two patches from IBM on the mailing list for powerpc runtime improvements (and one commit for not duplicating code).

mattsta added 3 commits June 26, 2014 08:51
From mailing list post https://groups.google.com/forum/#!topic/redis-db/QLjiQe4D7LA

In zmalloc.c the following primitives are currently used
to synchronize access to single global variable:
__sync_add_and_fetch
__sync_sub_and_fetch

In some architectures such as powerpc these primitives are overhead
intensive. More efficient C11 __atomic builtins are available with
newer GCC versions, see
http://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/_005f_005fatomic-Builtins.html#_005f_005fatomic-Builtins

By substituting the following  __atomic… builtins:
__atomic_add_fetch
__atomic_sub_fetch

the performance improvement on certain architectures such as powerpc can be significant,
around 10% to 15%, over the implementation using __sync builtins while there is only slight uptick on
Intel architectures because it was already enforcing Intel Strongly ordered memory semantics.

The selection of __atomic built-ins can be predicated on the definition of ATOMIC_RELAXED
which Is available on in gcc 4.8.2 and later versions.
From mailing list post https://groups.google.com/forum/#!topic/redis-db/D3k7KmJmYgM

In the file “config.h”, the definition HAVE_ATOMIC is used to indicate
if an architecture on which redis is implemented supports atomic
synchronization primitives.  Powerpc  supports atomic synchronization
primitives, however, it is not listed as one of the architectures
supported in config.h. This patch  adds the __powerpc__ to the list of
architectures supporting these primitives. The improvement of redis
due to the atomic synchronization on powerpc is significant,
around 30% to 40%, over the default implementation using pthreads.

This proposal adds __powerpc__ to the list of architectures designated
to support atomic builtins.
antirez added a commit that referenced this pull request Jun 26, 2014
PowerPC compile-time improvements
@antirez
antirez merged commit f86798b into redis:unstable Jun 26, 2014
@antirez

antirez commented Jun 26, 2014

Copy link
Copy Markdown
Contributor

Thanks Matt, merged. Do you suggest back porting into 2.8?

@mattsta

mattsta commented Jun 26, 2014

Copy link
Copy Markdown
Contributor Author

Yeah, a backport looks safe for these.

These commits improve performance two ways:

  • Redis on PowerPC now uses atomic memory update counters instead of mutex locking counters
  • all memory update counters now prefer C11 __atomic* built-ins when available (if using GCC >= 4.8.2; more optimized per-platform) instead of older __sync* operations.

@mattsta
mattsta deleted the powerpc-fixes branch November 20, 2014 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants