Re: [Rd] Modifying R_CheckStack for a speed increase

From: Byron Ellis <byron.ellis_at_gmail.com>
Date: Wed, 29 Aug 2007 13:58:35 -0700

Alternatively, if you actually wanted to keep the 0.95 you could use

usage > R_CStackLimit - (R_CStackLimit >> 4)

and probably get close enough to 0.95 as it makes no difference or go with 5 and get something more like 97%. At any rate, you'd avoid floating point.

On 8/29/07, Stephen Milborrow <milbo_at_sonic.net> wrote:
> Greetings R developers,
>
> R will run a little faster when executing "pure R" code if the function
> R_CheckStack() is modified.
>
> With the modification, the following code for example runs 15% faster
> (compared to a virgin R-2.5.1 on my Windows XP machine):
>
> N = 1e7
> foo <- function(x)
> {
> for (i in 1:N)
> x <- x + 1
> x
> }
> foo(0)
>
> The crux of the modification is to change the following line in
> R_CheckStack()
>
> if(R_CStackLimit != -1 && usage > 0.95 * R_CStackLimit) {...
>
> to
>
> if(usage > R_CStackLen) { ...
>
> Details and modified sources can be found at
> ftp://ftp.sonic.net/pub/users/milbo.
>
> Regards,
> Stephen
>
> http://milbo.users.sonic.net
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Byron Ellis (byron.ellis_at_gmail.com)
"Oook" -- The Librarian

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 29 Aug 2007 - 21:02:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 29 Aug 2007 - 21:40:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.