rextendr icon indicating copy to clipboard operation
rextendr copied to clipboard

Should profiles for skeleton package and sourcing functions match?

Open Thell opened this issue 4 years ago • 1 comments

I asked that in discord and was asked to make an issue for discussion.

On the skeleton package, as @Ilia-Kosenkov , rightly pointed out (in Discord) the release profile is an obvious choice for the creation of production ready packages. On the 'sourcing' side it didn't seem clear cut as to why it doesn't default to release like the skeleton does and some comments regarding thoughts on this start here on discord.

It has also been posted on in Benchmark Against Rcpp https://github.com/extendr/rextendr/issues/11.

Again, as a newcomer, I expect it to be release build unless otherwise directed via an argument or overridden by a ~/.R/Makevars setting (or something similar).

Thell avatar Dec 23 '21 19:12 Thell

I tried to benchmark simple rextendr function compilation, and the results are somewhat inconclusive. I see no significant difference between release and dev, but there is a noticeable increase in memory gced by R when compiling for release. Executed on Windows using i7-11700K and SATA SSD.

rust_fn <- "fn rust_add(x : Doubles, y : Doubles) -> Doubles {x.iter().zip(y.iter()).map(|(xx, yy)| xx + yy).collect()}"

release <- function() rextendr::rust_function(rust_fn, profile = "release", extendr_deps = list(`extendr-api` = list(git = "https://github.com/extendr/extendr")), cache_build = FALSE, quiet = TRUE)
develop <- function() rextendr::rust_function(rust_fn, profile = "dev", extendr_deps = list(`extendr-api` = list(git = "https://github.com/extendr/extendr")), cache_build = FALSE, quiet = TRUE)

tictoc::tic()
bench::mark(release(), develop(), check = FALSE, iterations = 10L) |> print()
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.
#> # A tibble: 2 x 13
#>   expression      min median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc total_time
#>   <bch:expr> <bch:tm> <bch:>     <dbl> <bch:byt>    <dbl> <int> <dbl>   <bch:tm>
#> 1 release()     12.6s    13s    0.0767    18.4MB   0.0844    10    11      2.17m
#> 2 develop()       13s  13.2s    0.0757   416.7KB   0.0833    10    11       2.2m
#> # ... with 4 more variables: result <list>, memory <list>, time <list>,
#> #   gc <list>
tictoc::toc()
#> 290.25 sec elapsed

Created on 2021-12-27 by the reprex package (v2.0.1)

Ilia-Kosenkov avatar Dec 27 '21 11:12 Ilia-Kosenkov