[R-pkg-devel] Slow down in R 4.2.x; Solved
Johannes Ranke
joh@nne@@r@nke @end|ng |rom jrwb@de
Fri Jul 8 19:39:32 CEST 2022
Am Freitag, 8. Juli 2022, 14:52:27 CEST schrieb Tomas Kalibera:
> 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"]]
Thanks a lot for this concise analysis...
> Perhaps one could save dll_info, once computed in mkin, alongside "cf"
> in the model, instead of re-computing it every time?
... and for this excellent suggestion - I did so and the benchmarks are better
than ever [1].
Cheers
Johannes
[1] https://pkgdown.jrwb.de/mkin/articles/web_only/benchmarks.html#results
More information about the R-package-devel
mailing list