Kevin Carter 60b7b834f9 Enable pypy to be used with swift
The intention of this change is to enable an option to increase swift
performance without changing any of the swift internals. This change is
in-line with documentation published by the good folks at swiftstack and
intel. This change will only effect swift when its installed in a
virtual environment which is a self-imposed limitation such that we're
not messing with the system's default Python.

New Options:
  - A new option `swift_pypy_enabled` has been added to enable or
    disable the pypy interpreter for swift. The default is "false".
  - A new option `swift_pypy_archive` has been added to allow a
    pre-built pypy archive to be downloaded and moved into place. This
    option is a dictionary and contains the URL and SHA256 as keys.

Reference: [ https://software.intel.com/en-us/blogs/2016/05/06/doubling-the-performance-of-openstack-swift-with-no-code-changes ].

Change-Id: I045e8b97d29b96e2c2450761efa1c2668de12a75
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
2016-05-17 04:41:34 +00:00

49 lines
1.6 KiB
YAML

---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Download pre-built pypy
get_url:
url: "{{ swift_pypy_archive['url'] }}"
sha256sum: "{{ swift_pypy_archive['sha256'] }}"
dest: "/var/cache/{{ swift_pypy_archive['url'] | basename }}"
force: yes
- name: Create pypy dir
file:
path: "/opt/pypy-runtime"
state: directory
- name: Set pypy version fact
set_fact:
swift_pypy_version: "{{ swift_pypy_archive['url'] | basename | replace('.tar.bz2', '') }}"
- name: Set pypy env fact
set_fact:
swift_pypy_env: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy"
- name: Unarchive pre-built pypy
unarchive:
src: "/var/cache/{{ swift_pypy_archive['url'] | basename }}"
dest: "/opt/pypy-runtime"
copy: "no"
creates: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy"
- name: Change virtualenv python to pypy
shell: |
virtualenv --python {{ swift_pypy_env }} "{{ swift_venv_bin | dirname }}"
touch "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse"
args:
creates: "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse"