Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow threading on get operations #103

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

GodTamIt
Copy link
Contributor

Before:

Get performance: 4194304 items in 13.99276754213497 seconds
Get performance multi-thread: 4194304 items in 13.610933708958328 seconds

After:

Get performance: 4194304 items in 14.377041833940893 seconds
Get performance multi-thread: 4194304 items in 5.503023374825716 seconds

Before:

```
Get performance: 4194304 items in 13.99276754213497 seconds
Get performance multi-thread: 4194304 items in 13.610933708958328 seconds
```

After:

```
Get performance: 4194304 items in 14.377041833940893 seconds
Get performance multi-thread: 4194304 items in 5.503023374825716 seconds
```
@Congyuwang
Copy link
Owner

So, the improvement is mainly on batch_get right? Since batch_get usually needs more time. 👍

@GodTamIt
Copy link
Contributor Author

Right, batch gets can run for an extended amount of time without having to re-acquire the GIL to access Python objects.

Individual get()s do not because they need the GIL to access the Python object values for the key and value every time. So if you do a get for a bunch of items, you're going to be contending on the lock for each iteration.

@GodTamIt
Copy link
Contributor Author

For posterity, I'll comment here a few more details:

  • The reason we don't see a 4x performance increase here is because the benchmark iterates through the results to verify them (which requires the GIL).
  • The numbers were run on a M2 MacBook Pro 16.

@Congyuwang Congyuwang merged commit 3e64dc4 into Congyuwang:main Dec 13, 2023
24 checks passed
@GodTamIt GodTamIt deleted the allow-threads-get branch December 13, 2023 16:16
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