Bug 14210 - system.time provides inaccurate sys.child
system.time provides inaccurate sys.child
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: System-specific
old
All Linux
: P5 normal
Assigned To: Jitterbug compatibility account
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-10 19:40 UTC by Jitterbug compatibility account
Modified: 2010-02-21 16:22 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2010-02-10 19:40:11 UTC
From: manuel.lopez-ibanez@ulb.ac.be
Full_Name: Manuel López-Ibáñez
Version: R version 2.6.2 (2008-02-08)
OS: linux-gnu 
Submission from: (NULL) (164.15.10.156)


This is only relevant for CPU intensive child processes. Otherwise, the problem
is not obvious.

Therefore, we need a CPU intensive program like this one:

/************************************/
/*** Compile with: gcc -o timer-test -O0 timer-test.c -lm */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double alpha, beta;
int size = 1000;

#define WORK_create_matrix(TYPEOFMATRIX)                \
                                                        \
TYPEOFMATRIX ** m_create_##TYPEOFMATRIX##_matrix (      \
int dim1, int dim2, int line, const char*file)          \
{                                                       \
    TYPEOFMATRIX **p;                                   \
    int i;                                              \
                                                        \
    p = malloc (sizeof(TYPEOFMATRIX) * dim1 * dim2      \
                + sizeof(TYPEOFMATRIX *) * dim1 );      \
    if (p == NULL) {                                    \
        fprintf(stderr, "cannot create " #TYPEOFMATRIX  \
                " matrix of size (%d x %d): "           \
                "see line %d of file %s\n",             \
                dim1, dim2, line, file);                \
        exit(1);                                        \
    }                                                   \
    for (i = 0; i < dim1; i++)                          \
        p[i] = (TYPEOFMATRIX *) (p + dim1) + i * dim2;  \
    return p;                                           \
}                                                       

WORK_create_matrix(int)
WORK_create_matrix(double)
#undef WORK_create_matrix
#define create_double_matrix(dim1,dim2)\
    m_create_double_matrix(dim1,dim2,__LINE__,__FILE__)


int main(int argc, char *argv[])
{
    double **matrix1 = create_double_matrix(size, size);
    double **matrix2 = create_double_matrix(size, size);
    int iterations = 0;
    int i,j;
    double iter_limit = 100;
    alpha = rand();
    beta = rand();

    while (iterations < iter_limit) {
        for (i = 0; i < size; i++) {
            for (j = 0; j < size; j++) {
                if (i == j) continue;
                matrix2[i][j] = pow(matrix1[i][j], alpha)
                    * pow(matrix2[j][i], beta);
                matrix1[j][i] = matrix2[i][j];
            }
        }
        iterations++;
    }

    printf("Iterations = %d\n", iterations);
    return 0;
}
/************************************/

Then in R evaluate:

> print.default (system.time (system(paste ("time", "bash -c './timer-test 100 >
/dev/null'"))))
10.77user 0.02system 0:10.81elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+4574minor)pagefaults 0swaps
 user.self   sys.self    elapsed user.child  sys.child 
     0.000      0.000     10.818     10.777     10.777 
attr(,"class")
[1] "proc_time"

Expected: the sys.child time should be 0.02.

> version
               _                           
platform       i486-pc-linux-gnu           
arch           i486                        
os             linux-gnu                   
system         i486, linux-gnu             
status                                     
major          2                           
minor          6.2                         
year           2008                        
month          02                          
day            08                          
svn rev        44383                       
language       R                           
version.string R version 2.6.2 (2008-02-08)

Comment 1 Jitterbug compatibility account 2010-02-10 21:26:52 UTC
From: Peter Dalgaard <P.Dalgaard@biostat.ku.dk>
Manuel López-Ibáñez wrote:
> Patch against current trunk attached. It is a one-liner, so I do not
> believe anyone can claim copyright over it.

Fixed for r-devel (r51115).


> Cheers,
> 
>     Manuel.
> 
> BTW, bugs.r-project.org is painfully slow. I cannot login, I cannot post
> messages, I cannot attach files. And it doesn't handle accents in my name.

Well, it will die from other causes at the latest on March 1, anyway...
Hopefully Simon Urbanek can pick up the pieces and put a more modern bug
tracker in its place.

(Part of the reason is that Jitterbug is horribly old and unmaintained;
another part is that U.Cph. appears to be intent on committing IT
suicide in the name of rampant corporativism. It is by design that only
a select group of people can login, though. It is expecting followups by
mail, for some reason.)


-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)              FAX: (+45) 35327907

Comment 2 Jitterbug compatibility account 2010-02-14 20:03:00 UTC
NOTES:
 Fixed (for those platforms on which it occurred) for 2.11.0
Comment 3 Jitterbug compatibility account 2010-02-14 20:03:43 UTC
Audit (from Jitterbug):
Sun Feb 14 14:03:43 2010	ripley	changed notes
Sun Feb 14 14:03:43 2010	ripley	moved from incoming to System-specific-fixed
Comment 4 Jitterbug compatibility account 2010-02-21 15:40:08 UTC
From: Henrik Bengtsson <hb@stat.berkeley.edu>
FYI,

you're much more likely to get a response/see actions on this if you
report issues using the most recent stable version (R v2.10.1) and/or
even the developers version (R v2.11.0).  You're current version is,
as you see, more than 2 years old.  It is likely that the threshold to
compare the code of your version with the latest one etc is to large
for someone to be bothered.

/Henrik

On Wed, Feb 10, 2010 at 2:45 PM,  <manuel.lopez-ibanez@ulb.ac.be> wrote:
> Full_Name: Manuel López-Ibáñez
> Version: R version 2.6.2 (2008-02-08)
> OS: linux-gnu
> Submission from: (NULL) (164.15.10.156)
>
>
> This is only relevant for CPU intensive child processes. Otherwise, the problem
> is not obvious.
>
> Therefore, we need a CPU intensive program like this one:
>
> /************************************/
> /*** Compile with: gcc -o timer-test -O0 timer-test.c -lm */
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
>
> double alpha, beta;
> int size = 1000;
>
> #define WORK_create_matrix(TYPEOFMATRIX)                \
>                                                        \
> TYPEOFMATRIX ** m_create_##TYPEOFMATRIX##_matrix (      \
> int dim1, int dim2, int line, const char*file)          \
> {                                                       \
>    TYPEOFMATRIX **p;                                   \
>    int i;                                              \
>                                                        \
>    p = malloc (sizeof(TYPEOFMATRIX) * dim1 * dim2      \
>                + sizeof(TYPEOFMATRIX *) * dim1 );      \
>    if (p == NULL) {                                    \
>        fprintf(stderr, "cannot create " #TYPEOFMATRIX  \
>                " matrix of size (%d x %d): "           \
>                "see line %d of file %s\n",             \
>                dim1, dim2, line, file);                \
>        exit(1);                                        \
>    }                                                   \
>    for (i = 0; i < dim1; i++)                          \
>        p[i] = (TYPEOFMATRIX *) (p + dim1) + i * dim2;  \
>    return p;                                           \
> }
>
> WORK_create_matrix(int)
> WORK_create_matrix(double)
> #undef WORK_create_matrix
> #define create_double_matrix(dim1,dim2)\
>    m_create_double_matrix(dim1,dim2,__LINE__,__FILE__)
>
>
> int main(int argc, char *argv[])
> {
>    double **matrix1 = create_double_matrix(size, size);
>    double **matrix2 = create_double_matrix(size, size);
>    int iterations = 0;
>    int i,j;
>    double iter_limit = 100;
>    alpha = rand();
>    beta = rand();
>
>    while (iterations < iter_limit) {
>        for (i = 0; i < size; i++) {
>            for (j = 0; j < size; j++) {
>                if (i == j) continue;
>                matrix2[i][j] = pow(matrix1[i][j], alpha)
>                    * pow(matrix2[j][i], beta);
>                matrix1[j][i] = matrix2[i][j];
>            }
>        }
>        iterations++;
>    }
>
>    printf("Iterations = %d\n", iterations);
>    return 0;
> }
> /************************************/
>
> Then in R evaluate:
>
>> print.default (system.time (system(paste ("time", "bash -c './timer-test 100 >
> /dev/null'"))))
> 10.77user 0.02system 0:10.81elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
> 0inputs+0outputs (0major+4574minor)pagefaults 0swaps
>  user.self   sys.self    elapsed user.child  sys.child
>     0.000      0.000     10.818     10.777     10.777
> attr(,"class")
> [1] "proc_time"
>
> Expected: the sys.child time should be 0.02.
>
>> version
>               _
> platform       i486-pc-linux-gnu
> arch           i486
> os             linux-gnu
> system         i486, linux-gnu
> status
> major          2
> minor          6.2
> year           2008
> month          02
> day            08
> svn rev        44383
> language       R
> version.string R version 2.6.2 (2008-02-08)
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

Comment 5 Jitterbug compatibility account 2010-02-21 16:22:24 UTC
From: Peter Dalgaard <p.dalgaard@biostat.ku.dk>
Henrik Bengtsson wrote:
> FYI,
> 
> you're much more likely to get a response/see actions on this if you
> report issues using the most recent stable version (R v2.10.1) and/or
> even the developers version (R v2.11.0).  You're current version is,
> as you see, more than 2 years old.  It is likely that the threshold to
> compare the code of your version with the latest one etc is to large
> for someone to be bothered.
> 
> /Henrik

It was fixed in r-devel same day, though. The message threading is just 
a bit messed up.

-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)              FAX: (+45) 35327907