-
Notifications
You must be signed in to change notification settings - Fork 37
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
Refactor method-dispatch.c
#483
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.
I cannot really approve (as I did not study the check failures),
but congratulations on this refactoring, including no longer working with "promise-property"s which really are meant to be off-API
After exploring the removal of That said, I did update non-API calls where possible while I was at it. I also addressed all rchk flagged warnings (many of which are spurious or false positives, but adding a few extra
|
I thought I had moved on, but woke up this morning with the solution for how to remove |
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.
Nice work!
Does this happen to fix this commented out test?
# method(foo, class_character) <- function(x, ..., z = 1) substitute(z)
# expect_equal(foo("x", z = letters), quote(letters))
I also double checked that we already had a test that ensures that the dispatch argument is only evaluated once, so there's no chance of a regression there.
// Force the promise so we can look up its class. | ||
// However, we preserve and pass along the promise itself so that | ||
// methods can still call substitute() | ||
// Instead of Rf_eval(arg, R_EmptyEnv), we do Rf_eval(name, envir), so that |
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.
Nice!!
Also would you mind doing a little benchmark of before and after just to verify that there's no performance regression? |
I knitted the "performance" vignette locally and compared it before and after, and generally, the performance is similar or slightly faster. I'll verify one last time and post here before merging. |
I tweaked how we pass along the non-dispatch arguments and now |
I ran some quick benchmarks on dispatch by re-rendering the "performance" vignette on this branch and the main branch. At a glance, performance seems to have improved by about 20%. For now, I’m including some screenshots of the vignette diffs. At some point, we may want to set up more consistent and rigorous benchmarks to track performance over time. # Helper function to install and render vignette
render_vignette() {
local branch=$(git branch --show-current)
local output_file="performance_${branch}.md"
local output_dir="~/github/RConsortium/S7/benchmarks/${branch}"
# Install package and render vignette (warmup and actual run)
Rscript -e 'remotes::install_local(force=TRUE)'
Rscript -e "rmarkdown::render('~/github/RConsortium/S7/vignettes/performance.Rmd', encoding = 'UTF-8', output_format = 'github_document', output_file = '${output_file}', output_dir = '${output_dir}');"
Rscript -e "rmarkdown::render('~/github/RConsortium/S7/vignettes/performance.Rmd', encoding = 'UTF-8', output_format = 'github_document', output_file = '${output_file}', output_dir = '${output_dir}');"
}
# Render vignette on main branch
git switch main
render_vignette "main"
# Render vignette on PR branch
export branch_name=rchk-and-non-API-fixes
git switch $branch_name
render_vignette $branch_name
# Diff the two generated Markdown files
code --diff ~/github/RConsortium/S7/benchmarks/$branch_name/performance_$branch_name.md ~/github/RConsortium/S7/benchmarks/main/performance_main.md (this branch on the left, main branch on the right) |
Great! Thanks so much for all your work on this. |
Should we add a test for the visibility issue? |
There’s already a unit test here: S7/tests/testthat/test-method-dispatch.R Lines 190 to 202 in 498cfad
|
Oh yeah, that's perfect. I thought it was a new feature due to the use of |
This PR has fixes for current
rchk
warning, as well as non-API usage warnings.rchk warnings:
https://raw.githubusercontent.com/kalibera/cran-checks/master/rchk/results/S7.out
non-API: #471