'Performance issues when when serialising JSON with larger base64 strings

As a result of a 3rd party integration that only supports file uploading via CURL, which we only found out after completing the implementation as a normal multi-part form and ran into CORS issues, we then had to proxy the requests via our API but took a simpler approach, which also solved/simplified other things of attaching the base64 encoded string for the file(s), as apposed to creating a new multi-part endpoint.

We base64 encode the files byte data and attach it as part of the POST payload, we then noticed some unusual performance issues, a 310kb file takes 20 seconds before the network request is actually started.

After some investigation and CPU profiling, we narrowed it down to the move method as part of darts iterable in the Dio chain. Given the majority of our network requests include lists this made little sense.

To confirm I pulled in the http package and made the network request using that, the time dropped from 2-25s to less than 2, so there is definitely something fishy up with Dio in our instance.

We are on v4.0.0 of Dio and 2.0.1 of Retrofit and owing to other dependencies that we cannot update at this time, we cannot progress further with these packages so it's possible this very likely edge case may be solved, however, I see no issues on Dio or Retrofit that could be related so it's also likely they may not be directly or indirectly causing this.

A solution would be fantastic, as preferably I would. not want to be running 2 network services.

Here is a link to the CPU profile, if that helps any. https://drive.google.com/file/d/1Dh7rEg7c04xxUvTmJB42Zs0RqEmdVPjQ/view?usp=sharing



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source