statnet / ergm

Fit, Simulate and Diagnose Exponential-Family Models for Networks
Other
98 stars 37 forks source link

Minimise or eliminate calls to utils::avalable.packages() and utils::installed.packages() in term indexing code #496

Closed krivit closed 2 years ago

krivit commented 2 years ago

Thanks to Kurt Hornik, the problem with Win-Builder and CRAN checks has been traced to frequent calls to tools::dependsOnPkgs(), which in turn calls utils::installed.packages(), which is extremely slow on CRAN because it has all the packages.

The recent change to the termalike template, for which the keywords/concepts are pulled in via a \Sexpr{}, brings things to a head, since it calls ergmTermCache() at least once for every termalike, and ergmTermCache() calls tools::dependsOnPkgs() every time.

krivit commented 2 years ago

The current most feasible solution is to come from the other direction: scan through the dependencies of all loaded packages to check for ergm.

tools::package_dependencies() calls utils::available.packages() which is very slow on any system, so it's probably a bad idea. However, packageDescription() takes almost no time, so it may be best to simply use a regex to search the Depends: and other fields for it.