Skip to content

Commit ed6e4d6

Browse files
committed
Add perf traces
1 parent d759388 commit ed6e4d6

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

runtime/coreclr-bridge.m

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -484,27 +484,29 @@
484484
xamarin_bridge_vm_initialize (int propertyCount, const char **propertyKeys, const char **propertyValues)
485485
{
486486
// TODO: Remove fprintf logs
487-
fprintf (stderr, "xamarin_bridge_vm_initialize: ENTRY propertyCount=%i\n", propertyCount);
487+
// fprintf (stderr, "xamarin_bridge_vm_initialize: ENTRY propertyCount=%i\n", propertyCount);
488488
int rv;
489489

490490
int combinedPropertyCount = 0;
491491
const char **combinedPropertyKeys = NULL;
492492
const char **combinedPropertyValues = NULL;
493493

494-
fprintf (stderr, "xamarin_bridge_vm_initialize: calling xamarin_bridge_compute_properties\n");
494+
// fprintf (stderr, "xamarin_bridge_vm_initialize: calling xamarin_bridge_compute_properties\n");
495495
xamarin_bridge_compute_properties (propertyCount, propertyKeys, propertyValues, &combinedPropertyCount, &combinedPropertyKeys, &combinedPropertyValues);
496-
fprintf (stderr, "xamarin_bridge_vm_initialize: xamarin_bridge_compute_properties returned, combinedPropertyCount=%i\n", combinedPropertyCount);
496+
// fprintf (stderr, "xamarin_bridge_vm_initialize: xamarin_bridge_compute_properties returned, combinedPropertyCount=%i\n", combinedPropertyCount);
497497

498498
const char *executablePath = [[[[NSBundle mainBundle] executableURL] path] UTF8String];
499499

500-
fprintf (stderr, "xamarin_vm_initialize: executablePath: %s\n", executablePath);
501-
fprintf (stderr, "xamarin_vm_initialize: xamarin_executable_name: %s\n", xamarin_executable_name);
502-
fprintf (stderr, "xamarin_vm_initialize: combinedPropertyCount: %i\n", combinedPropertyCount);
503-
for (int i = 0; i < combinedPropertyCount; i++) {
504-
fprintf (stderr, " Property[%i]: %s = %s\n", i, combinedPropertyKeys[i], combinedPropertyValues[i]);
505-
}
506-
fprintf (stderr, "xamarin_vm_initialize: calling coreclr_initialize\n");
507-
fprintf (stderr, "xamarin_vm_initialize: calling coreclr_initialize\n");
500+
// fprintf (stderr, "xamarin_vm_initialize: executablePath: %s\n", executablePath);
501+
// fprintf (stderr, "xamarin_vm_initialize: xamarin_executable_name: %s\n", xamarin_executable_name);
502+
// fprintf (stderr, "xamarin_vm_initialize: combinedPropertyCount: %i\n", combinedPropertyCount);
503+
// for (int i = 0; i < combinedPropertyCount; i++) {
504+
// fprintf (stderr, " Property[%i]: %s = %s\n", i, combinedPropertyKeys[i], combinedPropertyValues[i]);
505+
// }
506+
// fprintf (stderr, "xamarin_vm_initialize: calling coreclr_initialize\n");
507+
// struct timespec ts_init;
508+
// clock_gettime (CLOCK_MONOTONIC, &ts_init);
509+
// fprintf (stderr, "[PERF] Before coreclr_initialize at %lld.%09ld\n", (long long)ts_init.tv_sec, ts_init.tv_nsec);
508510

509511
rv = coreclr_initialize (
510512
executablePath,
@@ -516,7 +518,11 @@
516518
&coreclr_domainId
517519
);
518520

519-
fprintf (stderr, "xamarin_vm_initialize: coreclr_initialize returned rv=%i\n", rv);
521+
// struct timespec ts_after_init;
522+
// clock_gettime (CLOCK_MONOTONIC, &ts_after_init);
523+
// fprintf (stderr, "[PERF] After coreclr_initialize at %lld.%09ld\n", (long long)ts_after_init.tv_sec, ts_after_init.tv_nsec);
524+
525+
// fprintf (stderr, "xamarin_vm_initialize: coreclr_initialize returned rv=%i\n", rv);
520526

521527
for (int i = 0; i < combinedPropertyCount; i++) {
522528
free ((void *) combinedPropertyKeys [i]);
@@ -525,7 +531,7 @@
525531
free ((void *) combinedPropertyKeys);
526532
free ((void *) combinedPropertyValues);
527533

528-
fprintf (stderr, "xamarin_vm_initialize (%i, %p, %p): rv: %i (0x%x) domainId: %i handle: %p\n", combinedPropertyCount, combinedPropertyKeys, combinedPropertyValues, rv, rv, coreclr_domainId, coreclr_handle);
534+
// fprintf (stderr, "xamarin_vm_initialize (%i, %p, %p): rv: %i (0x%x) domainId: %i handle: %p\n", combinedPropertyCount, combinedPropertyKeys, combinedPropertyValues, rv, rv, coreclr_domainId, coreclr_handle);
529535

530536
return rv == 0;
531537
}

runtime/monotouch-main.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ - (void) memoryWarning: (NSNotification *) sender
237237
int
238238
xamarin_main (int argc, char *argv[], enum XamarinLaunchMode launch_mode)
239239
{
240+
struct timespec ts_main_start;
241+
clock_gettime (CLOCK_MONOTONIC, &ts_main_start);
242+
fprintf (stderr, "[PERF] StartupTotal %lld.%09ld\n", (long long)ts_main_start.tv_sec, ts_main_start.tv_nsec);
243+
240244
#ifdef DEBUG
241245
monotouch_start_launch_timer ();
242246
#endif
@@ -413,6 +417,11 @@ - (void) memoryWarning: (NSNotification *) sender
413417
xamarin_bridge_initialize ();
414418

415419
xamarin_initialize ();
420+
421+
struct timespec ts_main_end;
422+
clock_gettime (CLOCK_MONOTONIC, &ts_main_end);
423+
fprintf (stderr, "[PERF] RuntimeInit %lld.%09ld\n", (long long)ts_main_end.tv_sec, ts_main_end.tv_nsec);
424+
416425
DEBUG_LAUNCH_TIME_PRINT ("\tmonotouch init time");
417426

418427
if (xamarin_register_assemblies != NULL)

runtime/monovm-bridge.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,16 @@
344344

345345
xamarin_initialize_runtime_config ();
346346

347+
// struct timespec ts_init;
348+
// clock_gettime (CLOCK_MONOTONIC, &ts_init);
349+
// fprintf (stderr, "[PERF] Before monovm_initialize at %lld.%09ld\n", (long long)ts_init.tv_sec, ts_init.tv_nsec);
350+
347351
rv = monovm_initialize (propertyCount, propertyKeys, propertyValues);
348352

353+
// struct timespec ts_after_init;
354+
// clock_gettime (CLOCK_MONOTONIC, &ts_after_init);
355+
// fprintf (stderr, "[PERF] After monovm_initialize at %lld.%09ld\n", (long long)ts_after_init.tv_sec, ts_after_init.tv_nsec);
356+
349357
LOG_MONOVM (stderr, "xamarin_vm_initialize (%i, %p, %p): rv: %i\n", propertyCount, propertyKeys, propertyValues, rv);
350358

351359
return rv == 0;

runtime/runtime.m

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,9 +2474,9 @@ size_t get_image_size(void* base_address)
24742474
bool get_native_code_data(const struct host_runtime_contract_native_code_context* context, struct host_runtime_contract_native_code_data* data)
24752475
{
24762476
// TODO: Remove fprintf logs
2477-
fprintf (stderr, "R2R: get_native_code_data called for assembly: %s, composite: %s\n",
2478-
context ? context->assembly_path : "(null)",
2479-
context ? context->owner_composite_name : "(null)");
2477+
// fprintf (stderr, "R2R: get_native_code_data called for assembly: %s, composite: %s\n",
2478+
// context ? context->assembly_path : "(null)",
2479+
// context ? context->owner_composite_name : "(null)");
24802480

24812481
if (!context || !data || !context->assembly_path || !context->owner_composite_name)
24822482
return false;
@@ -2493,30 +2493,30 @@ bool get_native_code_data(const struct host_runtime_contract_native_code_context
24932493
if (written <= 0 || (size_t)written >= sizeof(r2r_path) - dir_len)
24942494
return false;
24952495

2496-
fprintf (stderr, "R2R: Attempting to load R2R image from: %s\n", r2r_path);
2496+
// fprintf (stderr, "R2R: Attempting to load R2R image from: %s\n", r2r_path);
24972497

24982498
void* handle = dlopen(r2r_path, RTLD_LAZY | RTLD_LOCAL);
24992499
if (handle == NULL) {
2500-
fprintf (stderr, "R2R: Failed to dlopen R2R image: %s\n", dlerror ());
2500+
// fprintf (stderr, "R2R: Failed to dlopen R2R image: %s\n", dlerror ());
25012501
return false;
25022502
}
25032503

2504-
fprintf (stderr, "R2R: Successfully loaded R2R image, looking for RTR_HEADER symbol\n");
2504+
// fprintf (stderr, "R2R: Successfully loaded R2R image, looking for RTR_HEADER symbol\n");
25052505

25062506
void* r2r_header = dlsym(handle, "RTR_HEADER");
25072507
if (r2r_header == NULL)
25082508
{
2509-
fprintf (stderr, "R2R: Failed to find RTR_HEADER symbol: %s\n", dlerror ());
2509+
// fprintf (stderr, "R2R: Failed to find RTR_HEADER symbol: %s\n", dlerror ());
25102510
dlclose(handle);
25112511
return false;
25122512
}
25132513

2514-
fprintf (stderr, "R2R: Found RTR_HEADER at %p\n", r2r_header);
2514+
// fprintf (stderr, "R2R: Found RTR_HEADER at %p\n", r2r_header);
25152515

25162516
Dl_info info;
25172517
if (dladdr(r2r_header, &info) == 0)
25182518
{
2519-
fprintf (stderr, "R2R: Failed to get dladdr info for RTR_HEADER\n");
2519+
// fprintf (stderr, "R2R: Failed to get dladdr info for RTR_HEADER\n");
25202520
dlclose(handle);
25212521
return false;
25222522
}
@@ -2526,8 +2526,8 @@ bool get_native_code_data(const struct host_runtime_contract_native_code_context
25262526
data->image_size = get_image_size(info.dli_fbase);
25272527
data->image_base = info.dli_fbase;
25282528

2529-
fprintf (stderr, "R2R: Successfully loaded R2R data - header: %p, base: %p, size: %lu\n",
2530-
data->r2r_header_ptr, data->image_base, (unsigned long)data->image_size);
2529+
// fprintf (stderr, "R2R: Successfully loaded R2R data - header: %p, base: %p, size: %lu\n",
2530+
// data->r2r_header_ptr, data->image_base, (unsigned long)data->image_size);
25312531

25322532
return true;
25332533
}

0 commit comments

Comments
 (0)