-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
bpo-32494: Use gdbm_count for dbm_length if possible #19814
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
Conversation
@pitrou Can you please take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing this. This looks mostly good, see below.
When you're done making the requested changes, leave the comment: |
Thank you for the review :) I have made the requested changes; please review again |
Thanks for making the requested changes! @pitrou: please review the changes made to this pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. Thanks for the Py_ssize_t
fix!
By this PR, we can use gdbm_count without exporting a new public API.
I ran the benchmark and it shows noticeable performance enhancement.
This can be measured by invalidating cached value.
Benchmark 1
Run len(kv) after putting new value to invalidate the cache.
| Benchmark | bpo-32494-master | bpo-32494-proposed |
+===========+==================+==============================+
| bpo-32494 | 262 us | 42.2 us: 6.20x faster (-84%) |
+-----------+------------------+------------------------------+
Benchmark2
Remove caching code path to measure without putting new key/value.
+-----------+--------------------+-------------------------------+
| Benchmark | bpo-32494-master-1 | bpo-32494-proposed-1 |
+===========+====================+===============================+
| bpo-32494 | 109 us | 590 ns: 185.32x faster (-99%) |
+-----------+--------------------+-------------------------------+
https://bugs.python.org/issue32494