Last active
October 29, 2016 02:21
-
-
Save stevenhao/4eb92c456cffd65cc2dee47a6e128b74 to your computer and use it in GitHub Desktop.
mdriver patch for peak util
This file contains 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/mymalloc/mdriver.c b/mymalloc/mdriver.c | |
index edbd17d..6bea5f8 100644 | |
--- a/mymalloc/mdriver.c | |
+++ b/mymalloc/mdriver.c | |
@@ -502,6 +502,9 @@ static double eval_mm_util(const malloc_impl_t *impl, trace_t *trace, int tracen | |
char *p; | |
char *newp, *oldp; | |
▫ | |
+ double U_numerator, U_denominator, U; | |
+ double peak_U = 1; // peak util: min U_numerator/U_denominator over time | |
+ | |
/* initialize the heap and the mm malloc package */ | |
mem_reset_brk(); | |
if (impl->init() < 0) { | |
@@ -572,13 +575,15 @@ static double eval_mm_util(const malloc_impl_t *impl, trace_t *trace, int tracen | |
default: | |
app_error("Nonexistent request type in eval_mm_util"); | |
} | |
+ | |
+ U_numerator = (double)((max_total_size > MEM_ALLOWANCE) ? max_total_size : MEM_ALLOWANCE); | |
+ heap_size = mem_heapsize(); | |
+ U_denominator = (double)(heap_size > MEM_ALLOWANCE ? heap_size: MEM_ALLOWANCE); | |
+ U = (double)U_numerator / (double)U_denominator; | |
+ peak_U = (U < peak_U) ? U : peak_U; | |
} | |
- max_total_size = (max_total_size > MEM_ALLOWANCE) ? | |
- max_total_size : MEM_ALLOWANCE; | |
- heap_size = mem_heapsize(); | |
- heap_size = (heap_size > MEM_ALLOWANCE) ? | |
- heap_size : MEM_ALLOWANCE; | |
- return ((double)max_total_size / (double)heap_size); | |
+ | |
+ return peak_U; | |
} | |
▫ | |
static void mem_op(volatile char *raddr, volatile char *waddr) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment