[rkward-devel] second execution 10 times slower than the first ?

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Tue Jan 26 14:58:09 UTC 2010


Hi,

On Sunday 24 January 2010, Marco Barbàra wrote:
> After the first execution this command takes approximately this amount of
> time. And if I launch it for i in 1:1000000 it takes more than 85
> seconds, compared to 1.2 seconds if launched just after rkward started.
> Closing and restarting rkward makes this behavior reproducible.
> 
> Is that normal? I do not think so.

yes, this is a bit embarassing, but it's a known problem. We have a report 
about it at 
http://sourceforge.net/tracker/?func=detail&aid=1810061&group_id=50231&atid=459010 
.

The problem is, that R provides no direct mechanism to find out, when an object 
has changed. To detect this happening, we replace all objects in the global 
environment with so-called active bindings, every time a command has finished. 
This means, the second time the loop runs, "i" is an active binding, and each 
assignment to it incurs a small hit penalty. In a long for-loop, this can 
become quite noteable.

Workarounds include:
- Running the loop inside a local ({})-statement as shown in the above report
- Removing "i" before running the loop
- Defining the loop inside a function, then calling this function

I'm sure we can do better at this point, and we will, eventually, but we have 
a long list of things we want to work at, and only a limited amount of time...

Many thinks for taking the time to report this, though!

Regards
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20100126/ea09a7ab/attachment.sig>


More information about the Rkward-devel mailing list