-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Switching from Rcpp_eval to Rcpp_fast_eval. close #866 #867
Conversation
Codecov Report
@@ Coverage Diff @@
## master #867 +/- ##
==========================================
+ Coverage 90.21% 90.22% +<.01%
==========================================
Files 70 70
Lines 3261 3263 +2
==========================================
+ Hits 2942 2944 +2
Misses 319 319
Continue to review full report at Codecov.
|
Passing Travis is an excellent first step :) |
Looks good. Though, the switch over is missing in Lines 30 to 32 in 5d5cdb8
Lines 99 to 101 in 5d5cdb8
Lines 141 to 143 in 5d5cdb8
|
@thirdwing Why did you switch back to |
@Enchufa2 I have some linking errors on one machine after changing |
No issues in rev.dep, results committed in rcpp-logs repo under RcppCore/rcpp-logs@8d355ce |
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.
"Textual" substitution is very clean; rev. deps are fine; happy to merge this. We can look into the remaining file / other issues in a follow-up PR as needed
This PR looks good to me as well. @lionel- any reservations around using |
If @thirdwing Have you tested this with protect-unwind enabled? You can enable it by adding
I was thinking we should first get a Rcpp release with protect-unwind disabled by default, then enable it in our packages to get some user exposure, and only then turn it on by default in Rcpp. |
I will once again run a second rev.dep with the Agreed that this should be safe to merge as is. |
Will this be on R 3.5? If R 3.4 the define will not have an effect.
On second thought this might cause trouble. Switching to fast eval means errors will be rethrown as is instead of being wrapped in a I think it's the right move to eventually switch to fast eval, but it might not be as smooth a transition as we could hope for. So it might be more prudent to first enable protect-unwind and only then switch to fast eval throughout Rcpp, so we can more easily assess the impact of enabling protect-unwind on revdep checks. |
Crap. Time to bite the bullet I suppose and rebuild the rev.dep checker. |
With R 3.5.0 and
when installing Rcpp. If I substitute Edit: I managed to borrow an idle machine, although not very powerful. Revdep checking now with the changes above. It might take a while. |
R 3.5.0 without the I just started R 3.5.0 with the |
I think the linking problem was introduced by me in a previous PR. The simplest workaround is to use |
Using |
In barrier.cpp, what we evaluate is 'getNamespace("Rcpp")'. Of course, it is better to call this in a try-catch manner. This will cause some potential linking problem.
@Enchufa2 Can you try the code again with |
I'm still running revdeps in 3.5.0 with the flag enabled in Rcpp, but as I
said, the machine is not very powerful and even building the environment
was painful. I had to exclude some packages due to memory problems (4GB)
while compiling (e.g., all Stan-based stuff), and I excluded Bioc-based
stuff too.
So at this rate, probably Dirk's checks will end before mine. :) But so
far, it looks good: 650 succeeded, and a few failures due to missing
dependencies (so my fault).
|
All "mostly" good here too with the
We could still merge as |
Regression alert: packages
all fail their tests with this version of the PR (ie |
Happy to, could you link to or send me the logs please? Did you run the checks on master or on this branch? |
This branch, once without the define, once with. That second run had an imperfect Not my machine, so not easy for access. I will tar them up and put them on my webserver. Good enough? I'll DM you the URL. |
Same here. |
I am leaning towards merging as is, despite the three known regressions as it is still opt-in with the Any thoughts? |
I am looking into the checking error in |
@@ -97,7 +95,7 @@ SEXP get_rcpp_cache() { | |||
SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table | |||
Rcpp::Shield<SEXP> RcppString(Rf_mkString("Rcpp")); | |||
Rcpp::Shield<SEXP> call(Rf_lang2(getNamespaceSym, RcppString)); | |||
Rcpp::Shield<SEXP> RCPP(Rcpp_eval(call, R_GlobalEnv)); | |||
Rcpp::Shield<SEXP> RCPP(Rf_eval(call, R_GlobalEnv)); |
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.
This should be evaluated in base or in the Rcpp namespace.
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.
Most (all?) of these Rcpp_eval()
/ Rcpp_fast_eval()
actually :)
Probably best to make these changes in another PR. And merge / check that PR before this one.
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.
Or modify this one and test it again?
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 was thinking a different PR would make things easier should this one be reversed.
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.
True. On the other hand this one "does no harm" / has no effect until the #define
. So we could merge, merge the two smaller ones behind it and have a new baseline to work from. We surely have different paths forward...
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 think you can send another PR and I will reverse this commit.
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.
What do you mean? This PR is three commits. What do you suggest reversing?
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 mean the changes in barrier.cpp
.
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.
Could do. And test that again, or first against those three? And wasn't there a link issue?
I can reproduce the failures. tidyxl is ok (it's failing because it's checking the error string). Working on figuring out the other two between meetings (it's the RStudio work week). I don't think we should merge this PR right now because master doesn't have the failures, so there may be something wrong here. |
The V8 issue is because Rcpp code is run in callbacks: https://github.com/jeroen/V8/blob/c67abd98797e488adc941ce67097b06e6547f6dc/src/V8.cpp#L63 @jeroen I think it would be safer not to use Rcpp in such callbacks and use protect-unwind manually. Going to investigate the reticulate error soon. |
@lionel- The error in |
In reticulate we are executing an R function while within a C Python stack
frame. Here is where we execute the R function:
https://github.com/rstudio/reticulate/blob/master/src/python.cpp#L1259-L1272
…On Thu, Jun 14, 2018 at 1:36 PM Qiang Kou (KK) ***@***.***> wrote:
@lionel- <https://github.com/lionel-> The error in reticulate should come
from the changes in inst/include/Rcpp/generated/Function__operator.h
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#867 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGXx4IHx46qoK85kgKDhONtHI9RxfLOks5t8q0RgaJpZM4UhvHm>
.
|
@lionel- I think the error in |
@thirdwing When sourcing a Python script, the getter defined here https://github.com/rstudio/reticulate/blob/43664503884625f55cd4d452228a7a855ce86ce2/R/python.R#L1323 is called from the try-catch block linked by @jjallaire. The getter parses strings as R code but it is passed two non-syntactic values
So The reason we observe a different behaviour is because if you don't catch the error on the R side, it gets printed before initiating the error longjump. Hence catching a longjump from the C++ side without catching it on the R side will always produce the side effect of printing the error message as part of the unwinding. I think in general these longjumps should not be interrupted. The good practice would be to catch the For the cases where you really want to interrupt the longjump, this gets trickier if Rcpp switches to fast_eval everywhere. But we could provide some kind of |
The good news is that it appears fast_eval is doing the right thing in all cases :) |
Oh and the last piece of the puzzle is that unhandled errors are recorded by testthat in a calling handler. So even though the code path eventually succeeds the error is detected and reported to R CMD check. This is another reason not to handle errors on the C++ side without handling them on the R side as well. And either resume the jump or evaluate Rcpp code in a |
So what is the consensus then for next steps? Merge this, have a follow-up PR? |
I think this can be merged and I'll send a follow-up PR with an API to deal with handling of R errors at the C++ level. I'll also look into the eval envs. |
@Enchufa2
This PR ports most of the
Rcpp_eval
toRcpp_fast_eval
.I might need a little more time to double check.