[Rcpp-devel] rcpp overhead

Kaveh Vakili kaveh.vakili at ulb.ac.be
Sun Mar 11 17:04:54 CET 2012


Dear Jared,

thank you on so many levels: 

A) you have understood my question (no, i'm not asking for free consulting,
yes i'm comparing pur c++ and rcpp and yes this is the part of the code 
that has the difference in timing --the rest of the code times roughtly 
the same, no i'm not calling back anything from R and yes, i have no 
experience in rcpp but 2* seems large to me for what is, after all, 
a wraper)

B) I have matched the compiler options exactly (-O3 in both cases). 
I have measured the execution times several times. They are large enough
 6sec vec 29 sec), and the spreads increase with larger input sizes; 


C) you have not been obnoxious or disrespectfull. 


I have been experimenting with this most of yesterday. I can give more details of my experiments if someone is interrested. But i expect to get at least some help *understanding* what is wrong, not sneazy advices on how to read books inside dogs.



>I don't have the answer to his question, but it looks like he's not
>comparing R to Rcpp/C++ but rather "pure" C++ to Rcpp/C++. And the
>suspect code he posted isn't doing anything obviously (to me) silly,
>like repeatedly calling back into R (of course it would have bigger
>problems trying to do that in pure C++ :) )
>
>My thoughts would be to match the compiler options exactly (maybe
>something is optimized in one case but not the other?). Also make sure
>that the execution time is long enough so that actual work dominates,
>and do as many replications as you can. As mentioned previously it
>could be a simple problem with how you're timing the code as well, but
>I can't speak to that.
>
>A 2x difference just from wrapping your code with Rcpp seems extreme
>to me, but I've never measured...
>
>Best,
>-Jared
>
>On Sat, Mar 10, 2012 at 8:09 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>>
>> On 11 March 2012 at 01:33, Kaveh Vakili wrote:
>> |
>> | >Don't take this the wrong way, but we are not here to debug or rewrite your
>> | >code for you.
>> |
>> |
>> | Thanks Dirk, but i'm not asking for this either.
>> |
>> | The code works....only it doesn't time the same.
>> | My question is: is it normal -- is there an
>> | overhead in using rcpp and how large is it,
>> | typically?
>> |
>> | I'm was not even so enclined to post my code
>> | --my question is more general.
>>
>> In that case you get a firm "maybe" in reply.
>>
>> You need to understand that there is still nothing for us to go on.  Define
>> overhead. Relative to what? Do you expect calls of compiled functions to be
>> faster or slower than interpreted? What about recursion?
>>
>> Do your homework, and come back with a well-formed question with measurable
>> objectives. Everything else is just chitchat suitable for a campfire.
>>
>> And again, if you care to _read_ the archives you will find different people
>> posting different result with speed increases ranging anywhere from a 'few
>> times faster' to 'ten (and more) times faster' up to to an increase of
>> several hundred times on a arguably degenerate problem (of a fibonacci
>> recursion).
>>
>> But people also do silly things (eg calling R back each time) and expect it
>> to be faster.  No mas -- this ain't magic pixie dust. If you use it the wrong
>> way, you get out what you put in.
>>
>> Dirk
>>
>> --
>> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
>> dark to read." -- Groucho Marx
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>




More information about the Rcpp-devel mailing list