[R-pkg-devel] Slow down in R 4.2.x
On 7/1/22 11:10, Johannes Ranke wrote:
Dear list, independent of the thread on this list about slow examples on R 4.2 on windows I have discovered over the last few days that some of my benchmarks (look for t4 and t9) run by a factor of 3 slower on R 4.2.x than on R 4.1.3 [1]. This is on Linux, using my own backported R packages for R 4.2.x and locally compiled versions (with default configure options) of R-4-1-branch on two different CPUs. The results for R 4.2.1 are only slightly modulated by the use of different BLAS version (openblas-serial versus atlas versus lapack). I also tested the R 4.0.4 version that is part of Debian bullseye, it is as fast as the locally compiled R 4.1.3. I went through the NEWS for R 4.2.0 (because the first slow results were obtained using that version), but the only change I could imagine causing such a change is the additional check of the length of the arguments && and ||. Any other thoughts?
I can reproduce slowdown in one of your tests:
library(mkin)
FOCUS_D <- subset(FOCUS_2006_D, value != 0)
SFO_SFO <- mkinmod(
? parent = mkinsub("SFO", "m1"),
? m1 = mkinsub("SFO"))
FOMC_SFO <- mkinmod(
? parent = mkinsub("FOMC", "m1"),
? m1 = mkinsub("SFO"))
DFOP_SFO <- mkinmod(
? parent = mkinsub("FOMC", "m1"),
? m1 = mkinsub("SFO"))
mmkin_bench <- function(models, datasets, error_model = "const") {
? mmkin(models, datasets, error_model = error_model, cores = 1, quiet =
TRUE)
}
t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO),
list(FOCUS_D), error_model = "tc"))[["elapsed"]]
This is slower in R 4-devel than R 4.1 because of bug fixes in DLL info
interface (PR#16446, r80285). "perf" tool on Linux shows extra time
spent in R_registerSymbolEptr and R_WeakRefKey. This is because of
repeated calls to getLoadedDLLs(), via repeated calls to
inline::getDynLib(x$cf)[["name"]]
Perhaps one could save dll_info, once computed in mkin, alongside "cf"
in the model, instead of re-computing it every time?
Best
Tomas
Johannes [1] https://pkgdown.jrwb.de/mkin/articles/web_only/benchmarks.html#results [[alternative HTML version deleted]]
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel