Dear R-devel list,

Running the following example on a recent R-devel (here, 2016-11-22 r71672) shows that the byte compiler can cause some significant performance drops (here, computation time increasing from 0.01s to 0.31s ...)
=================================
library(Matrix)
someMatrix <- new("dtCMatrix", i= c(1L, 0:3), p=c(0L,0L,0:2, 5L), Dim = c(5L, 5L),
                  x = rep(1, 5), diag = "U")
compiler::enableJIT(3) ## R-devel default
system.time(replicate(100,Matrix::crossprod(someMatrix))) ## slow !
compiler::enableJIT(0)
system.time(replicate(100,Matrix::crossprod(someMatrix))) ## fast
==================================
By tracing compiler::cmpfun, I found that the reason may be that invoking Matrix::crossprod calls methods:::.selectSuperClasses which creates and runs the following function
function (exti) {!isVirtualExt(exti) && length(exti@by) == 0 && exti@simple}
and thus that this function is byte-compiled each time Matrix::crossprod is called.

Is there a straightforward way for users / R package writers to avoid such problems, or shouldn't it be fixed in the R sources ?

Thanks,

F.

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to