Skip to content
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

Make Rcpp::exception thread-safe #1043

Merged
merged 5 commits into from
Feb 12, 2020
Merged

Conversation

jpritikin
Copy link
Contributor

Pull Request Template for Rcpp

See the discussion thread on rcpp-devel.

I don't think new tests are a great idea. It would be tricky to reliably fail by throwing the old thread-unsafe version of Rcpp::exception.

Checklist

  • Code compiles correctly
  • R CMD check still passes all tests
  • Prefereably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

@eddelbuettel
Copy link
Member

Well this falls short on

  • issue ticket with prior discussion in order to establish consensus about what to change, rather than throwing a PR over the fence
  • does not demonstrate lack of impact on reverse dependencies, and it is not fair of you to assume I have to do it for you

@eddelbuettel
Copy link
Member

eddelbuettel commented Feb 9, 2020

Also, I did point out to you on rcpp-devel that we had extensive discussions around that. Maybe take a moment and look at

which may be relevant. There is much more via a simple search for 'exception' among closed PRs.

@jpritikin
Copy link
Contributor Author

jpritikin commented Feb 9, 2020

issue ticket with prior discussion in order to establish consensus about what to change, rather than throwing a PR over the fence

I'm happy to open an issue, but why not just have the discussion here?

Also, I did point out to you on rcpp-devel that we had extensive discussions around that.

Hm, I didn't see these because I searched issues instead of PRs. The only one that looks relevant is #868. It seems like this PR was incomplete because rcpp_set_stack_trace was not conditioned on include_call. So I am happy to add another commit to obey include_call if you think that is the right thing to do.

Basically, my approach here was to make Rcpp::exception thread-safe and otherwise change as little as possible. So what's the next step?

@jpritikin
Copy link
Contributor Author

jpritikin commented Feb 9, 2020

does not demonstrate lack of impact on reverse dependencies, and it is not fair of you to assume I have to do it for you

What's an efficient way to demonstrate a lack of impact on reverse dependencies? There are a zillion packages that depend on Rcpp.

@kevinushey
Copy link
Contributor

This requires a reverse depends check, which does imply running R CMD check on all client packages of Rcpp. @eddelbuettel usually runs these after PRs which may be disruptive. (There's also the revdepcheck package for doing these kinds of checks as well)

@eddelbuettel
Copy link
Member

eddelbuettel commented Feb 9, 2020

I wrote a package for that (see prrd) which I use on a somewhat underpowered VM I have a courtesy account on, but that box is busy today rev.dep checking RcppArmadillo which I submitted. That takes ~ 6 hours, Doing Rcpp takes 18+ hours. And I have some work to do today so I cannot dedicated my Sunday for doing the work for PRs we have not deemed necessary yet, and which go fairly deep into inner Rcpp guts where we needed half-a-dozen PRs to get to where we are today.

Also, how to do reverse dependency checks is otherwise not a secret, discussed on the R mailing lists, supported by base R and several add-on packages.

@eddelbuettel
Copy link
Member

There is no impact on reverse dependencies. I merely reorganized the existing code.

"Beware of bugs in the above code; I have only proved it correct, not tried it.". -- Donald Knuth

@jpritikin
Copy link
Contributor Author

This requires a reverse depends check, which does imply running R CMD check on all client packages of Rcpp.

Wow. Okay, I kicked off the job.

Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, but I would prefer to keep the old stack_trace routine registered. (It's okay if it's just a stub that returns R_NilValue)

inst/include/Rcpp/exceptions.h Show resolved Hide resolved
inst/include/Rcpp/routines.h Outdated Show resolved Hide resolved
inst/include/Rcpp/exceptions_impl.h Show resolved Hide resolved
inst/include/Rcpp/exceptions_impl.h Show resolved Hide resolved
inst/NEWS.Rd Outdated Show resolved Hide resolved
inst/NEWS.Rd Outdated Show resolved Hide resolved
inst/include/Rcpp/exceptions.h Outdated Show resolved Hide resolved
@eddelbuettel
Copy link
Member

@lionel- I couldn't add you to 'request a code review' but it would be good if you could look at this too. If you have a few moments in the next few days it would be appreciated!

@jpritikin
Copy link
Contributor Author

jpritikin commented Feb 9, 2020

Also, how to do reverse dependency checks is otherwise not a secret, discussed on the R mailing lists, supported by base R and several add-on packages.

If you are so tired of answering, you might add some hints in the Contributing.md file.

@eddelbuettel
Copy link
Member

The file, like everything else here, is based on volunteer effort and time, and in fact fairly recent. It appears to have helped as well because your PR, while clearly not ready yet or consensus-based, did in fact 'tick off' a couple of boxes I consider helpful.

If you have a suggestion to make for the file, why not raise an issue ticket and suggest new wording?

Lastly, I am sorry but as I recall you too have multiple CRAN uploads under your belt and state each time you do one that you checked reverse depends (if there any) for your package. In other words you were already supposed to know this, which is why I allowed myself to use short hand.

@jpritikin
Copy link
Contributor Author

Lastly, I am sorry but as I recall you too have multiple CRAN uploads under your belt and state each time you do one that you checked reverse depends (if there any) for your package. In other words you were already supposed to know this, which is why I allowed myself to use short hand.

I do indeed have a primitive script to check reverse depends, but nowhere near as polished as the scripts you suggested. It is one thing to check when there are less than 10 revdeps, and other thing entirely when there are more than 2000. Cheers!

@eddelbuettel
Copy link
Member

1857 as of today. We omit Suggests:.

And I am aware that this is a lot of work. I have been doing this diligently for some time now: https://github.com/RcppCore/rcpp-logs

It is to the benefit of everybody who depends on Rcpp, i.e. all of use here and of course you too. And if "stuff breaks" I have to deal with it which is why I lean towards the conservative side when it comes to unannounced PRs going deep into internals.

And as a whole we could do better around CRAN and tooling but alas there is always so much to do and so little time. Again, if you think you can make the process better please do not hold back (and I of course do not speak for CRAN as nobody does).

@lionel-
Copy link
Contributor

lionel- commented Feb 10, 2020

LGTM!

@jpritikin
Copy link
Contributor Author

I tried to run revdepcheck overnight and my laptop ran out of memory. Sorry but it seems that I don't have access to big enough hardware to run the check. I would appreciate it if somebody else can do it. No hurry; This can happen at your convenience.

@eddelbuettel
Copy link
Member

Now that RcppArmadillo is updated on CRAN, I can turn this on. Runs unattended in a (very remote to me) data center anyway once I launch. But what about comments / requests for changes Kevin made yesterday? (I didn't have time to look in detail, was busy shepherding RcppArmadillo and cranking out a paper draft...)

@jpritikin
Copy link
Contributor Author

But what about comments / requests for changes Kevin made yesterday?

I believe that I have addressed them.

@eddelbuettel
Copy link
Member

And just to be sure: you squashed/rebased your several commits back into one? It is a little hard to see what changed when in that case. Possibly nicer for merged history yet harder for PR assessment...

@jpritikin
Copy link
Contributor Author

jpritikin commented Feb 10, 2020

And just to be sure: you squashed/rebased your several commits back into one? It is a little hard to see what changed when in that case. Possibly nicer for merged history yet harder for PR assessment...

Yeah, I wasn't sure which kind of history was preferred. That's another point to add to the Contributing.md file.

@eddelbuettel
Copy link
Member

Well I guess all we know now is that I just wasted the last few minutes preparing a test tarball.

@eddelbuettel
Copy link
Member

And I am in no position to assess what just changed. That goes against the entire spirit of the PR we all just spent 24 hours on. Why?

@jpritikin
Copy link
Contributor Author

And I am in no position to assess what just changed. That goes against the entire spirit of the PR we all just spent 24 hours on. Why?

I changed the authorship in the comment. That's it. From now on, I'll add commits instead of squashing.

@jpritikin
Copy link
Contributor Author

If you want, I can unsquash the commits. But that would require another force push. Let me know.

@eddelbuettel
Copy link
Member

I would appreciate that as it will no longer hide your work and make it inaccessible. It is also how the rest the world works. If and when we're done you can still squash, or I could squash-merge, ...

+ Move NEWS.Rd entries to the bottom of the relevant section
+ Restore GET_STACKTRACE macro
+ Move open brace to conform to code style
+ Add copywrite comment block to Rcpp/exceptions_impl.h
+ Restore useless stack_trace API in Rcpp/routines.h
+ Restore RCPP_REGISTER(stack_trace)
@eddelbuettel
Copy link
Member

Jeebus.

Did you just push AGAIN?

@eddelbuettel
Copy link
Member

eddelbuettel commented Feb 10, 2020

The 👎 was a discouragement. As in: "no, I would prefer if you not pushed again".

@jpritikin
Copy link
Contributor Author

jpritikin commented Feb 10, 2020

I would appreciate that as it will no longer hide your work and make it inaccessible. It is also how the rest the world works. If and when we're done you can still squash, or I could squash-merge, ...

The -1 was a discouragement. As I, "no, I would prefer if you not pushed again".

What the heck? You are giving contradictory instructions within the span of 30 minutes. Yeah, I pushed again to unsquash the commits.

Sorry, I didn't notice the thumbs down emoji until it was too late.

@eddelbuettel
Copy link
Member

I'll unsubscribe from this thread now. I actually have work to do.

@eddelbuettel
Copy link
Member

@kevinushey When you have a moment, can you take a look at the changes made in response to you code review comments? I have "unresolved" these; commonly the person who raises an issue gets to declare it resolved (rather than the person responding, but many things were a little unusual here...)

I had started one full reverse-depends which was promptly partially invalidated by forced pushes, but maybe that won't happen again either. In any, results from the rev.dep runs are in RcppCore/rcpp-logs@dc22889 and RcppCore/rcpp-logs@6811463. Result are pretty stunning -- essentially only three fails on the last run all of which seem internal to the affected packages (but as usual I do skip a few for various reasons).

So in sum no issue from here: looks good. Shout-out also to @lionel- for taking a look, appreciate it,

Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; just two minor nitpicks.

ChangeLog Outdated
* inst/include/Rcpp/exceptions.h: Make thread-safe
* inst/include/Rcpp/exceptions_impl.h: New home for code moved
from inst/include/Rcpp/routines.h and src/api.cpp
* src/rcpp_init.cpp: stack_trace no longer exported as an R API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is no longer true I think?

@@ -0,0 +1,88 @@
// exceptions_impl.h: Rcpp R/C++ interface class library -- exceptions
//
// Copyright (C) 2020 Joshua N. Pritikin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should preserve the old author names as well (adding yourself is okay since you've also made changes)

@eddelbuettel
Copy link
Member

I can take care of the cleanup on the header and ChangeLog and NEWS entries.

@jpritikin
Copy link
Contributor Author

Thanks all! Sorry again for the force pushes.

@eddelbuettel
Copy link
Member

It's ok, I think we're all coming closer to the same page regarding process now.

Do you want to do another commit with touch-ups? Or do you want me to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants