Skip to content

Commit 740b49b

Browse files
Merge pull request #36 from MichaelDietzel/patch-1
added comment: realloc is already optimized
2 parents 56ce549 + e896b6d commit 740b49b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/borghash/HashTable.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ cdef class HashTable:
263263
# We must never use kv indexes >= RESERVED, thus we'll never need more capacity either.
264264
cdef size_t capacity = min(new_capacity, <size_t> RESERVED - 1)
265265
self.stats_resize_kv += 1
266+
# realloc is already highly optimized (in Linux). By using mremap internally only the peak address space usage is "old size" + "new size", while the peak memory usage is only "new size".
266267
self.keys = <uint8_t*> realloc(self.keys, capacity * self.ksize * sizeof(uint8_t))
267268
self.values = <uint8_t*> realloc(self.values, capacity * self.vsize * sizeof(uint8_t))
268269
self.kv_capacity = <uint32_t> capacity

0 commit comments

Comments
 (0)