Explorar o código

Remove timing profiler

Fabian %!s(int64=6) %!d(string=hai) anos
pai
achega
94b0376186

+ 0 - 10
src/browser/print_stats.js

@@ -48,16 +48,6 @@ const print_stats = {
             "TLB_GLOBAL_FULL",
         ];
 
-        const total = cpu.wm.exports["_profiler_get_total"]();
-
-        for(let i = 0; i < names.length; i++)
-        {
-            let stat = cpu.wm.exports["_profiler_get_time"](i) / total;
-            text += names[i] + "=" + stat.toFixed(2) + " ";
-        }
-
-        text += "\n";
-
         for(let i = 0; i < stat_names.length; i++)
         {
             let stat = cpu.wm.exports["_profiler_stat_get"](i);

+ 0 - 10
src/cpu.js

@@ -1122,9 +1122,6 @@ CPU.prototype.do_run = function()
 {
     this.wm.exports["_profiler_stat_increment_do_run"]();
 
-    // Idle time is when no instructions are being executed
-    this.wm.exports["_profiler_end"](P_IDLE);
-
     /** @type {number} */
     var start = v86.microtick();
 
@@ -1147,8 +1144,6 @@ CPU.prototype.do_run = function()
 
         now = v86.microtick();
     }
-
-    this.wm.exports["_profiler_start"](P_IDLE);
 };
 
 let do_many_cycles_count = 0;
@@ -1157,7 +1152,6 @@ let do_many_cycles_total = 0;
 CPU.prototype.do_many_cycles = function()
 {
     // Capture the total time we were executing instructions
-    this.wm.exports["_profiler_start"](P_DO_MANY_CYCLES);
     this.coverage_logger.log_start();
 
     if(ENABLE_PROFILER)
@@ -1180,10 +1174,6 @@ CPU.prototype.do_many_cycles = function()
     }
 
     this.coverage_logger.log_end();
-    this.wm.exports["_profiler_end"](P_DO_MANY_CYCLES);
-    this.wm.exports["_profiler_end"](P_GEN_INSTR);
-    this.wm.exports["_profiler_end"](P_RUN_FROM_CACHE);
-    this.wm.exports["_profiler_end"](P_RUN_INTERPRETED);
 };
 
 /** @export */

+ 0 - 1
src/native/config.h

@@ -38,7 +38,6 @@
 #endif
 
 #define ENABLE_PROFILER 0
-#define ENABLE_PROFILER_TIMES 0
 #define ENABLE_PROFILER_OPSTATS 0
 
 // Note: needs to be enabled here and in config.js

+ 0 - 8
src/native/cpu.c

@@ -624,7 +624,6 @@ uint32_t jit_hot_hash_page(uint32_t page)
 
 static void jit_run_interpreted(int32_t phys_addr)
 {
-    profiler_start(P_RUN_INTERPRETED);
     profiler_stat_increment(S_RUN_INTERPRETED);
 
     jit_block_boundary = false;
@@ -648,8 +647,6 @@ static void jit_run_interpreted(int32_t phys_addr)
 #endif
         run_instruction(opcode | !!*is_32 << 8);
     }
-
-    profiler_end(P_RUN_INTERPRETED);
 }
 
 bool has_flat_segmentation(void)
@@ -1495,7 +1492,6 @@ __attribute__((noinline))
 static void jit_generate(uint32_t phys_addr)
 {
     profiler_stat_increment(S_COMPILE);
-    profiler_start(P_GEN_INSTR);
 
     // don't immediately retry to compile
     hot_code_addresses[jit_hot_hash_page(phys_addr >> 12)] = 0;
@@ -1509,7 +1505,6 @@ static void jit_generate(uint32_t phys_addr)
     // populate basic_blocks
     if(!jit_find_basic_blocks(phys_addr, &requires_loop_limit))
     {
-        profiler_end(P_GEN_INSTR);
         dbg_log("No basic blocks, not generating code");
         *instruction_pointer = start;
         return;
@@ -1732,7 +1727,6 @@ static void jit_generate(uint32_t phys_addr)
             first_opcode, state_flags);
 
     profiler_stat_increment(S_COMPILE_SUCCESS);
-    profiler_end(P_GEN_INSTR);
 
     *instruction_pointer = start;
 }
@@ -1759,7 +1753,6 @@ void cycle_internal()
 
     if(entry && !entry->pending)
     {
-        profiler_start(P_RUN_FROM_CACHE);
         profiler_stat_increment(S_RUN_FROM_CACHE);
 
         int32_t initial_tsc = *timestamp_counter;
@@ -1778,7 +1771,6 @@ void cycle_internal()
         UNUSED(old_start_address);
 
         profiler_stat_increment_by(S_RUN_FROM_CACHE_STEPS, *timestamp_counter - initial_tsc);
-        profiler_end(P_RUN_FROM_CACHE);
     }
     else
     {

+ 0 - 82
src/native/profiler/profiler.c

@@ -9,93 +9,16 @@
 
 #if ENABLE_PROFILER
 
-struct profiler_data profiler_arr[PROFILER_NAME_COUNT] = {{0, 0, false}};
 struct profiler_stat profiler_stat_arr[PROFILER_STAT_COUNT] = {{0}};
-double profiler_init_time = 0;
 
 void profiler_init(void)
 {
-    profiler_init_time = get_time();
-
-    for(uint32_t i = 0; i < PROFILER_NAME_COUNT; i++)
-    {
-        struct profiler_data *entry = &profiler_arr[i];
-        entry->total = 0;
-        entry->current_start = 0;
-        entry->capturing = false;
-    }
-
     for(uint32_t i = 0; i < PROFILER_STAT_COUNT; i++)
     {
         profiler_stat_arr[i].count = 0;
     }
 }
 
-void profiler_start(enum profile_name name)
-{
-#if ENABLE_PROFILER_TIMES
-    struct profiler_data *entry = &profiler_arr[name];
-    assert(!entry->capturing);
-
-    entry->current_start = get_time();
-    entry->capturing = true;
-#endif
-    UNUSED(name);
-}
-
-void profiler_end(enum profile_name name)
-{
-#if ENABLE_PROFILER_TIMES
-    struct profiler_data *entry = &profiler_arr[name];
-    if(entry->capturing)
-    {
-        entry->total += get_time() - entry->current_start;
-        entry->current_start = 0;
-        entry->capturing = false;
-    }
-#endif
-    UNUSED(name);
-}
-
-void profiler_print(void)
-{
-#if ENABLE_PROFILER_TIMES
-    static const char *profiler_names[] = {
-        "IDLE",
-        "DO_MANY_CYCLES",
-        "GEN_INSTR",
-        "RUN_FROM_CACHE",
-        "RUN_INTERPRETED",
-    };
-
-    double init_elapsed = get_time() - profiler_init_time;
-    printf("\nElapsed: %d\n", (int32_t) init_elapsed);
-    for(int32_t i = 0; i < PROFILER_NAME_COUNT; i++)
-    {
-        double cur_total = profiler_arr[i].total;
-        printf(profiler_names[i]);
-        printf(
-            "\nIndex:\t%d"
-            "\nTotal:\t%d"
-            "\nPercentage:\t%d%%\n",
-            i,
-            (int32_t) cur_total,
-            (int32_t) (100 * cur_total / init_elapsed)
-        );
-    }
-#endif
-}
-
-int32_t profiler_get_time(enum profile_name name)
-{
-    return profiler_arr[name].total;
-}
-
-int32_t profiler_get_total(void)
-{
-    return get_time() - profiler_init_time;
-}
-
 void profiler_stat_increment(enum stat_name stat)
 {
     profiler_stat_increment_by(stat, 1);
@@ -121,11 +44,6 @@ int32_t profiler_stat_get(enum stat_name stat)
 // Disable profiler
 
 void profiler_init(void) {}
-void profiler_start(enum profile_name name) { UNUSED(name); }
-void profiler_end(enum profile_name name) { UNUSED(name); }
-void profiler_print(void) {}
-int32_t profiler_get_time(enum profile_name name) { UNUSED(name); return 0; }
-int32_t profiler_get_total(void) { return 0; }
 void profiler_stat_increment(enum stat_name stat) { UNUSED(stat); }
 void profiler_stat_increment_by(enum stat_name stat, int32_t by) { UNUSED(stat); UNUSED(by); }
 void profiler_stat_increment_do_run() {}

+ 0 - 22
src/native/profiler/profiler.h

@@ -3,25 +3,6 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#define PROFILER_NAME_COUNT 5
-
-struct profiler_data {
-    double total;
-    double current_start;
-    bool capturing;
-};
-
-extern struct profiler_data profiler_arr[PROFILER_NAME_COUNT];
-
-enum profile_name {
-    P_IDLE,
-    P_DO_MANY_CYCLES,
-    P_GEN_INSTR,
-    P_RUN_FROM_CACHE,
-    P_RUN_INTERPRETED,
-};
-
-
 enum stat_name {
     S_COMPILE,
     S_COMPILE_SUCCESS,
@@ -65,9 +46,6 @@ struct profiler_stat {
 extern struct profiler_stat profiler_stat_arr[PROFILER_STAT_COUNT];
 
 void profiler_init(void);
-void profiler_start(enum profile_name name);
-void profiler_end(enum profile_name name);
-void profiler_print(void);
 
 void profiler_stat_increment(enum stat_name stat);
 void profiler_stat_increment_by(enum stat_name stat, int32_t by);

+ 0 - 21
tests/benchmark/linux-boot.js

@@ -47,13 +47,6 @@ emulator.add_listener("serial0-output-char", function(chr)
         emulator.stop();
 
         const cpu = emulator.v86.cpu;
-        const names = [
-            "IDLE",
-            "DO_MANY_CYCLES",
-            "GEN_INSTR",
-            "RUN_FROM_CACHE",
-            "RUN_INTERPRETED",
-        ];
         const stat_names = [
             "COMPILE",
             "COMPILE_SUCCESS",
@@ -66,22 +59,8 @@ emulator.add_listener("serial0-output-char", function(chr)
             "TLB_FULL",
             "TLB_GLOBAL_FULL",
         ];
-        const total = cpu.wm.exports["_profiler_get_total"]();
         let text = "";
 
-        if(!total)
-        {
-            console.error("Warning: No elapsed time measured, did you set ENABLE_PROFILER?");
-        }
-
-        for(let i = 0; i < names.length; i++)
-        {
-            let stat = cpu.wm.exports["_profiler_get_time"](i) / total;
-            text += names[i] + "=" + stat.toFixed(2) + " ";
-        }
-
-        text += "\n";
-
         for(let i = 0; i < stat_names.length; i++)
         {
             let stat = cpu.wm.exports["_profiler_stat_get"](i);