Re: [Rd] serialize() takes too long when serializing to a raw vector

From: Luke Tierney <luke_at_stat.uiowa.edu>
Date: Thu 25 Jan 2007 - 14:19:37 GMT

There was an error in the buffer allocation code that caused realloc to be called far more often than needed; on systems where realloc is slow this will cause problems. Will be fixed shortly in R-devel and R-patched.

Best,

luke

On Thu, 25 Jan 2007, Ashish Kulkarni wrote:

> 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
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke@stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Jan 26 01:31:56 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 25 Jan 2007 - 15:31:15 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.