浏览代码

pstatclient: Fix out-of-order events with thread profiling

It could generate an end/start pair on a thread that is waiting due to other threads in that sync group submitting a PStats frame for the whole sync group, which would cause out-of-order events
rdb 10 月之前
父节点
当前提交
3082d28fe8
共有 1 个文件被更改,包括 10 次插入15 次删除
  1. 10 15
      panda/src/pstatclient/pStatClientImpl.cxx

+ 10 - 15
panda/src/pstatclient/pStatClientImpl.cxx

@@ -155,10 +155,9 @@ client_connect(std::string hostname, int port) {
       int thread_index = current_thread->get_pstats_index();
       if (thread_index >= 0) {
         PStatClient *client = PStatClient::get_global_pstats();
-        double start = client->get_real_time();
+        client->start(_wait_sleep_pcollector.get_index(), thread_index);
         ThreadImpl::sleep(seconds);
-        double stop = client->get_real_time();
-        client->start_stop(_wait_sleep_pcollector.get_index(), thread_index, start, stop);
+        client->stop(_wait_sleep_pcollector.get_index(), thread_index);
         client->add_level(_cswitch_sleep_pcollector.get_index(), thread_index, 1);
       }
       else {
@@ -171,10 +170,9 @@ client_connect(std::string hostname, int port) {
       int thread_index = current_thread->get_pstats_index();
       if (thread_index >= 0) {
         PStatClient *client = PStatClient::get_global_pstats();
-        double start = client->get_real_time();
+        client->start(_wait_yield_pcollector.get_index(), thread_index);
         ThreadImpl::yield();
-        double stop = client->get_real_time();
-        client->start_stop(_wait_yield_pcollector.get_index(), thread_index, start, stop);
+        client->stop(_wait_yield_pcollector.get_index(), thread_index);
         client->add_level(_cswitch_yield_pcollector.get_index(), thread_index, 1);
       }
       else {
@@ -190,10 +188,9 @@ client_connect(std::string hostname, int port) {
         BOOL result;
         if (thread_index >= 0) {
           PStatClient *client = PStatClient::get_global_pstats();
-          double start = client->get_real_time();
+          client->start(_wait_cvar_pcollector.get_index(), thread_index);
           result = SleepConditionVariableSRW(cvar, lock, time, flags);
-          double stop = client->get_real_time();
-          client->start_stop(_wait_cvar_pcollector.get_index(), thread_index, start, stop);
+          client->stop(_wait_cvar_pcollector.get_index(), thread_index);
           client->add_level(_cswitch_cvar_pcollector.get_index(), thread_index, 1);
         }
         else {
@@ -211,10 +208,9 @@ client_connect(std::string hostname, int port) {
         int result;
         if (thread_index >= 0) {
           PStatClient *client = PStatClient::get_global_pstats();
-          double start = client->get_real_time();
+          client->start(_wait_cvar_pcollector.get_index(), thread_index);
           result = pthread_cond_wait(cvar, lock);
-          double stop = client->get_real_time();
-          client->start_stop(_wait_cvar_pcollector.get_index(), thread_index, start, stop);
+          client->stop(_wait_cvar_pcollector.get_index(), thread_index);
           client->add_level(_cswitch_cvar_pcollector.get_index(), thread_index, 1);
         }
         else {
@@ -231,10 +227,9 @@ client_connect(std::string hostname, int port) {
         int result;
         if (thread_index >= 0) {
           PStatClient *client = PStatClient::get_global_pstats();
-          double start = client->get_real_time();
+          client->start(_wait_cvar_pcollector.get_index(), thread_index);
           result = pthread_cond_timedwait(cvar, lock, ts);
-          double stop = client->get_real_time();
-          client->start_stop(_wait_cvar_pcollector.get_index(), thread_index, start, stop);
+          client->stop(_wait_cvar_pcollector.get_index(), thread_index);
           client->add_level(_cswitch_cvar_pcollector.get_index(), thread_index, 1);
         }
         else {