-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-29777][SparkR] SparkR::cleanClosure aggressively removes a function required by user function #26429
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
Conversation
|
@mengxr can we cherry-pick this to 2.4.x? |
|
Test build #113409 has finished for PR 26429 at commit
|
| found <- sapply(funcList, function(func) { | ||
| ifelse(identical(func, obj), TRUE, FALSE) | ||
| }) | ||
| if (sum(found) > 0) { |
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.
Discussed offline. The change would lead to dead loop. We should make sure newEnv contains the (cleaned) node.
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.
Is the dead loop case when the same function with the same environments is recursively called in the closure?
|
Test build #113493 has finished for PR 26429 at commit
|
|
Retest this please. |
|
Test build #113519 has finished for PR 26429 at commit
|
|
@shivaram and @felixcheung do you guys have any input on this? |
|
@HyukjinKwon would you please take a look? |
|
retest this please |
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.
LGTM. one question and one nit. Wait, I take it back. Let me take another look.
|
Test build #113738 has finished for PR 26429 at commit
|
R/pkg/tests/fulltests/test_utils.R
Outdated
| f1 <- function(x) x + 1 | ||
| f2 <- function(x) f1(x) + 2 | ||
| user_func <- function(x) { f1(x); f2(x) } | ||
| c_user_func_env <- environment(cleanClosure(user_func)) |
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.
BTW, I think naming c_user_func_env is not preferred (it was discussed here #17590 (comment)) before.
I think it should rather be cUserFuncEnv.
Google guide seems updated rapidly (https://google.github.io/styleguide/Rguide.html).. We will have to update the guide ...
|
Looks fine except two nits: #26429 (comment) and #26429 (comment) |
|
Thanks for reviewing @HyukjinKwon I addressed your comments. |
|
Test build #113814 has finished for PR 26429 at commit
|
|
retest this please |
|
Test build #113827 has finished for PR 26429 at commit
|
|
The test cases should be fixed as of 65a189c |
|
Just needs a rebase? |
|
Looks reasonable to me
…________________________________
|
|
Rebased this. Sorry for the delay. |
|
Test build #114031 has finished for PR 26429 at commit
|
|
Let's give a try. |
What changes were proposed in this pull request?
The implementation for walking through the user function AST and picking referenced variables and functions, had an optimization to skip a branch if it had already seen it. This runs into an interesting problem in the following example
Results in error:
Why are the changes needed?
Bug fix
Does this PR introduce any user-facing change?
No
How was this patch tested?
Unit tests in
test_utils.R