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

added comment: realloc is already optimized #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/borghash/HashTable.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ cdef class HashTable:
# We must never use kv indexes >= RESERVED, thus we'll never need more capacity either.
cdef size_t capacity = min(new_capacity, <size_t> RESERVED - 1)
self.stats_resize_kv += 1
//realloc is already highly optimized (in linux). By using mremap internally only the peak address space usage is "old size" + "new size", the peak memory usage is "new size".
ThomasWaldmann marked this conversation as resolved.
Show resolved Hide resolved
self.keys = <uint8_t*> realloc(self.keys, capacity * self.ksize * sizeof(uint8_t))
self.values = <uint8_t*> realloc(self.values, capacity * self.vsize * sizeof(uint8_t))
self.kv_capacity = <uint32_t> capacity
Expand Down
Loading