In{s}a(ne)!!
Having missed the earliest entry by Radford last month, due to disconnection in Yosemite, I was stunned to read his three entries of the past month about R performances being significantly modify when changing brackets with curly brackets! I (obviously!) checked on my own machine and found indeed the changes in system.time uncovered by Radford… The worst is that I have a tendency to use redundant brackets to separate entities in long expressions and thus make them more readable (I know, this is debatable!), so each new parenthesis add to the wasted time… Note that it is the same with curly bracket: any extra curly bracket takes some additional computing time…
> f=function(n) for (i in 1:n) x=1/(1+x)
> g=function(n) for (i in 1:n) x=(1/(1+x))
> h=function(n) for (i in 1:n) x=(1+x)^(-1)
> j=function(n) for (i in 1:n) x={1/{1+x}}
> k=function(n) for (i in 1:n) x=1/{1+x}
> x=1
> system.time(f(10^6))
user system elapsed
1.684 0.020 1.705
> system.time(g(10^6))
user system elapsed
1.964 0.012 1.976
> system.time(h(10^6))
user system elapsed
2.452 0.016 2.470
> system.time(j(10^6))
user system elapsed
1.716 0.008 1.725
> system.time(k(10^6))
user system elapsed
1.532 0.016 1.548
In the latest of his posts, Radford lists a series of 14 patches that speed up R up to 25%… That R can face such absurdities is pretty annoying! Given that I am currently fighting testing an ABC algorithm with MCMC inner runs, which takes forever to run, this is even depressing!!! As Radford stresses, “slow speed is a significant impediment to greater use of R, much more so than lack of some wish list of new features.”
May 24, 2011 at 6:47 am
[...] related posts: (automatically generated)In{s}a(ne)!!Sudoku via simulated annealingUpdated R code for Bayesian CoreRadford University moves up to 38 in [...]
April 7, 2011 at 2:40 am
[...] all parentheses ( ) by curly brackets { }. I was inspired to do so by this post (and this, via Xi’Ans Og) over at Radford Neal’s blog. As he pointed out, code that uses parentheses is actually [...]
January 27, 2011 at 6:20 am
[...] which makes a big difference. In a Gibbs sampling loop, where a lot of other computations are done, I still have gain of 25%! For other recommendations (don’t use parentheses where you can avoid them), you can have a look on this post. [...]
September 18, 2010 at 10:13 am
[...] are peculiar to R.After this, several discussion threads where started around the web (for example: 0, 1, 2, 3, 4 ,5, 6 ), but then a comment was made in the R-help mailing list by Jaroslaw Piskorski [...]
September 15, 2010 at 7:45 am
[...] http://xianblog.wordpress.com/2010/09/06/insane/comment-page-4/#comments [...]
September 14, 2010 at 7:27 pm
Random comments:
1. “Simply re-write” is astoundingly naive. There are plenty of examples of re-writes (Lotus 1-2-3 switch from assembler to C, Netscape’s rewrite, KDE4, reference counting in S) that proved far costlier in time and effort than anyone dreamed.
2. Patches to improve the speed of R are a good thing, but not an end-all. I spend far more time developing algorithms, cleaning data, exploring data, trying models than I do in the actual processing time of the data. If you want to talk about optimization, “programmer time” is a much bigger bottleneck than “CPU time”.
3. Shaving milliseconds off CPU time is nice, but shaving hours of head-banging due to terse R documentation and too-cute-to-be-useful examples in the docs would be a far greater contribution to society.
4. I would argue that we need a smaller user base in Computer Science. Statisticians don’t need an elegant, modern, computer language. We need a modern, _simple_ “data analysis environment”.
September 13, 2010 at 11:04 pm
[...] The discussions started in the response for the following blog post on Xi’An’s blog: http://xianblog.wordpress.com/2010/09/06/insane/ [...]
September 13, 2010 at 5:04 pm
I was at Stallman’s talk too, and it wasn’t clear to me he even knows what R *is*. I certainly don’t recall him mentioning it in his 3 hour talk.
Personally I would be much happier to see R move to a more permissive license, not more greedy. For my own open-source projects, I like to encourage people to use it however they want, whether that’s creating more open-source creations on top of it, closed-source commercial projects, simple usage as a library, or “stealing” the code for nefarious purposes (in quotes, because what’s given away can no longer be stolen. Once I give it away, it’s not mine anymore.).
I realize not everyone agrees with me about this, but as a community member I wanted to give voice to this – a lot of people at useR! seemed to feel the same way.
September 13, 2010 at 8:21 am
@Ross Ihaka:
First, it is an honor to get to read your opinion here, thank you so much for taking the time to share your views.
From reading the thread, it is not clear to me if indeed the right course of action should be the creation of a new R (R++ ?!) or revamping the current R.
Two things do come to my mind.
The first is regarding the graphics engine. I don’t think it requires for a new R system, but if we are on the topic of “starting a new”, then on the last useR2010 I had the chance to talk at length with Jeroen oom (the guy behind the ggplot2 web interface) who explained to me how he doesn’t believe the current R graphics engine would be able to support interactive graphics. He also extended to explain how he thinks such an engine could be built, but I won’t go into that now (I also remember there where talks about iPlots extreme to maybe achieve the same thing – but I didn’t see any published progress on that project in the past year).
The second point is regarding the license, and is only to say that I imagine that Richard Stallman would be happy to help out with options of licensing. (he’s latest talk on useR 2010, regarding free software and the various GPL versions, clearly exemplify his passion for the topic)
I hope to see the discussion started here to continue.
Best wishes,
Tal
September 13, 2010 at 12:36 am
[...] start over and build something better” The post on the shortcomings of R has attracted a huge number of readers and Ross Ihaka has now posted a detailed comment that is [...]