Saving the dso from expose_stan_functions

Thank you guys for pointing me in this direction. This rcpp.cache.dir is a life-saver. A few notes for anyone who finds this: If you want to avoid recompilation every time you load the exposed stan functions, you have to follow these steps:

  1. set the rcpp.cache.dir option as described avove
  2. Use the stanc_builder function with the (default) obfuscate_model_name=FALSE setting in order to ensure that the same c++ code is generated each time
  3. pass the result from stanc_builder into expose_stan_functions

So like this:

options(rccp.cpp.dir="cache")
model_src <- stanc_builder("foo.stan")
expose_stan_functions(model_src)

Also make sure that a recent enough Rcpp is installed which supports dso caching.

@bgoodri: Should we make expose_stan_functions by default such that the model name is not obfuscated? This would lead to easier caching of this. Maybe we could even switch on the caching stuff if rstan_auto_write is set to true?

User who use exposed stan functions will love this caching.

1 Like