Skip to content

Commit

Permalink
evidently threading is slower, pending gevent/greenify
Browse files Browse the repository at this point in the history
  • Loading branch information
kentslaney committed Jan 20, 2024
1 parent c3ff9ae commit 5a709ae
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,32 @@ jobs:
./misc/travis/gotest.sh
- name: Stop memcached servers
run: ./misc/memcached_server stop

reference:
runs-on: ubuntu-latest
strategy:
matrix:
pyver: ["3.12"]

steps:
- uses: actions/checkout@v2
- name: Setup system dependencies
run: |
sudo apt-get update
sudo apt-get -y install memcached libmemcached-dev g++
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.pyver }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools future python-memcached pylibmc
- name: Start memcached servers
run: ./misc/memcached_server start
- name: Run benchmark
run: |
./misc/travis/benchmark.sh
- name: Stop memcached servers
run: ./misc/memcached_server stop
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif (NOT CMAKE_BUILD_TYPE)

set(CMAKE_CXX_FLAGS_COMMON "-Wall -fno-rtti -fno-exceptions")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g2 ${CMAKE_CXX_FLAGS_COMMON} -fsanitize=thread" CACHE STRING "CXX DEBUG FLAGS" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g2 ${CMAKE_CXX_FLAGS_COMMON}" CACHE STRING "CXX DEBUG FLAGS" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 ${CMAKE_CXX_FLAGS_COMMON}" CACHE STRING "CXX RELEASE FLAGS" FORCE)
set(CMAKE_INSTALL_INCLUDE include CACHE PATH "Output directory for header files")
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
Expand Down
10 changes: 7 additions & 3 deletions misc/runbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(self):
def __unicode__(self):
m = self.mean()
d = self.stddev()
fmt = u"%.3gs, σ=%.3g, n=%d, snr=%.3g:%.3g".__mod__
fmt = u"%.3gs, \u03C3=%.3g, n=%d, snr=%.3g:%.3g".__mod__
return fmt((m, d, len(self.laps)) + ratio(m, d))

__str__ = __unicode__
Expand Down Expand Up @@ -139,7 +139,7 @@ def bench_get(mc, key, data):

@benchmark_method
def bench_set(mc, key, data):
if isinstance(mc.mc, libmc.Client):
if isinstance(mc.mc, libmc.Client) or isinstance(mc.mc, libmc.ThreadedClient):
if not mc.set(key, data):
logger.warn('%r.set(%r, ...) fail', mc, key)
else:
Expand All @@ -156,7 +156,7 @@ def bench_get_multi(mc, keys, pairs):
@benchmark_method
def bench_set_multi(mc, keys, pairs):
ret = mc.set_multi(pairs)
if isinstance(mc.mc, libmc.Client):
if isinstance(mc.mc, libmc.Client) or isinstance(mc.mc, libmc.ThreadedClient):
if not ret:
logger.warn('%r.set_multi fail', mc)
else:
Expand Down Expand Up @@ -235,6 +235,10 @@ def make_pylibmc_client(servers, **kw):
name='libmc(md5 / ketama / nodelay / nonblocking, from douban)',
factory=lambda: Prefix(__import__('libmc').Client(servers, comp_threshold=4000), 'libmc1')
),
Participant(
name='libmc(md5 / ketama / nodelay / nonblocking / threaded, from douban)',
factory=lambda: Prefix(__import__('libmc').ThreadedClient(servers, comp_threshold=4000), 'libmc2')
),
]


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)
os._exit(errno)


setup(
Expand Down

0 comments on commit 5a709ae

Please sign in to comment.