[Rd] serialize() takes too long when serializing to a raw vector
Ashish Kulkarni
ashish.kulkarni at kalyptorisk.com
Thu Jan 25 14:26:22 CET 2007
Hin-Tak Leung wrote:
>
> It might be interesting to know get some details on your hardware.
>
It's a P4 2.66GHz with a standard Intel motherboard having 1GB RAM.
> On my box, linux native seems to be a little slower than
> your quick.serialize times:
>
> > system.time( serialize(matrix(0, 1000, 1000), NULL) )
> [1] 0.372 0.288 0.692 0.000 0.000
> > system.time( serialize(matrix(0, 2000, 2000), NULL) )
> [1] 1.237 1.195 2.501 0.000 0.000
>
> running R 2.4.1 windows under wine (same box) is a good deal s
> lower, but is not anywhere nearly as slow as yours.
>
> > system.time( serialize(matrix(0, 1000, 1000), NULL) )
> [1] 0.00 0.00 6.08 NA NA
> > system.time( serialize(matrix(0, 2000, 2000), NULL) )
> [1] 0.01 0.01 78.00 NA NA
> >
>
Well, the timings certainly differ quite a bit. What kind of
hardware do you have? I suspect that most of the delay may be
caused by memory reallocation since the size of the output
raw array is not known up front. I would imagine that WINE
would use the system memory allocator, not the one used by
the windows kernel.
> Since you mentioned that you are using Rmpi, there is a possibility
> that you might be calling a different serialize() than base::serialize
> all together???
Nope, I hit this problem while using Rmpi and tracked it down
to .mpi.serialize, which in turn calls base::serialize. From Rmpi:
.mpi.serialize <- function (obj)
{
trans_obj = serialize(obj, NULL)
if (getRversion() >= "2.4.0")
return(trans_obj)
else return(charToRaw(trans_obj))
}
Regards,
ashish
More information about the R-devel
mailing list