[Rcpp-devel] Rcpp_fast_eval

Iñaki Úcar i.ucar86 at gmail.com
Sun Jun 10 09:53:48 CEST 2018


Understood, thanks, Kevin and Qiang, for your response. Those numbers
are really impressive!, so special kudos to Lionel, Luke and everyone
involved in this new evaluation path for their efforts.

Looking forward to seeing these usages ported to the new
Rcpp_fast_eval. This will be a *huge* performance improvement for my
simulator, which compulsorily needs to make an intensive use of R
function evaluation from C++.

Iñaki
El dom., 10 jun. 2018 a las 4:07, Qiang Kou (<qkou at iu.edu>) escribió:
>
> I think Kevin is right.
>
> The Rcpp Function is still using the old API: https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/Function.h#L82
>
> After changing to Rcpp_fast_eval in Rcpp Function, the timing result on my laptop is as follow:
>
> > system.time(old_api(func, 1e5))
>    user  system elapsed
>   1.025   0.000   1.025
> > system.time(new_api(func, 1e5))
>    user  system elapsed
>   0.025   0.000   0.025
>
> I believe this is what Inaki expected.
>
> Best wishes,
>
> Qiang Kou
>
>
>
> On Sat, Jun 9, 2018 at 8:15 PM, Kevin Ushey <kevinushey at gmail.com> wrote:
>>
>> I think this is mostly because we still haven't ported the majority of usages of Rcpp_eval() to the new Rcpp_fast_eval(), so by default users are still getting the slower Rcpp_eval(). Compare e.g.
>>
>> Rcpp::sourceCpp(code='
>>   #include <Rcpp.h>
>>   using namespace Rcpp;
>>
>>   // [[Rcpp::export]]
>>   void Rcpp_eval_old(SEXP expr, int n) {
>>     for (int i = 0; i < n; i++)
>>       Rcpp_eval(expr, R_GlobalEnv);
>>   }'
>> )
>>
>> Rcpp::sourceCpp(code='
>>   #define RCPP_PROTECTED_EVAL
>>   #include <Rcpp.h>
>>   using namespace Rcpp;
>>
>>   // [[Rcpp::export]]
>>   void Rcpp_eval_new(SEXP expr, int n) {
>>     for (int i = 0; i < n; i++)
>>        Rcpp_fast_eval(expr, R_GlobalEnv);
>>   }')
>>
>> system.time(Rcpp_eval_old(quote(1 + 1), 1E5L))
>> system.time(Rcpp_eval_new(quote(1 + 1), 1E5L))
>>
>>
>> I get:
>>
>> > system.time(Rcpp_eval_old(quote(1 + 1), 1E5L))
>>    user  system elapsed
>>   1.198   0.003   1.203
>> > system.time(Rcpp_eval_new(quote(1 + 1), 1E5L))
>>    user  system elapsed
>>   0.118   0.034   0.151
>>
>>
>> We'll take a closer look next week.
>>
>> On Sat, Jun 9, 2018 at 4:40 AM Iñaki Úcar <i.ucar86 at gmail.com> wrote:
>>>
>>> Hi all,
>>>
>>> I've followed with interest the development of the new evaluation API.
>>> Now that it's finally merged, I was testing it. Perhaps I'm mistaken,
>>> but shouldn't we expect a performance improvement in code such as the
>>> following?
>>>
>>> Rcpp::sourceCpp(code='
>>>   #include <Rcpp.h>
>>>   using namespace Rcpp;
>>>
>>>   // [[Rcpp::export]]
>>>   void old_api(Function func, int n) {
>>>     for (int i=0; i<n; i++) func();
>>>   }'
>>> )
>>>
>>> Rcpp::sourceCpp(code='
>>>   #define RCPP_PROTECTED_EVAL
>>>   #include <Rcpp.h>
>>>   using namespace Rcpp;
>>>
>>>   // [[Rcpp::export]]
>>>   void new_api(Function func, int n) {
>>>     for (int i=0; i<n; i++) func();
>>>   }'
>>> )
>>>
>>> func <- function() 1
>>> system.time(old_api(func, 1e5))
>>> system.time(new_api(func, 1e5))
>>>
>>> Regards,
>>> Iñaki
>>> _______________________________________________
>>> 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
>>
>>
>> _______________________________________________
>> 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
>
>


-- 
Iñaki Úcar
http://www.enchufa2.es
@Enchufa2


More information about the Rcpp-devel mailing list