bpo-32494: Use gdbm_count for dbm_length if possible#19814
Merged
pitrou merged 6 commits intopython:masterfrom May 1, 2020
Merged
bpo-32494: Use gdbm_count for dbm_length if possible#19814pitrou merged 6 commits intopython:masterfrom
pitrou merged 6 commits intopython:masterfrom
Conversation
Member
Author
|
@pitrou Can you please take a look? |
pitrou
requested changes
May 1, 2020
Member
pitrou
left a comment
There was a problem hiding this comment.
Thank you for doing this. This looks mostly good, see below.
|
When you're done making the requested changes, leave the comment: |
Member
Author
|
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. |
pitrou
approved these changes
May 1, 2020
Member
pitrou
left a comment
There was a problem hiding this comment.
+1. Thanks for the Py_ssize_t fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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