Right, I think the only remaing one using double to store system_jiffies is the cygwin.
I'm attatching a patch for cygwin (based on the linux changes). <- NOT tested

Att,

Rafael Xavier de Souza
Linux Technology Center Software Engineer
IBM Systems & Technology Group
rxavi...@br.ibm.com
MM17 Hortolândia-SP, Brazil

On 05-05-2010 19:47, Jesse Becker wrote:
I also looked at similar code for several other operating systems.  At least some of them already store the counters as 'unsigned long long', and do a conversion right before returning the data.

On Wed, May 5, 2010 at 18:33, Jesse Becker <haw...@gmail.com> wrote:
Could you please re-base this patch off of trunk?  Once done, I'll test and commit it.

Thanks for the patch!

On Wed, May 5, 2010 at 09:47, Rafael Xavier de Souza <rxavi...@br.ibm.com> wrote:
This patch fixes CPU system and idle metrics. Ganglia uses float variables (double) to store the jiffies and the jiffies sums. But, Float numbers have a problem with precision and Ganglia is getting lost with big ppc64 numbers on its calculations. This patch changes libmetrics/linux/metrics.c to use integers (unsined long long) to store the jiffies and jiffies sums and floats (double) to store the calculated numbers only.


Signed off by: Rafael Xavier <rxavi...@br.ibm.com>

OBS:
1) This patch has been sniff tested, but not extensively.
2) It fixes it for linux only. The ideal approach would be to make the same changes for other OSes as well.

--

Rafael Xavier de Souza
Linux Technology Center Software Engineer
IBM Systems & Technology Group
rxavi...@br.ibm.com
MM17 Hortolândia-SP, Brazil

------------------------------------------------------------------------------

_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers




--
Jesse Becker
Every cloud has a silver lining, except for the mushroom-shaped ones, which come lined with strontium-90.




--
Jesse Becker
Every cloud has a silver lining, except for the mushroom-shaped ones, which come lined with strontium-90.

Index: metrics.c
===================================================================
--- metrics.c	(revisão 2294)
+++ metrics.c	(cópia de trabalho)
@@ -23,7 +23,9 @@
 #include <mntent.h>
 #include <sys/vfs.h>
 #include <psapi.h>
+#define JT unsigned long long
 
+
 /* From old ganglia 2.5.x... */
 #include "file.h"
 #include "libmetrics.h"
@@ -470,11 +472,11 @@
 /*
  * A helper function to return the total number of cpu jiffies
  */
-unsigned long
+JT
 total_jiffies_func ( void )
 {
    char *p;
-   unsigned long user_jiffies, nice_jiffies, system_jiffies, idle_jiffies;
+   JT user_jiffies, nice_jiffies, system_jiffies, idle_jiffies;
 
    p = update_file(&proc_stat);
    p = skip_token(p);
@@ -496,8 +498,8 @@
    char *p;
    static g_val_t val;
    static struct timeval stamp = {0, 0};
-   static double last_user_jiffies,  user_jiffies,
-                 last_total_jiffies, total_jiffies, diff;
+   static JT last_user_jiffies,  user_jiffies, 
+             last_total_jiffies, total_jiffies, diff;
 
    p = update_file(&proc_stat);
    if ((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
@@ -511,7 +513,7 @@
      diff = user_jiffies - last_user_jiffies;
 
      if ( diff )
-       val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+       val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
      else
        val.f = 0.0;
 
@@ -528,8 +530,8 @@
    char *p;
    static g_val_t val;
    static struct timeval stamp = {0, 0};
-   static double last_nice_jiffies,  nice_jiffies,
-                 last_total_jiffies, total_jiffies, diff;
+   static JT last_nice_jiffies,  nice_jiffies,
+             last_total_jiffies, total_jiffies, diff;
 
    p = update_file(&proc_stat);
    if ((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
@@ -544,7 +546,7 @@
      diff = (nice_jiffies  - last_nice_jiffies);
 
      if ( diff )
-       val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+       val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
      else
        val.f = 0.0;
 
@@ -561,8 +563,8 @@
    char *p;
    static g_val_t val;
    static struct timeval stamp = {0, 0};
-   static double last_system_jiffies,  system_jiffies,
-                 last_total_jiffies, total_jiffies, diff;
+   static JT last_system_jiffies,  system_jiffies,
+             last_total_jiffies, total_jiffies, diff;
 
    p = update_file(&proc_stat);
    if ((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
@@ -586,7 +588,7 @@
      diff = system_jiffies  - last_system_jiffies;
 
      if ( diff )
-       val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+       val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
      else
        val.f = 0.0;
 
@@ -603,8 +605,8 @@
    char *p;
    static g_val_t val;
    static struct timeval stamp = {0, 0};
-   static double last_idle_jiffies,  idle_jiffies,
-                 last_total_jiffies, total_jiffies, diff;
+   static JT last_idle_jiffies,  idle_jiffies,
+             last_total_jiffies, total_jiffies, diff;
 
    p = update_file(&proc_stat);
    if ((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
@@ -621,7 +623,7 @@
      diff = idle_jiffies - last_idle_jiffies;
 
      if ( diff )
-       val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+       val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
      else
        val.f = 0.0;
 
------------------------------------------------------------------------------
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to