Don't allocate new memory for htkeys on adding new item if the dict has deleted slots#1200
Don't allocate new memory for htkeys on adding new item if the dict has deleted slots#1200asvetlov merged 11 commits intoaio-libs:masterfrom
Conversation
CodSpeed Performance ReportMerging #1200 will degrade performances by 33.41%Comparing Summary
Benchmarks breakdown
|
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1200 +/- ##
=======================================
Coverage 98.32% 98.32%
=======================================
Files 27 27
Lines 3874 3874
Branches 706 706
=======================================
Hits 3809 3809
Misses 18 18
Partials 47 47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| for (Py_ssize_t i = 0; i < nentries; ++i, ++old_ep) { | ||
| if (old_ep->identity != NULL) { | ||
| if (new_ep != old_ep) { | ||
| *new_ep++ = *old_ep; |
There was a problem hiding this comment.
This looks like it might be the cause of the segfault
There was a problem hiding this comment.
does new_ep always need to be incremented here even if != ?
There was a problem hiding this comment.
maybe new_ep == old_ep, first entry to be overwritten by later entries, new_ep now at wrong position, anything after writes to the wrong memory address...
There was a problem hiding this comment.
I think no.
The loop iterates over all elements and overwrites empty ones with next items.
It basically deletes entries with identity == NULL and collapses unused memory holes
It is an optimization that eliminates
malloc()/free()calls for the keys structure if it could be collapsed in-place.