Loading...
--- libmalloc/libmalloc-657.80.3/tools/malloc_replay.cpp
+++ libmalloc/libmalloc-166.220.1/tools/malloc_replay.cpp
@@ -48,9 +48,6 @@
#endif // TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
-// Opt out malloc_replay from PGM
-asm(".section __DATA, __pgm_opt_out\n.long 0\n");
-
static void (*s_funcMagSetThreadIndex)(unsigned int index);
extern "C" int thread_selfcounts(int type, void *buf, size_t nbytes);
@@ -93,9 +90,6 @@
//Our allocator to allocate from a specific zone.
//
malloc_zone_t* s_zone = NULL;
-
-// The magazine number to use for non-replayed allocations.
-#define NON_REPLAY_MAGAZINE 0
static void
configure_ktrace_session(ktrace_session_t s)
@@ -483,10 +477,6 @@
break;
};
- if (s_funcMagSetThreadIndex){
- s_funcMagSetThreadIndex(NON_REPLAY_MAGAZINE);
- }
-
if (config & (CONFIG_REC_COUNTERS | CONFIG_REC_STATS)) {
uint64_t diff = postICount - preICount;
uint16_t instrCount = diff <= UINT16_MAX ? diff : UINT16_MAX;
@@ -581,8 +571,11 @@
if (disposition & (VM_PAGE_QUERY_PAGE_COPIED|VM_PAGE_QUERY_PAGE_DIRTY)) {
magazine.pages_dirty++;
}
- } else if (disposition & VM_PAGE_QUERY_PAGE_PAGED_OUT) {
+
+ magazine.pages_resident++;
+ } else if (disposition & VM_PAGE_QUERY_PAGE_PAGED_OUT){
magazine.pages_dirty++;
+ magazine.pages_resident++;
}
}
}
@@ -688,13 +681,7 @@
s_addressMap.clear();
ktrace_session_destroy(s);
- return true;
-}
-
-static void
-report_results(pdwriter_t perfDataWriter, replay_config_t config)
-{
- //
+ //
//If passed a writer, output performance data.
//
if (perfDataWriter) {
@@ -778,7 +765,8 @@
//Write out the fragmentation in DefaultMallocZone as a primary metric.
//
pdwriter_new_value(perfDataWriter, _DefaultFragMetricName, PDUNIT_CUSTOM(FragmentedPercent), defaultFrag);
- } else if (config & CONFIG_REC_STATS) {
+ pdwriter_record_variable(perfDataWriter, kPCFailureThresholdPctVar, 10);
+ } else if (config & CONFIG_REC_STATS){
printf("\n\n\n");
printf("Call Cycles (mean)\n");
printf("=====================\n");
@@ -830,6 +818,7 @@
// operation enum is indexed from 1, adjust index for mcall_to_name.
snprintf(full_name, sizeof(full_name), "%s-mean", mcall_to_name(i + 1));
pdwriter_new_value(perfDataWriter, full_name, pdunit_instructions, mean);
+ pdwriter_record_variable(perfDataWriter, kPCFailureThresholdPctVar, 100);
} else {
printf("%9s %6llu\n", mcall_to_name(i + 1), mean);
}
@@ -841,7 +830,9 @@
pdwriter_end_extension(perfDataWriter, jsonW);
}
}
-}
+ return true;
+}
+
////////////////////////////////////////////////////////////////////////////////
//
@@ -931,7 +922,6 @@
}
timespec beginTime = {0};
- timespec endTime = {0};
pdwriter_t writer = NULL;
if (outputPerfData) {
@@ -969,34 +959,29 @@
if (!s_funcMagSetThreadIndex) {
printf("\n****Couldn't load mag_set_thread_index, replay won't honor core****\n\n");
- } else {
- s_funcMagSetThreadIndex(NON_REPLAY_MAGAZINE);
}
clock_gettime(CLOCK_MONOTONIC_RAW, &beginTime);
+
if (!run_malloc_replay(inputMTrace, writer, config)) {
return -1;
}
-
- clock_gettime(CLOCK_MONOTONIC_RAW, &endTime);
-
- report_results(writer, config);
} else if (config & CONFIG_CONVERT_FILE) {
clock_gettime(CLOCK_MONOTONIC_RAW, &beginTime);
if (!run_ktrace(inputKtrace, outputMTrace)) {
printf("\n****Couldn't record mtrace file.\n");
}
- clock_gettime(CLOCK_MONOTONIC_RAW, &endTime);
} else if (outputMTrace) {
clock_gettime(CLOCK_MONOTONIC_RAW, &beginTime);
if (!run_ktrace(NULL, outputMTrace)) {
printf("\n****Couldn't record mtrace file.\n");
}
+ }
+
+ if (beginTime.tv_sec) {
+ timespec endTime;
clock_gettime(CLOCK_MONOTONIC_RAW, &endTime);
- }
-
- if (beginTime.tv_sec) {
printf("\n\nRuntime: %ld ms\n", ((endTime.tv_sec - beginTime.tv_sec) * 1000) + (endTime.tv_nsec - beginTime.tv_nsec)/1000000);
}