Created
February 13, 2020 20:25
-
-
Save colesbury/f3487f9d4f89dbf3497bcff2ca454458 to your computer and use it in GitHub Desktop.
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
diff --git a/src/alloc.c b/src/alloc.c | |
index b080e6f..7a8f030 100644 | |
--- a/src/alloc.c | |
+++ b/src/alloc.c | |
@@ -10,10 +10,12 @@ terms of the MIT license. A copy of the license can be found in the file | |
#include <string.h> // memset, memcpy, strlen | |
#include <stdlib.h> // malloc, exit | |
+#include <stdio.h> | |
+#include <unistd.h> | |
-#define MI_IN_ALLOC_C | |
-#include "alloc-override.c" | |
-#undef MI_IN_ALLOC_C | |
+// #define MI_IN_ALLOC_C | |
+// #include "alloc-override.c" | |
+// #undef MI_IN_ALLOC_C | |
// ------------------------------------------------------ | |
// Allocation | |
@@ -320,6 +322,7 @@ static mi_decl_noinline void _mi_free_block_mt(mi_page_t* page, mi_block_t* bloc | |
if (mi_unlikely(use_delayed)) { | |
// racy read on `heap`, but ok because MI_DELAYED_FREEING is set (see `mi_heap_delete` and `mi_heap_collect_abandon`) | |
mi_heap_t* const heap = mi_page_heap(page); | |
+ usleep(1000 * 200); | |
mi_assert_internal(heap != NULL); | |
if (heap != NULL) { | |
// add to the delayed free list of this heap. (do this atomically as the lock only protects heap memory validity) | |
diff --git a/src/heap.c b/src/heap.c | |
index 900cef6..f12f504 100644 | |
--- a/src/heap.c | |
+++ b/src/heap.c | |
@@ -10,6 +10,8 @@ terms of the MIT license. A copy of the license can be found in the file | |
#include "mimalloc-atomic.h" | |
#include <string.h> // memset, memcpy | |
+#include <unistd.h> | |
+#include <stdio.h> | |
/* ----------------------------------------------------------- | |
@@ -313,8 +315,9 @@ static void mi_heap_absorb(mi_heap_t* heap, mi_heap_t* from) { | |
if (from==NULL || from->page_count == 0) return; | |
// reduce the size of the delayed frees | |
+ usleep(1000 * 300); | |
_mi_heap_delayed_free(from); | |
- | |
+ | |
// transfer all pages by appending the queues; this will set a new heap field | |
// so threads may do delayed frees in either heap for a while. | |
for (size_t i = 0; i <= MI_BIN_FULL; i++) { | |
@@ -331,6 +334,7 @@ static void mi_heap_absorb(mi_heap_t* heap, mi_heap_t* from) { | |
// turns out to be ok as `_mi_heap_delayed_free` only visits the list and calls a | |
// the regular `_mi_free_delayed_block` which is safe. | |
_mi_heap_delayed_free(from); | |
+ usleep(1000 * 600); | |
mi_assert_internal(from->thread_delayed_free == NULL); | |
// and reset the `from` heap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment