qubitdigital / qubit-sdk-ios

Qubit iOS SDK
https://docs.coveo.com/en/qbb1t310/coveo-experimentation-hub/build-server-experiences
MIT License
5 stars 5 forks source link

Slow placement fetching #34

Open AdnanHamzabegovic opened 2 years ago

AdnanHamzabegovic commented 2 years ago

We're having an issue where Qubit placement fetching is too slow. To give more context, once our home screen appears, we fetch 6 placements and show various views to the user based on placement content received. However, the placements are taking too much time to process, frequently over 10 seconds. This causes a noticeable delay between the time our users see the home screen, and when the Qubit related content appears. It's not a networking issue, the API requests usually take less than 300 ms.

Using Time Profiler I can see that the app spends most of its CPU time on QubitSDK. I believe, the issue is due to QBDispatchQueueService, all of the DispatchQueues created have a quality-of-service set to background. This simply doesn't give us enough resources for a timely UI update. Since we're using Qubit content to update the UI, userInteractive would be more appropriate.

I've verified this via Time Profiler, if I switch the quality-of-service of placements DispatchQueue from background:

qubit_home_background

to userInteractive:

qubit_home_user_interactive

the time spent processing the placements reduces significantly and Qubit content loads under 2 seconds.

There should be a way of setting the QoS on a particular DispatchQueue in QBDispatchQueueService.

hporter commented 2 years ago

@AdnanHamzabegovic - Many thanks for taking the time to report this issue. We'll get the team to take a look at what we can do here to improve performance as you suggest, for the upcoming releases.