Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 65:13b22ffb8a2f
Nov 14 vers -- Added measurement of Plugin, malloc, & master lock, + vutilities
| author | Me |
|---|---|
| date | Sun, 14 Nov 2010 11:17:52 -0800 |
| parents | 5cb919ac890f |
| children | bf08108405cc 2377967a2732 |
| files | CoreLoop.c VMS.c VMS.h probes.c probes.h vmalloc.c vmalloc.h vutilities.c vutilities.h |
| diffstat | 9 files changed, 198 insertions(+), 26 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Sat Nov 13 14:39:40 2010 -0800 1.2 +++ b/CoreLoop.c Sun Nov 14 11:17:52 2010 -0800 1.3 @@ -119,27 +119,45 @@ 1.4 #endif 1.5 1.6 if( currPr != NULL ) _VMSMasterEnv->numMasterInARow[thisCoresIdx] = 0; 1.7 + else 1.8 + { 1.9 + //============================= MEASUREMENT STUFF ===================== 1.10 + #ifdef MEAS__TIME_MASTER_LOCK 1.11 + int32 startStamp, endStamp; 1.12 + saveLowTimeStampCountInto( startStamp ); 1.13 + #endif 1.14 + //===================================================================== 1.15 + int tries = 0; int gotLock = 0; 1.16 + while( currPr == NULL ) //if queue was empty, enter get masterLock loop 1.17 + { //queue was empty, so get master lock 1.18 1.19 - int tries = 0; int gotLock = 0; 1.20 - while( currPr == NULL ) //if queue was empty, enter get masterLock loop 1.21 - { //queue was empty, so get master lock 1.22 - gotLock = __sync_bool_compare_and_swap( &(_VMSMasterEnv->masterLock), \ 1.23 + gotLock = __sync_bool_compare_and_swap(&(_VMSMasterEnv->masterLock), 1.24 UNLOCKED, LOCKED ); 1.25 - if( gotLock ) 1.26 - { //run own MasterVP -- jmps to coreLoops startPt when done 1.27 - currPr = _VMSMasterEnv->masterVPs[thisCoresIdx]; 1.28 - if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 1000 ) 1.29 - { DEBUG( dbgB2BMaster,"Many back to back MasterVPs\n"); 1.30 - pthread_yield(); 1.31 + if( gotLock ) 1.32 + { //run own MasterVP -- jmps to coreLoops startPt when done 1.33 + currPr = _VMSMasterEnv->masterVPs[thisCoresIdx]; 1.34 + if( _VMSMasterEnv->numMasterInARow[thisCoresIdx] > 1000 ) 1.35 + { DEBUG( dbgB2BMaster,"Many back to back MasterVPs\n"); 1.36 + pthread_yield(); 1.37 + } 1.38 + _VMSMasterEnv->numMasterInARow[thisCoresIdx] += 1; 1.39 + break; //end while -- have a VP to animate now 1.40 } 1.41 - _VMSMasterEnv->numMasterInARow[thisCoresIdx] += 1; 1.42 - break; //end while -- have a VP to animate now 1.43 + 1.44 + tries++; //if too many, means master on other core taking too long 1.45 + if( tries > MASTERLOCK_RETRIES ) { tries = 0; pthread_yield(); } 1.46 } 1.47 - 1.48 - tries++; //if too many, means master on other core taking too long 1.49 - if( tries > MASTERLOCK_RETRIES ) { tries = 0; pthread_yield(); } 1.50 + //============================= MEASUREMENT STUFF ===================== 1.51 + #ifdef MEAS__TIME_MASTER_LOCK 1.52 + saveLowTimeStampCountInto( endStamp ); 1.53 + addIntervalToHist( startStamp, endStamp, 1.54 + _VMSMasterEnv->masterLockLowTimeHist ); 1.55 + addIntervalToHist( startStamp, endStamp, 1.56 + _VMSMasterEnv->masterLockHighTimeHist ); 1.57 + #endif 1.58 + //===================================================================== 1.59 + 1.60 } 1.61 - 1.62 /* VirtProcr offsets: 1.63 * 0xc stackPtr 1.64 * 0x10 framePtr 1.65 @@ -150,7 +168,7 @@ 1.66 * _VMSMasterEnv offsets: 1.67 * 0x24 coreLoopStartPt 1.68 * 0x28 coreLoopEndPt 1.69 - * 0x30 masterLock 1.70 + * 0x30 masterLock 1.71 */ 1.72 // SwitchToVP( currPr ) 1.73 asm volatile("movl %0, %%ebx; \
2.1 --- a/VMS.c Sat Nov 13 14:39:40 2010 -0800 2.2 +++ b/VMS.c Sun Nov 14 11:17:52 2010 -0800 2.3 @@ -101,6 +101,16 @@ 2.4 //After this, all other mallocs are VMS__malloc. 2.5 _VMSMasterEnv->freeListHead = VMS_ext__create_free_list(); 2.6 2.7 + 2.8 + //============================= MEASUREMENT STUFF ======================== 2.9 + #ifdef MEAS__TIME_MALLOC 2.10 + _VMSMasterEnv->mallocTimeHist = makeFixedBinHistExt( 100, 50, 10, 2.11 + "malloc time hist"); 2.12 + _VMSMasterEnv->freeTimeHist = makeFixedBinHistExt( 100, 50, 10, 2.13 + "free time hist"); 2.14 + #endif 2.15 + //======================================================================== 2.16 + 2.17 //===================== Only VMS__malloc after this ==================== 2.18 masterEnv = _VMSMasterEnv; 2.19 2.20 @@ -147,6 +157,18 @@ 2.21 _VMSMasterEnv->createPtInSecs = 2.22 timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0); 2.23 #endif 2.24 + #ifdef MEAS__TIME_PLUGIN 2.25 + _VMSMasterEnv->pluginLowTimeHist = makeFixedBinHist( 50, 0, 2, 2.26 + "plugin low time hist"); 2.27 + _VMSMasterEnv->pluginHighTimeHist = makeFixedBinHist( 100, 0, 200, 2.28 + "plugin high time hist"); 2.29 + #endif 2.30 + #ifdef MEAS__TIME_MASTER_LOCK 2.31 + _VMSMasterEnv->masterLockLowTimeHist = makeFixedBinHist( 50, 0, 2, 2.32 + "master lock low time hist"); 2.33 + _VMSMasterEnv->masterLockHighTimeHist = makeFixedBinHist( 100, 0, 200, 2.34 + "master lock high time hist"); 2.35 + #endif 2.36 //======================================================================== 2.37 2.38 } 2.39 @@ -600,9 +622,7 @@ 2.40 semReq = req->semReqData; 2.41 2.42 newProbe = VMS__malloc( sizeof(IntervalProbe) ); 2.43 - nameLen = strlen( semReq->nameStr ); 2.44 - newProbe->nameStr = VMS__malloc( nameLen ); 2.45 - memcpy( newProbe->nameStr, semReq->nameStr, nameLen ); 2.46 + newProbe->nameStr = VMS__strDup( semReq->nameStr ); 2.47 newProbe->hist = NULL; 2.48 newProbe->schedChoiceWasRecorded = FALSE; 2.49 2.50 @@ -744,6 +764,44 @@ 2.51 VirtProcr **masterVPs; 2.52 SchedSlot ***allSchedSlots; //ptr to array of ptrs 2.53 2.54 + //Before getting rid of everything, print out any measurements made 2.55 + #ifdef MEAS__TIME_PLUGIN 2.56 + printHist( _VMSMasterEnv->pluginLowTimeHist ); 2.57 + printHist( _VMSMasterEnv->pluginHighTimeHist ); 2.58 + #endif 2.59 + #ifdef MEAS__TIME_MALLOC 2.60 + printHist( _VMSMasterEnv->mallocTimeHist ); 2.61 + printHist( _VMSMasterEnv->freeTimeHist ); 2.62 + freeHistExt( _VMSMasterEnv->mallocTimeHist ); 2.63 + freeHistExt( _VMSMasterEnv->freeTimeHist ); 2.64 + #endif 2.65 + #ifdef MEAS__TIME_MASTER_LOCK 2.66 + printHist( _VMSMasterEnv->masterLockLowTimeHist ); 2.67 + printHist( _VMSMasterEnv->masterLockHighTimeHist ); 2.68 + #endif 2.69 + #ifdef MEAS__TIME_MASTER 2.70 + printHist( _VMSMasterEnv->pluginTimeHist ); 2.71 + for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 2.72 + { 2.73 + freeVMSQ( readyToAnimateQs[ coreIdx ] ); 2.74 + //master VPs were created external to VMS, so use external free 2.75 + VMS__dissipate_procr( masterVPs[ coreIdx ] ); 2.76 + 2.77 + freeSchedSlots( allSchedSlots[ coreIdx ] ); 2.78 + } 2.79 + #endif 2.80 + #ifdef MEAS__TIME_STAMP_SUSP 2.81 + printHist( _VMSMasterEnv->pluginTimeHist ); 2.82 + for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 2.83 + { 2.84 + freeVMSQ( readyToAnimateQs[ coreIdx ] ); 2.85 + //master VPs were created external to VMS, so use external free 2.86 + VMS__dissipate_procr( masterVPs[ coreIdx ] ); 2.87 + 2.88 + freeSchedSlots( allSchedSlots[ coreIdx ] ); 2.89 + } 2.90 + #endif 2.91 + 2.92 //All the environment data has been allocated with VMS__malloc, so just 2.93 // free its internal big-chunk and all inside it disappear. 2.94 /*
3.1 --- a/VMS.h Sat Nov 13 14:39:40 2010 -0800 3.2 +++ b/VMS.h Sun Nov 14 11:17:52 2010 -0800 3.3 @@ -61,8 +61,11 @@ 3.4 // suspending a processor and just after resuming that processor. It is 3.5 // saved into a field added to VirtProcr. Have to sanity-check for 3.6 // rollover of low portion into high portion. 3.7 -#define MEAS__TIME_STAMP_SUSP 3.8 -#define MEAS__TIME_MASTER 3.9 +//#define MEAS__TIME_STAMP_SUSP 3.10 +//#define MEAS__TIME_MASTER 3.11 +//#define MEAS__TIME_PLUGIN 3.12 +//#define MEAS__TIME_MALLOC 3.13 +#define MEAS__TIME_MASTER_LOCK 3.14 #define MEAS__NUM_TIMES_TO_RUN 100000 3.15 3.16 //For code that calculates normalization-offset between TSC counts of 3.17 @@ -192,10 +195,11 @@ 3.18 unsigned int preSuspTSCLow; 3.19 unsigned int postSuspTSCLow; 3.20 #endif 3.21 - #ifdef MEAS__TIME_MASTER 3.22 + #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ 3.23 unsigned int startMasterTSCLow; 3.24 unsigned int endMasterTSCLow; 3.25 #endif 3.26 + //======================================== 3.27 3.28 float64 createPtInSecs; //have space but don't use on some configs 3.29 }; 3.30 @@ -238,6 +242,18 @@ 3.31 HashTable *probeNameHashTbl; 3.32 int32 masterCreateProbeID; 3.33 float64 createPtInSecs; 3.34 + #ifdef MEAS__TIME_PLUGIN 3.35 + Histogram *pluginLowTimeHist; 3.36 + Histogram *pluginHighTimeHist; 3.37 + #endif 3.38 + #ifdef MEAS__TIME_MALLOC 3.39 + Histogram *mallocTimeHist; 3.40 + Histogram *freeTimeHist; 3.41 + #endif 3.42 + #ifdef MEAS__TIME_MASTER_LOCK 3.43 + Histogram *masterLockLowTimeHist; 3.44 + Histogram *masterLockHighTimeHist; 3.45 + #endif 3.46 } 3.47 MasterEnv; 3.48 3.49 @@ -378,6 +394,7 @@ 3.50 3.51 #include "SwitchAnimators.h" 3.52 #include "probes.h" 3.53 +#include "vutilities.h" 3.54 3.55 #endif /* _VMS_H */ 3.56
4.1 --- a/probes.c Sat Nov 13 14:39:40 2010 -0800 4.2 +++ b/probes.c Sun Nov 14 11:17:52 2010 -0800 4.3 @@ -334,6 +334,7 @@ 4.4 } 4.5 4.6 4.7 +inline void doNothing(){}; 4.8 4.9 void 4.10 generic_print_probe( void *_probe )
5.1 --- a/probes.h Sat Nov 13 14:39:40 2010 -0800 5.2 +++ b/probes.h Sun Nov 14 11:17:52 2010 -0800 5.3 @@ -135,7 +135,7 @@ 5.4 0 /* do nothing */ 5.5 5.6 int32 5.7 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr, VirtProcr *animPr); 5.8 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr ); 5.9 #define VMS_ext__record_time_point_into_new_probe( nameStr ) \ 5.10 0 /* do nothing */ 5.11 5.12 @@ -178,15 +178,16 @@ 5.13 #define VMS__record_interval_end_in_probe( probeID ) \ 5.14 /* do nothing */ 5.15 5.16 +inline void doNothing(); 5.17 void 5.18 VMS_impl__print_stats_of_probe( int32 probeID ); 5.19 #define VMS__print_stats_of_probe( probeID ) \ 5.20 - /* do nothing */ 5.21 + doNothing/* do nothing */ 5.22 5.23 void 5.24 VMS_impl__print_stats_of_all_probes(); 5.25 #define VMS__print_stats_of_all_probes \ 5.26 - /* do nothing */ 5.27 + doNothing/* do nothing */ 5.28 5.29 #endif /* defined STATS__ENABLE_PROBES */ 5.30
6.1 --- a/vmalloc.c Sat Nov 13 14:39:40 2010 -0800 6.2 +++ b/vmalloc.c Sun Nov 14 11:17:52 2010 -0800 6.3 @@ -49,6 +49,13 @@ 6.4 { MallocProlog *foundElem = NULL, *currElem, *newElem; 6.5 int32 amountExtra, foundElemIsTopOfHeap, sizeConsumed,sizeOfFound; 6.6 6.7 + //============================= MEASUREMENT STUFF ======================== 6.8 + #ifdef MEAS__TIME_MALLOC 6.9 + int32 startStamp, endStamp; 6.10 + saveLowTimeStampCountInto( startStamp ); 6.11 + #endif 6.12 + //======================================================================== 6.13 + 6.14 //step up the size to be aligned at 16-byte boundary, prob better ways 6.15 sizeRequested = ((sizeRequested + 16) >> 4) << 4; 6.16 currElem = (_VMSMasterEnv->freeListHead)->nextChunkInFreeList; 6.17 @@ -108,6 +115,13 @@ 6.18 } 6.19 _VMSMasterEnv->amtOfOutstandingMem += sizeConsumed; 6.20 6.21 + //============================= MEASUREMENT STUFF ======================== 6.22 + #ifdef MEAS__TIME_MALLOC 6.23 + saveLowTimeStampCountInto( endStamp ); 6.24 + addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->mallocTimeHist ); 6.25 + #endif 6.26 + //======================================================================== 6.27 + 6.28 //skip over the prolog by adding its size to the pointer return 6.29 return (void *)((char *)foundElem + sizeof(MallocProlog)); 6.30 } 6.31 @@ -124,6 +138,13 @@ 6.32 { MallocProlog *elemToFree, *nextLowerElem, *nextHigherElem; 6.33 int32 lowerExistsAndIsFree, higherExistsAndIsFree, sizeOfElem; 6.34 6.35 + //============================= MEASUREMENT STUFF ======================== 6.36 + #ifdef MEAS__TIME_MALLOC 6.37 + int32 startStamp, endStamp; 6.38 + saveLowTimeStampCountInto( startStamp ); 6.39 + #endif 6.40 + //======================================================================== 6.41 + 6.42 if( ptrToFree < (void*)_VMSMasterEnv->freeListHead->nextLowerInMem || 6.43 ptrToFree > (void*)_VMSMasterEnv->freeListHead->nextHigherInMem ) 6.44 { //outside the range of data owned by VMS's malloc, so do nothing 6.45 @@ -211,6 +232,12 @@ 6.46 elemToFree->prevChunkInFreeList = _VMSMasterEnv->freeListHead; 6.47 } 6.48 } 6.49 + //============================= MEASUREMENT STUFF ======================== 6.50 + #ifdef MEAS__TIME_MALLOC 6.51 + saveLowTimeStampCountInto( endStamp ); 6.52 + addIntervalToHist( startStamp, endStamp, _VMSMasterEnv->freeTimeHist ); 6.53 + #endif 6.54 + //======================================================================== 6.55 6.56 } 6.57
7.1 --- a/vmalloc.h Sat Nov 13 14:39:40 2010 -0800 7.2 +++ b/vmalloc.h Sun Nov 14 11:17:52 2010 -0800 7.3 @@ -7,6 +7,9 @@ 7.4 * Created on November 14, 2009, 9:07 PM 7.5 */ 7.6 7.7 +#ifndef _VMALLOC_H 7.8 +#define _VMALLOC_H 7.9 + 7.10 #include <malloc.h> 7.11 #include "VMS_primitive_data_types.h" 7.12 7.13 @@ -50,3 +53,5 @@ 7.14 7.15 void 7.16 VMS_ext__free_free_list( MallocProlog *freeListHead ); 7.17 + 7.18 +#endif 7.19 \ No newline at end of file
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/vutilities.c Sun Nov 14 11:17:52 2010 -0800 8.3 @@ -0,0 +1,25 @@ 8.4 +/* 8.5 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 8.6 + * Licensed under GNU General Public License version 2 8.7 + * 8.8 + * Author: seanhalle@yahoo.com 8.9 + * 8.10 + * Created on November 14, 2009, 9:07 PM 8.11 + */ 8.12 + 8.13 +#include <malloc.h> 8.14 +#include <stdlib.h> 8.15 + 8.16 +#include "VMS.h" 8.17 + 8.18 + 8.19 +inline char * 8.20 +VMS__strDup( char *str ) 8.21 + { char *retStr; 8.22 + 8.23 + retStr = VMS__malloc( strlen(str) + 1 ); 8.24 + if( str == NULL ) return str; 8.25 + strcpy( retStr, str ); 8.26 + 8.27 + return retStr; 8.28 + }
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/vutilities.h Sun Nov 14 11:17:52 2010 -0800 9.3 @@ -0,0 +1,20 @@ 9.4 +/* 9.5 + * Copyright 2009 OpenSourceCodeStewardshipFoundation.org 9.6 + * Licensed under GNU General Public License version 2 9.7 + * 9.8 + * Author: seanhalle@yahoo.com 9.9 + * 9.10 + * Created on November 14, 2009, 9:07 PM 9.11 + */ 9.12 + 9.13 + 9.14 +#ifndef _UTILITIES_H 9.15 +#define _UTILITIES_H 9.16 + 9.17 +#include <string.h> 9.18 +#include "VMS_primitive_data_types.h" 9.19 + 9.20 +inline char * 9.21 +VMS__strDup( char *str ); 9.22 + 9.23 +#endif
