From a8b1805749f68965846af0f18f9af50c044e788b Mon Sep 17 00:00:00 2001 From: Nikita Smith Date: Tue, 12 Nov 2024 13:17:34 -0800 Subject: [PATCH] updated prof markup usage sites --- src/linker/lnk_debug_info.c | 23 +++++++++-------------- src/linker/lnk_io.c | 10 ++-------- src/linker/pdb_ext/msf_builder.c | 28 ++++++++-------------------- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/src/linker/lnk_debug_info.c b/src/linker/lnk_debug_info.c index 0d09fff8..531dc776 100644 --- a/src/linker/lnk_debug_info.c +++ b/src/linker/lnk_debug_info.c @@ -382,9 +382,7 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, String8List lib_dir ProfEnd(); if (lnk_get_log_status(LNK_Log_Debug) || PROFILE_TELEMETRY) { - U64 total_debug_s_size = 0; - U64 total_debug_t_size = 0; - U64 total_debug_p_size = 0; + U64 total_debug_s_size = 0, total_debug_t_size = 0, total_debug_p_size = 0; for (U64 obj_idx = 0; obj_idx < obj_count; ++obj_idx) { for (LNK_ChunkNode *chunk = debug_s_list_arr[obj_idx].first; chunk != 0; chunk = chunk->next) { total_debug_s_size += chunk->data->u.leaf.size; @@ -396,19 +394,16 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, String8List lib_dir total_debug_p_size += chunk->data->u.leaf.size; } } - String8 total_debug_s_size_string = str8_from_memory_size(scratch.arena, total_debug_s_size); - String8 total_debug_t_size_string = str8_from_memory_size(scratch.arena, total_debug_t_size); - String8 total_debug_p_size_string = str8_from_memory_size(scratch.arena, total_debug_p_size); + + ProfNoteV("Total .debug$S Input Size: %M", total_debug_s_size); + ProfNoteV("Total .debug$T Input Size: %M", total_debug_t_size); + ProfNoteV("Total .debug$P Input Size: %M", total_debug_p_size); + if (lnk_get_log_status(LNK_Log_Debug)) { - lnk_log(LNK_Log_Debug, "[Total .debug$S Input Size %S]", total_debug_s_size_string); - lnk_log(LNK_Log_Debug, "[Total .debug$T Input Size %S]", total_debug_t_size_string); - lnk_log(LNK_Log_Debug, "[Total .debug$P Input Size %S]", total_debug_p_size_string); + lnk_log(LNK_Log_Debug, "[Total .debug$S Input Size %M]", total_debug_s_size); + lnk_log(LNK_Log_Debug, "[Total .debug$T Input Size %M]", total_debug_t_size); + lnk_log(LNK_Log_Debug, "[Total .debug$P Input Size %M]", total_debug_p_size); } -#if PROFILE_TELEMETRY - tmMessage(0, TMMF_ICON_NOTE, "Total .debug$S Input Size: %.*s", str8_varg(total_debug_s_size_string)); - tmMessage(0, TMMF_ICON_NOTE, "Total .debug$T Input Size: %.*s", str8_varg(total_debug_t_size_string)); - tmMessage(0, TMMF_ICON_NOTE, "Total .debug$P Input Size: %.*s", str8_varg(total_debug_p_size_string)); -#endif } // TODO: temp hack, remove when we have null obj with .debug$T diff --git a/src/linker/lnk_io.c b/src/linker/lnk_io.c index aaa3d5bf..377d500e 100644 --- a/src/linker/lnk_io.c +++ b/src/linker/lnk_io.c @@ -165,14 +165,7 @@ lnk_read_data_from_file_path_parallel(TP_Context *tp, Arena *arena, String8Array internal void lnk_write_data_list_to_file_path(String8 path, String8List data) { -#if PROFILE_TELEMETRY - { - Temp scratch = scratch_begin(0, 0); - String8 size_str = str8_from_memory_size(scratch.arena, data.total_size); - ProfBeginDynamic("Write %.*s to %.*s", str8_varg(size_str), str8_varg(path)); - scratch_end(scratch); - } -#endif + ProfBeginV("Write %M to %S", data.total_size, path); B32 is_written = 0; @@ -200,6 +193,7 @@ lnk_write_data_list_to_file_path(String8 path, String8List data) } else { lnk_error(LNK_Error_NoAccess, "don't have access to write to %S", path); } + ProfEnd(); } diff --git a/src/linker/pdb_ext/msf_builder.c b/src/linker/pdb_ext/msf_builder.c index cebfffab..9905147f 100644 --- a/src/linker/pdb_ext/msf_builder.c +++ b/src/linker/pdb_ext/msf_builder.c @@ -998,12 +998,7 @@ exit:; internal MSF_UInt msf_stream_reserve__(MSF_Context *msf, MSF_Stream *stream, MSF_UInt res) { - Temp scratch = scratch_begin(0,0); - -#if PROFILE_TELEMETRY - String8 size_string = str8_from_memory_size2(scratch.arena, res); - ProfBeginDynamic("MSF Reserve %.*s", str8_varg(size_string)); -#endif + ProfBeginV("MSF Reserve %m", res); B32 is_ok = 1; @@ -1019,7 +1014,6 @@ msf_stream_reserve__(MSF_Context *msf, MSF_Stream *stream, MSF_UInt res) AssertAlways(is_ok); } - scratch_end(scratch); ProfEnd(); return is_ok; } @@ -1152,20 +1146,13 @@ THREAD_POOL_TASK_FUNC(msf_write_task) internal B32 msf_stream_write_parallel(TP_Context *tp, MSF_Context *msf, MSF_StreamNumber sn, void *buffer, MSF_UInt buffer_size) { - Temp scratch = scratch_begin(0,0); - -#if PROFILE_TELEMETRY - String8 buffer_size_string = str8_from_memory_size2(scratch.arena, buffer_size); - ProfBeginDynamic("MSF Write Parallel [%.*s]", str8_varg(buffer_size_string)); -#endif + ProfBeginV("MSF Write Parallel %m", buffer_size); MSF_Stream *stream = msf_find_stream(msf, sn); B32 is_write_ok = msf_stream_reserve__(msf, stream, buffer_size); if (is_write_ok) { - Temp scratch = scratch_begin(0,0); - U64 expected_pos = stream->pos + buffer_size; U64 pre_size = Min(AlignPadPow2(stream->pos, msf->page_size), buffer_size); @@ -1176,13 +1163,15 @@ msf_stream_write_parallel(TP_Context *tp, MSF_Context *msf, MSF_StreamNumber sn, U8 *mid_ptr = (U8*)buffer + pre_size; U8 *end_ptr = (U8*)buffer + pre_size + mid_size; - ProfBegin("Write Buffer Pre"); + ProfBeginV("Write Buffer Pre %M", pre_size); B32 is_pre_written = msf_stream_write__(msf, stream, pre_ptr, pre_size); AssertAlways(is_pre_written); ProfEnd(); // write buffer mid if (mid_size > 0) { + Temp scratch = scratch_begin(0,0); + Assert(stream->pos % msf->page_size == 0); Assert(mid_size % msf->page_size == 0); @@ -1199,20 +1188,19 @@ msf_stream_write_parallel(TP_Context *tp, MSF_Context *msf, MSF_StreamNumber sn, U64 after_mid = stream->pos + mid_size; B32 is_seek_ok = msf_stream_seek__(msf, stream, after_mid); AssertAlways(is_seek_ok); + + scratch_end(scratch); } - ProfBegin("Write Buffer End"); + ProfBeginV("Write Buffer End %M", end_size); B32 is_end_ok = msf_stream_write__(msf, stream, end_ptr, end_size); AssertAlways(is_end_ok); ProfEnd(); // did we write bytes correctly? AssertAlways(stream->pos == expected_pos); - - scratch_end(scratch); } - scratch_end(scratch); ProfEnd(); return is_write_ok; }