Changeset: aa019beec696 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aa019beec696
Modified Files:
        monetdb5/extras/crackers/crackers_holistic.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_profiler.h
Branch: holindex
Log Message:

Print the cpu load in a file.


diffs (145 lines):

diff --git a/monetdb5/extras/crackers/crackers_holistic.c 
b/monetdb5/extras/crackers/crackers_holistic.c
--- a/monetdb5/extras/crackers/crackers_holistic.c
+++ b/monetdb5/extras/crackers/crackers_holistic.c
@@ -27,7 +27,6 @@
 static FrequencyNode *_InternalFrequencyStructA = NULL;
 static FrequencyNode *_InternalFrequencyStructB = NULL;
 static MT_Id *idletime_thread;
-static MT_Id *cpuload_thread;
 MT_Lock frequencylock;
 MT_Lock CRKIndexLock;
 pthread_rwlock_t CRKFirstPieceRWLock;
@@ -38,11 +37,9 @@ CRKinitHolistic(int *ret)
 {
        IdleFunc=&CRKrandomCrack;
        idletime_thread = GDKzalloc(sizeof(*idletime_thread));
-       cpuload_thread = GDKzalloc(sizeof(*cpuload_thread));
        MT_lock_init(&frequencylock, "FrequencyStruct");
        MT_lock_init(&CRKIndexLock, "Cracker Index Lock");
        MT_create_thread(idletime_thread,(void (*)(void *))HeartbeatCPUload, 
IdleFunc, MT_THR_JOINABLE);
-       MT_create_thread(cpuload_thread,(void (*)(void 
*))HeartbeatCPUload_total, NULL, MT_THR_JOINABLE);
        *ret = 0;
        return MAL_SUCCEED;
 }
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -1331,10 +1331,12 @@ void HeartbeatCPUload(void *arg)
        lng t0,t1,t;
        int n=0;  /*number of idle cores*/
        int N=0;  /*number of busy cores*/
-       
+       FILE *ofp;
+       char *outputFilename1 = getenv("TOTAL_CPULOAD");
        void (*IdleFunc)(void *) = arg;
 
-       if (p == NULL || cores == NULL)
+
+       if (p == NULL || cores == NULL || outputFilename1 == NULL)
        {
                fprintf(stderr, "Error HeartbeatCPUload: environment variable 
is missing.\n");
                exit(1);
@@ -1343,58 +1345,49 @@ void HeartbeatCPUload(void *arg)
        {
                threshold = atoi(p);
                max_threads=atoi(cores);
+               ofp = fopen(outputFilename1,"a");
+               if (ofp == NULL) {
+                       fprintf(stderr, "Can't open output file!\n");
+                       exit(1);
+               }
        }
 
-       while(1)
+       if (max_threads > 0)
        {
-               (void) getCPULoad(cpuload);
-               load = corestat[256].load;
-               if ( load < threshold)
+               while(1)
                {
-                       
-                       N = (load/100) * max_threads;
-                       n = max_threads - N;
-                       (void) n;
-                       t0 = GDKusec();
-                       MRschedule(n, NULL, IdleFunc);
-                       t1 = GDKusec();
-                       t = 10000 - (t1 - t0);
-                       if (t < 0 ) 
-                               MT_sleep_ms(t);
+                       (void) getCPULoad(cpuload);
+                       load = corestat[256].load;
+                       fprintf(ofp,"%lf\n",corestat[256].load);
+                       if ( load < threshold)
+                       {
+                               N = (load/100) * max_threads;
+                               n = max_threads - N;
+                               (void) n;
+                               t0 = GDKusec();
+                               MRschedule(n, NULL, IdleFunc);
+                               t1 = GDKusec();
+                               t = 10000 - (t1 - t0);
+                               if (t < 0 ) 
+                                       MT_sleep_ms(t);
+                       }
+                       else
+                               MT_sleep_ms(10);        
                }
-               else
-                       MT_sleep_ms(10);        
        }
+       else
+       {
+               while(1)
+               {
+                       (void) getCPULoad(cpuload);
+                       fprintf(ofp,"%lf\n",corestat[256].load);
+                       MT_sleep_ms(10);
+               }
+       }
+       fclose(ofp);
 }
 
 // Give users the option to check for the system total load between two heart 
beats
-void HeartbeatCPUload_total(void* dummy)
-{
-       char cpuload[BUFSIZ];
-       FILE *ofp;
-       char *outputFilename1;
-       (void) dummy;
-
-       outputFilename1 = getenv("TOTAL_CPULOAD");
-       if (outputFilename1 == NULL){
-               fprintf(stderr, "Error: TOTAL_CPULOAD\n");
-               exit(1);
-       }
-
-       ofp = fopen(outputFilename1,"a");
-       if (ofp == NULL) {
-               fprintf(stderr, "Can't open output file!\n");
-               exit(1);
-       }
-
-       while(1)
-       {
-               (void) getCPULoad(cpuload);
-               fprintf(ofp,"%lf\n",corestat[256].load);
-               MT_sleep_ms(10);        
-       }
-       fclose(ofp);
-}
 void profilerGetCPUStat(lng *user, lng *nice, lng *sys, lng *idle, lng *iowait)
 {
        (void) getCPULoad(0);
diff --git a/monetdb5/mal/mal_profiler.h b/monetdb5/mal/mal_profiler.h
--- a/monetdb5/mal/mal_profiler.h
+++ b/monetdb5/mal/mal_profiler.h
@@ -102,7 +102,6 @@ mal_export str cleanupProfiler(void);
 mal_export void initHeartbeat(void);
 mal_export void stopHeartbeat(void);
 mal_export void HeartbeatCPUload(void*);
-mal_export void HeartbeatCPUload_total(void*);
 
 mal_export int instrFilter(InstrPtr pci, str mod, str fcn);
 mal_export void setFilter(Module cntxt, str mod, str fcn);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to