-
-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable optional parallel site building #383
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'd love to have this feature. Please finish up whatever you planned to do, and let me know when the PR is ready for review. Thank you very much!
I would consider this ready to be reviewed, just not sure about the "UI" in terms of using the feature. I am a fan of conservative introduction of new features, but happy to change. |
@yihui, is there anything waited on from my side? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the delay. I just added my own proposal (which is even more conservative but also more general). Please let me know what you think. Thanks!
@@ -44,7 +47,11 @@ build_site = function( | |||
if (local && length(files)) { | |||
files = getOption('blogdown.files_filter', timestamp_filter)(files) | |||
} | |||
build_rmds(files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought a while about it and I tend to let users decide how to parallelize it because there are multiple ways of parallelization. Here is how I'd implement it:
build_fun = getOption('blogdown.build_rmds', function(files, build) {
build(files)
})
build_fun(files, build_rmds)
Then users can set their own functions (in .Rprofile
), e.g.
options(blogdown.build_rmds = function(files, build) {
parallel::mclapply(files, build)
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Updated the approach to hopefully be in line with your though process, albeit still exposing the
build_fun
as a parameter, not just retrieving it from options within the function. We can also remove the parameter if you like the other approach better. -
Would suggest to keep the
build_rmds_parallel()
, as it gives users an easy way to get parallelization without having to implement themselves, using eitheroptions("blogdown.build_rmds" = blogdown:::build_rmds_parallel)
or (assuming we keep the parameter) calling directly
blogdown::build_site(build_fun = blogdown:::build_rmds_parallel)
102e98f
to
129cf50
Compare
Just some thoughts about letting user choose how to do parallel. 💭
Thanks for this feature by the way ! |
Thanks for the feedback!
|
Hi @yihui, do we still want to move this forward? |
This PR proposes an option to
build_site()
using multiple parallel-running R processes, utilizing only the base packageparallel
. This can result in significant speed improvements with hardware common in 2019.To enable the parallelization, the user must specify 2 options:
The functionality is only triggered if:
blogdown.use_parallel
isTRUE
blogdown.use_parallel.cores
is> 1
files
is> 1
parallel
package is availableIf this direction of functionality is accepted, we can make the implementation less conservative and easier to use.