[R-gui] Getting started on R GUIs

TB thomas.baier at kirchnersoft.com
Mon Jan 12 08:22:37 MET 2004


Anthony,

Anthony Berno <mailto:Anthony_Berno at perlegen.com> wrote:
[...]
> I haven't done much performance testing yet, so it might turn out that
> using the COM server is every bit as fast as using the DLL directly.
> Which would be great! But my primary concern is in getting big
> datasets to R really fast, and getting ones back really fast, since
> the app I'm using is extremely interactive and every bit of speed
> matters. If I could get a vector of 100,000 numbers shipped across in
> less than half a second, that would be great, but that may be an
> unrealistic expectation. 
> 
> Maybe you can comment on this - between having a variant in VB and
> having a vector in R, there are a bunch of marshalling and copying
> steps that appear to take place. Compared to the time required for
> some simple calculations on that vector, do you think that there is
> room for making it faster by using the DLL directly? If you think the
> overhead is very low, I will probably not bother with getting up to
> speed on the DLL and testing it myself, but will just use your server.

In my opinion, the marshalling overhead is not that a big one. Of course,
there is some kind of conversion taking place from VB to R, but this can be
minimized by just "helping" the COM server a bit.

1. Use the correct data types in VB, not just Variants. This will minimize
the number of conversions
   required. For arrays, this rule has to be followed (correct typeing is
required here)
2. The more calls into the COM server are made, the higher the overhead of
COM and marshalling will be.
   Transferring 1 array of 1000 booleans is nearly 1000 times faster than
transferring 1000 booleans
   in distinct function/method calls.
3. Try to do as many computations as possible on the same side of the COM
interface. E.g. even if it is
   more efficient to to some computations in the VB part of your program
instead of in R (because in R
   always some kind of interpreter is invoked), any additional data transfer
required between R and VB
   will cost more.
4. If you don't expect a result from a call to R, use .EvaluateNoReturn
instead of .Evaluate. This will
   prevent data conversion and marshalling back a result which is not used.

Nevertheless, the implementation of data transfer has been done (at least I
hope so) as efficiently as
possible taking into account the general nature of the COM and C interfaces.

Hope this helps

Best,
Thomas



More information about the R-SIG-GUI mailing list