Changeset 26108 in vbox
- Timestamp:
- Jan 30, 2010 9:21:11 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57094
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMAsyncCompletion.cpp
r22309 r26108 39 39 #include <iprt/critsect.h> 40 40 #include <iprt/tcp.h> 41 #include <iprt/path.h> 41 42 42 43 #include <VBox/pdmasynccompletion.h> … … 837 838 pTask->pPrev = NULL; 838 839 pTask->pNext = NULL; 840 #ifdef VBOX_WITH_STATISTICS 841 pTask->tsNsStart = RTTimeNanoTS(); 842 STAM_COUNTER_INC(&pEndpoint->StatIoOpsStarted); 843 #endif 839 844 } 840 845 … … 853 858 { 854 859 PPDMASYNCCOMPLETIONEPCLASS pEndpointClass = pEndpoint->pEpClass; 860 861 #ifdef VBOX_WITH_STATISTICS 862 uint64_t tsRun = RTTimeNanoTS() - pTask->tsNsStart; 863 uint64_t iStatIdx; 864 865 if (tsRun < 1000) 866 { 867 /* Update nanoseconds statistics */ 868 iStatIdx = tsRun / 100; 869 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesNs[iStatIdx]); 870 } 871 else 872 { 873 tsRun /= 1000; 874 875 if (tsRun < 1000) 876 { 877 /* Update microsecnds statistics */ 878 iStatIdx = tsRun / 100; 879 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesMicroSec[iStatIdx]); 880 } 881 else 882 { 883 tsRun /= 1000; 884 885 if (tsRun < 1000) 886 { 887 /* Update milliseconds statistics */ 888 iStatIdx = tsRun / 100; 889 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesMs[iStatIdx]); 890 } 891 else 892 { 893 tsRun /= 1000; 894 895 if (tsRun < 1000) 896 { 897 /* Update seconds statistics */ 898 iStatIdx = tsRun / 10; 899 STAM_COUNTER_INC(&pEndpoint->StatTaskRunTimesSec[iStatIdx]); 900 } 901 else 902 STAM_COUNTER_INC(&pEndpoint->StatTaskRunOver100Sec); 903 } 904 } 905 } 906 907 STAM_COUNTER_INC(&pEndpoint->StatIoOpsCompleted); 908 pEndpoint->cIoOpsCompleted++; 909 uint64_t tsMsCur = RTTimeMilliTS(); 910 uint64_t tsInterval = tsMsCur - pEndpoint->tsIntervalStartMs; 911 912 if (tsInterval >= 1000) 913 { 914 pEndpoint->StatIoOpsPerSec.c = pEndpoint->cIoOpsCompleted / (tsInterval / 1000); 915 pEndpoint->tsIntervalStartMs = tsMsCur; 916 pEndpoint->cIoOpsCompleted = 0; 917 } 918 #endif 855 919 856 920 /* Check whether we can use the per endpoint cache */ … … 947 1011 pEndpoint->pszUri = RTStrDup(pszFilename); 948 1012 pEndpoint->cUsers = 1; 949 if (pEndpoint->pszUri) 1013 1014 #ifdef VBOX_WITH_STATISTICS 1015 /* Init the statistics part */ 1016 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++) 1017 { 1018 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesNs[i], STAMTYPE_COUNTER, 1019 STAMVISIBILITY_USED, 1020 STAMUNIT_OCCURENCES, 1021 "Nanosecond resolution runtime statistics", 1022 "/PDM/AsyncCompletion/File/%s/TaskRunNs-%u-%u", 1023 RTPathFilename(pEndpoint->pszUri), 1024 i*100, i*100+100-1); 1025 if (RT_FAILURE(rc)) 1026 break; 1027 } 1028 1029 if (RT_SUCCESS(rc)) 1030 { 1031 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMicroSec); i++) 1032 { 1033 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMicroSec[i], STAMTYPE_COUNTER, 1034 STAMVISIBILITY_USED, 1035 STAMUNIT_OCCURENCES, 1036 "Microsecond resolution runtime statistics", 1037 "/PDM/AsyncCompletion/File/%s/TaskRunMicroSec-%u-%u", 1038 RTPathFilename(pEndpoint->pszUri), 1039 i*100, i*100+100-1); 1040 if (RT_FAILURE(rc)) 1041 break; 1042 } 1043 } 1044 1045 if (RT_SUCCESS(rc)) 1046 { 1047 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1048 { 1049 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesMs[i], STAMTYPE_COUNTER, 1050 STAMVISIBILITY_USED, 1051 STAMUNIT_OCCURENCES, 1052 "Milliseconds resolution runtime statistics", 1053 "/PDM/AsyncCompletion/File/%s/TaskRunMs-%u-%u", 1054 RTPathFilename(pEndpoint->pszUri), 1055 i*100, i*100+100-1); 1056 if (RT_FAILURE(rc)) 1057 break; 1058 } 1059 } 1060 1061 if (RT_SUCCESS(rc)) 1062 { 1063 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1064 { 1065 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunTimesSec[i], STAMTYPE_COUNTER, 1066 STAMVISIBILITY_USED, 1067 STAMUNIT_OCCURENCES, 1068 "Second resolution runtime statistics", 1069 "/PDM/AsyncCompletion/File/%s/TaskRunSec-%u-%u", 1070 RTPathFilename(pEndpoint->pszUri), 1071 i*10, i*10+10-1); 1072 if (RT_FAILURE(rc)) 1073 break; 1074 } 1075 } 1076 1077 if (RT_SUCCESS(rc)) 1078 { 1079 rc = STAMR3RegisterF(pVM, &pEndpoint->StatTaskRunOver100Sec, STAMTYPE_COUNTER, 1080 STAMVISIBILITY_USED, 1081 STAMUNIT_OCCURENCES, 1082 "Tasks which ran more than 100sec", 1083 "/PDM/AsyncCompletion/File/%s/TaskRunSecGreater100Sec", 1084 RTPathFilename(pEndpoint->pszUri)); 1085 } 1086 1087 if (RT_SUCCESS(rc)) 1088 { 1089 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsPerSec, STAMTYPE_COUNTER, 1090 STAMVISIBILITY_ALWAYS, 1091 STAMUNIT_OCCURENCES, 1092 "Processed I/O operations per second", 1093 "/PDM/AsyncCompletion/File/%s/IoOpsPerSec", 1094 RTPathFilename(pEndpoint->pszUri)); 1095 } 1096 1097 if (RT_SUCCESS(rc)) 1098 { 1099 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsStarted, STAMTYPE_COUNTER, 1100 STAMVISIBILITY_ALWAYS, 1101 STAMUNIT_OCCURENCES, 1102 "Started I/O operations for this endpoint", 1103 "/PDM/AsyncCompletion/File/%s/IoOpsStarted", 1104 RTPathFilename(pEndpoint->pszUri)); 1105 } 1106 1107 if (RT_SUCCESS(rc)) 1108 { 1109 rc = STAMR3RegisterF(pVM, &pEndpoint->StatIoOpsCompleted, STAMTYPE_COUNTER, 1110 STAMVISIBILITY_ALWAYS, 1111 STAMUNIT_OCCURENCES, 1112 "Completed I/O operations for this endpoint", 1113 "/PDM/AsyncCompletion/File/%s/IoOpsCompleted", 1114 RTPathFilename(pEndpoint->pszUri)); 1115 } 1116 1117 pEndpoint->tsIntervalStartMs = RTTimeMilliTS(); 1118 #endif 1119 1120 if ( pEndpoint->pszUri 1121 && RT_SUCCESS(rc)) 950 1122 { 951 1123 /* Init the cache. */ … … 1053 1225 AssertMsg(RT_SUCCESS(rc), ("Failed to enter critical section rc=%Rrc\n", rc)); 1054 1226 1227 #ifdef VBOX_WITH_STATISTICS 1228 /* Deregister the statistics part */ 1229 PVM pVM = pEndpointClass->pVM; 1230 1231 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesNs); i++) 1232 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesNs[i]); 1233 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMicroSec); i++) 1234 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesMicroSec[i]); 1235 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1236 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesMs[i]); 1237 for (unsigned i = 0; i < RT_ELEMENTS(pEndpoint->StatTaskRunTimesMs); i++) 1238 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunTimesSec[i]); 1239 1240 STAMR3Deregister(pVM, &pEndpoint->StatTaskRunOver100Sec); 1241 STAMR3Deregister(pVM, &pEndpoint->StatIoOpsPerSec); 1242 STAMR3Deregister(pVM, &pEndpoint->StatIoOpsStarted); 1243 STAMR3Deregister(pVM, &pEndpoint->StatIoOpsCompleted); 1244 #endif 1245 1055 1246 RTStrFree(pEndpoint->pszUri); 1056 1247 MMR3HeapFree(pEndpoint); -
trunk/src/VBox/VMM/PDMAsyncCompletionInternal.h
r22309 r26108 27 27 #include <VBox/types.h> 28 28 #include <VBox/cfgm.h> 29 #include <VBox/stam.h> 29 30 #include <VBox/pdmasynccompletion.h> 30 31 … … 226 227 /** URI describing the endpoint */ 227 228 char *pszUri; 229 #ifdef VBOX_WITH_STATISTICS 230 STAMCOUNTER StatTaskRunTimesNs[10]; 231 STAMCOUNTER StatTaskRunTimesMicroSec[10]; 232 STAMCOUNTER StatTaskRunTimesMs[10]; 233 STAMCOUNTER StatTaskRunTimesSec[10]; 234 STAMCOUNTER StatTaskRunOver100Sec; 235 STAMCOUNTER StatIoOpsPerSec; 236 STAMCOUNTER StatIoOpsStarted; 237 STAMCOUNTER StatIoOpsCompleted; 238 uint64_t tsIntervalStartMs; 239 uint64_t cIoOpsCompleted; 240 #endif 228 241 } PDMASYNCCOMPLETIONENDPOINT; 229 242 … … 246 259 /** Task id. */ 247 260 uint32_t uTaskId; 261 #ifdef VBOX_WITH_STATISTICS 262 /** Start timestamp. */ 263 uint64_t tsNsStart; 264 #endif 248 265 } PDMASYNCCOMPLETIONTASK; 249 266
Note:
See TracChangeset
for help on using the changeset viewer.