Skip to content

Commit e6a6894

Browse files
committed
Python POC: added async API using CFFI
1 parent d163ba4 commit e6a6894

File tree

13 files changed

+999
-84
lines changed

13 files changed

+999
-84
lines changed

benchmarks/python/all_async_100

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"client": "redispy", "loop": "asyncio", "num_of_tasks": 10, "data_size": 100, "tps": 12261, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 0.757, "get_existing_p90_latency": 0.851, "get_existing_p99_latency": 0.69, "get_existing_average_latency": 0.798, "get_existing_std_dev": 3.012, "get_non_existing_p50_latency": 0.742, "get_non_existing_p90_latency": 0.837, "get_non_existing_p99_latency": 0.679, "get_non_existing_average_latency": 0.757, "get_non_existing_std_dev": 0.145, "set_p50_latency": 0.755, "set_p90_latency": 0.848, "set_p99_latency": 0.687, "set_average_latency": 0.813, "set_std_dev": 4.049}, {"client": "glide_socket", "loop": "asyncio", "num_of_tasks": 10, "data_size": 100, "tps": 14454, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 0.601, "get_existing_p90_latency": 0.92, "get_existing_p99_latency": 0.538, "get_existing_average_latency": 0.689, "get_existing_std_dev": 0.27, "get_non_existing_p50_latency": 0.596, "get_non_existing_p90_latency": 0.916, "get_non_existing_p99_latency": 0.534, "get_non_existing_average_latency": 0.686, "get_non_existing_std_dev": 0.298, "set_p50_latency": 0.598, "set_p90_latency": 0.916, "set_p99_latency": 0.537, "set_average_latency": 0.686, "set_std_dev": 0.295}, {"client": "glide_ffi", "loop": "asyncio", "num_of_tasks": 10, "data_size": 100, "tps": 13885, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 0.704, "get_existing_p90_latency": 0.89, "get_existing_p99_latency": 0.512, "get_existing_average_latency": 0.721, "get_existing_std_dev": 0.427, "get_non_existing_p50_latency": 0.69, "get_non_existing_p90_latency": 0.872, "get_non_existing_p99_latency": 0.494, "get_non_existing_average_latency": 0.706, "get_non_existing_std_dev": 0.532, "set_p50_latency": 0.697, "set_p90_latency": 0.879, "set_p99_latency": 0.5, "set_average_latency": 0.711, "set_std_dev": 0.378}, {"client": "redispy", "loop": "asyncio", "num_of_tasks": 100, "data_size": 100, "tps": 8658, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 6.738, "get_existing_p90_latency": 6.858, "get_existing_p99_latency": 6.635, "get_existing_average_latency": 9.442, "get_existing_std_dev": 93.62, "get_non_existing_p50_latency": 6.729, "get_non_existing_p90_latency": 6.846, "get_non_existing_p99_latency": 6.626, "get_non_existing_average_latency": 7.898, "get_non_existing_std_dev": 60.307, "set_p50_latency": 6.738, "set_p90_latency": 6.856, "set_p99_latency": 6.634, "set_average_latency": 10.012, "set_std_dev": 101.823}, {"client": "glide_socket", "loop": "asyncio", "num_of_tasks": 100, "data_size": 100, "tps": 24707, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 3.972, "get_existing_p90_latency": 4.138, "get_existing_p99_latency": 3.923, "get_existing_average_latency": 4.042, "get_existing_std_dev": 0.513, "get_non_existing_p50_latency": 3.971, "get_non_existing_p90_latency": 4.149, "get_non_existing_p99_latency": 3.922, "get_non_existing_average_latency": 4.037, "get_non_existing_std_dev": 0.485, "set_p50_latency": 3.974, "set_p90_latency": 4.129, "set_p99_latency": 3.925, "set_average_latency": 4.042, "set_std_dev": 0.509}, {"client": "glide_ffi", "loop": "asyncio", "num_of_tasks": 100, "data_size": 100, "tps": 13857, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 7.273, "get_existing_p90_latency": 7.79, "get_existing_p99_latency": 6.2921, "get_existing_average_latency": 7.215, "get_existing_std_dev": 2.779, "get_non_existing_p50_latency": 7.269, "get_non_existing_p90_latency": 7.791, "get_non_existing_p99_latency": 6.2847, "get_non_existing_average_latency": 7.217, "get_non_existing_std_dev": 2.738, "set_p50_latency": 7.275, "set_p90_latency": 7.774, "set_p99_latency": 6.297, "set_average_latency": 7.167, "set_std_dev": 2.257}, {"client": "redispy", "loop": "asyncio", "num_of_tasks": 1000, "data_size": 100, "tps": 1730, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 91.572, "get_existing_p90_latency": 92.46, "get_existing_p99_latency": 90.881, "get_existing_average_latency": 349.823, "get_existing_std_dev": 2868.364, "get_non_existing_p50_latency": 91.556, "get_non_existing_p90_latency": 92.4182, "get_non_existing_p99_latency": 90.865, "get_non_existing_average_latency": 336.043, "get_non_existing_std_dev": 2829.902, "set_p50_latency": 91.577, "set_p90_latency": 92.475, "set_p99_latency": 90.89, "set_average_latency": 348.878, "set_std_dev": 2900.974}, {"client": "glide_socket", "loop": "asyncio", "num_of_tasks": 1000, "data_size": 100, "tps": 17042, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 60.046, "get_existing_p90_latency": 61.8933, "get_existing_p99_latency": 41.5114, "get_existing_average_latency": 58.463, "get_existing_std_dev": 10.693, "get_non_existing_p50_latency": 60.04, "get_non_existing_p90_latency": 61.867, "get_non_existing_p99_latency": 41.516, "get_non_existing_average_latency": 58.406, "get_non_existing_std_dev": 10.671, "set_p50_latency": 60.093, "set_p90_latency": 61.798, "set_p99_latency": 41.5268, "set_average_latency": 58.358, "set_std_dev": 10.445}, {"client": "glide_ffi", "loop": "asyncio", "num_of_tasks": 1000, "data_size": 100, "tps": 12173, "client_count": 1, "is_cluster": true, "get_existing_p50_latency": 81.869, "get_existing_p90_latency": 85.655, "get_existing_p99_latency": 74.679, "get_existing_average_latency": 81.529, "get_existing_std_dev": 7.444, "get_non_existing_p50_latency": 81.87, "get_non_existing_p90_latency": 85.671, "get_non_existing_p99_latency": 74.5847, "get_non_existing_average_latency": 81.507, "get_non_existing_std_dev": 7.602, "set_p50_latency": 81.885, "set_p90_latency": 85.669, "set_p99_latency": 74.5914, "set_average_latency": 81.529, "set_std_dev": 7.391}]

benchmarks/python/glide_sync_100

Lines changed: 0 additions & 1 deletion
This file was deleted.

benchmarks/python/glide_sync_4000

Lines changed: 0 additions & 1 deletion
This file was deleted.

benchmarks/python/python_benchmark.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from glide import (
1919
GlideClientConfiguration,
2020
GlideClusterClientConfiguration,
21+
GlideAsync,
2122
GlideClient,
2223
GlideClusterClient,
2324
Logger,
@@ -197,7 +198,12 @@ def latency_results(prefix, latencies):
197198

198199

199200
async def create_clients(client_count, action):
200-
return [await action() for _ in range(client_count)]
201+
try:
202+
return [await action() for _ in range(client_count)]
203+
except Exception as e:
204+
print(e)
205+
return [action() for _ in range(client_count)]
206+
201207

202208

203209
async def run_clients(
@@ -270,7 +276,7 @@ async def main(
270276
clients = await create_clients(
271277
client_count,
272278
lambda: client_class(
273-
host=host, port=port, decode_responses=True, ssl=use_tls
279+
host=host, port=port, decode_responses=False, ssl=use_tls
274280
),
275281
)
276282

@@ -285,7 +291,10 @@ async def main(
285291
)
286292

287293
for client in clients:
288-
await client.aclose()
294+
try:
295+
await client.aclose()
296+
except Exception:
297+
await client.close()
289298

290299
if clients_to_run == "all" or clients_to_run == "glide":
291300
# Glide Socket
@@ -301,7 +310,28 @@ async def main(
301310
)
302311
await run_clients(
303312
clients,
304-
"glide",
313+
"glide_socket",
314+
event_loop_name,
315+
total_commands,
316+
num_of_concurrent_tasks,
317+
data_size,
318+
is_cluster,
319+
)
320+
if clients_to_run == "all" or clients_to_run == "glide":
321+
# Glide Socket
322+
client_class = GlideAsync
323+
config = GlideClusterClientConfiguration(
324+
[NodeAddress(host=host, port=port)], use_tls=use_tls
325+
) if is_cluster else GlideClientConfiguration(
326+
[NodeAddress(host=host, port=port)], use_tls=use_tls
327+
)
328+
clients = await create_clients(
329+
client_count,
330+
lambda: client_class(config),
331+
)
332+
await run_clients(
333+
clients,
334+
"glide_ffi",
305335
event_loop_name,
306336
total_commands,
307337
num_of_concurrent_tasks,
@@ -311,6 +341,7 @@ async def main(
311341

312342

313343
def number_of_iterations(num_of_concurrent_tasks):
344+
return 100000
314345
return min(max(100000, num_of_concurrent_tasks * 10000), 5000000)
315346

316347

benchmarks/python/python_sync_benchmark.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

benchmarks/python/redispy_sync_100

Lines changed: 0 additions & 1 deletion
This file was deleted.

benchmarks/python/redispy_sync_4000

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)