Couchbase Lite performance differences Android Java vs Xamarin

Hi,

At the moment I am tasked with evaluating Couchbase (Server, Lite and Sync Gateway) for a new project.
I created a test application that simulates our use case. One part of this is to pull a large amount of documents from the server. After the pull is complete a View is created to index all documents (and I execute a query to ensure the index is built).

(Note: I am aware of the recommendation to include a pre-built database in the application package. However, this is not possible for all of our use cases.)

I have implemented a test (open empty database + pull 10k small [~1k] documents + create view/run query) with Android native (Java SDK) and Xamarin. The results are:

With Android native it takes around 45sec to pull the documents and to create the index. With Xamarin it takes 3min 30sec. (creating the view/index is roughly equal but Xamarin takes much longer to pull the documents)

Setup Details:

  • Running on Android 7.1.2 on an OnePlus 3
  • Xamarin Version: current version included in Visual Studio 2017
  • Couchbase Lite SDK Java/.NET: 1.4.1
  • Server: Couchbase 5.0 + Sync Gateway 1.5.1 (4 core, 16GB memory). No other devices access the server during testing.
  • Java implementation uses default SQLite storage engine. On Xamarin I tested SystemSQLite and CustomSQLite.

One difference I noticed is that during pull the Xamarin version produces much more output regarding garbage collection in ADB logcat. (so the performance difference is caused by excessive memory allocation/deallocation?)

Is this performance difference expected?
Do you have any suggestion on how to improve performance on Xamarin?

1 Like

Performance on Xamarin Android is a bit tricky. There is not much you can do directly, but if you are evaluating performance I suggest trying out the 2.0 developer builds instead. There is a vast improvement, mostly due to fewer calls across the managed / unmanaged barrier and having a lot of logic in C++ instead (this also helps with allocating fewer GC objects). I also notice that the GC logs are very noisy on Xamarin Android but I’m not sure if I can blame that for performance drops (despite the volume, GC is in general much faster than most other things).

Thank you for your quick response.

I would love to use 2.0 but as there is no official release date announced so far I am not sure if it is an option. We have to start development in January with a first release by end of March. (can’t risk having no stable version of the SDK at time of release)

GC:
Yeah you are probably right. Just an observation on my end.

1 Like

2.0 should be able to replicate 10k small documents in well under a minute, although it will depend on network bandwidth as well as the device’s storage speed and CPU.

I’ve been working on replication today, using a database of 12k small docs as a test case, and it usually takes about 5 seconds on my MacBook Pro. Obviously that’s faster than a mobile device, but not by orders of magnitude.