xml-rpc-rs icon indicating copy to clipboard operation
xml-rpc-rs copied to clipboard

Very slow download

Open cschramm opened this issue 3 years ago • 1 comments

xml-rs is freaking slow so that it slows down download rates for any connection with more than like 1 MBit/s (even locally!).

I successfully worked around that by implementing and using a Transport wrapper that just adds buffering to the stream:

struct BufTransport {
    inner: RequestBuilder,
}

impl Transport for BufTransport {
    type Stream = BufReader<<RequestBuilder as Transport>::Stream>;

    fn transmit(self, request: &Request<'_>) -> Result<Self::Stream, Box<dyn Error + Send + Sync>> {
        self.inner.transmit(request).map(BufReader::new)
    }
}

(RequestBuilder could be a generic Read of course)

As long as xml-rpc-rs sticks with xml-rs, I guess it's a good idea to use a BufReader in general. I can prepare a pull request if you like.

cschramm avatar Jan 25 '22 14:01 cschramm

To add some numbers: With the standard RequestBuilder transport I observe download rates of about 0.5 MBit/s. With my BufTransport at first the network connection is the limit, then the network goes quiet and it takes a long unsatisfying processing time before I get back the result from call, but overall it's a rate of about 2 to 6 MBit/s locally (i.e. where the download phase is negligible).

cschramm avatar Jan 25 '22 14:01 cschramm