Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native R kernel computation is slow #145

Open
ArtPoon opened this issue Feb 22, 2019 · 2 comments
Open

Native R kernel computation is slow #145

ArtPoon opened this issue Feb 22, 2019 · 2 comments

Comments

@ArtPoon
Copy link
Contributor

ArtPoon commented Feb 22, 2019

To get rid of a large number of dependencies and make it easier to maintain and extend the kernel function, I've reimplemented the kernel in R. As expected, it is slower than the original C-igraph implementation. Unfortunately it is a lot slower. We're going to have to make the parallel library a prerequisite and use mclapply as much as possible. See test.speciation.model.
See also #142 and #143

@ArtPoon
Copy link
Contributor Author

ArtPoon commented Feb 22, 2019

require(microbenchmark)
require(Kaphi)
trees1 <- trees(c(0.1, 0.2, 0.003, 0.003, 0.01, 0.01), 
                    type='bisse', n=2, max.taxa=20)
t1 <- trees1[[1]]
t2 <- trees1[[2]]
> microbenchmark(tree.kernel(t1, t2), times=10)
Unit: milliseconds
                expr      min      lq     mean   median       uq      max neval
 tree.kernel(t1, t2) 343.7733 350.649 360.0597 354.9235 356.8686 417.4822    10  

We need to knock this down at least 10-fold.

@ArtPoon
Copy link
Contributor Author

ArtPoon commented Feb 22, 2019

About 25% of the time is spent converting the phylo object into an igraph object:

> g1 <- .tree.to.igraph(t1)
> g2 <- .tree.to.igraph(t2)
> microbenchmark(.tsk(g1, g2, lambda=0.2, rbf.var=100), times=10)
Unit: milliseconds
                                      expr      min       lq     mean   median
 .tsk(g1, g2, lambda = 0.2, rbf.var = 100) 268.2636 270.8561 281.0074 274.6949
       uq      max neval
 286.7355 320.8223    10

gtng92 added a commit that referenced this issue Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant