-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving Read Performance (Primarily Android) #259
Comments
Probably this Java file. I do seem to remember that, when I was testing this last summer, I found that our switch from using Android foreground threads (aka UI thread, aka application thread) to backgrounds threads actually caused a significantly decrease in performance. However, it was already slower than WebSQL at that point. :) Also the background thread has the advantage of not blocking UI interactions. That being said, I'd be more concerned about the fact that this plugin is not passing the PouchDB test suite. :) I would first look there, and it's pretty easy to run: steps are described here. |
Thanks @jfspencer for your help so far-excellent work! @nolanlawson, as I said in #255, the problems with the PouchDB test suite should really be my responsibility, and I will deal with it sometime early next week. I am not surprised that the Android version is measured slower, due to some factors that I will describe sometime later. |
The Android version actually contains two different implementations as described in README.md:
I am assuming that using https://code.google.com/p/sqlite4java/ should not be any slower than using the built-in Android database classes, but we should measure to be sure. At some point, we should measure the iOS version with the FTS3/FTS4/R-Tree compile-time options enabled. I do not expect much difference. I also recommend we run some other major scenarios such as bulk writing and perhaps combination of reading and writing. And don't forget to use profiling to measure where we should consider making improvements. |
Some things that can make the Android version slower than the iOS version:
A couple ideas that could make the Android version faster:
|
According to Instagram anyway, the fastest JSON serializer/desierializer on Android is their IG-JSON. |
Thanks for this feedback, I will add write and read/write tests to the test app. I'll start on the JSON library first then. I'll compare GSON and IG-JSON libraries and see what affect they have. Thanks! |
So it looks like I had a whitelisting configuration issue that was silently failing the tests and made performance worse with in the android sqlite tests. here are the new baseline results. Summary: Tests: Test Results in ms: 2: iOS webSQL: 1813 -- iOS SQLite: 1748 -- Android webSQL: 5316 -- Android SQLite: 5137 3: iOS webSQL: 1862 -- iOS SQLite: 1768 -- Android webSQL: 6262 -- Android SQLite: 5072 4: iOS webSQL: 51 -- iOS SQLite: 48 -- Android webSQL: 210 -- Android SQLite: 197 having looked in to gson/ig-json/jackson I am going to start with jackson for two reasons. first, looking at benchmarks of projects that migrated from org.json to jackson saw 100% performance increase. and Second and almost more compelling is, jackson provides interoperability with org.json so the migration will be pretty smooth. Cordova has an override for execute that provides the raw string. |
Looks like you copy-pasted the same results as before, or am I mistaken somehow? |
Also, you are welcome to explore JSON alternatives but I highly recommend you start with profiling to measure how significant the JSON processing time really is. |
I did copy the test section and then updated the android SQLite numbers and associated percentage differences. I will do some tracing, thanks! |
I just updated the iOS version to build with support for FTS3/FTS4, column metadata, and R-Tree. I don't expect this to have a major effect but cannot say for sure. |
@jfspencer interesting results! I'd be interested to see a comparison of iOS WebSQL to iOS SQLite, though. iOS to Android is not really an apples-to-apples comparison. ;) |
Here is link of two projects, one built with websql the other with sqlite. android(import into Android Studio) and iOS projects have been pre-compiled and are located in their respective platforms/[ios/android] folder for each project. Both projects were produced by ionic.
test hardware
iPhone 6 - iOS 8.3
Nexus 6 - Android 5.1
Results Summary:
Android Falls significantly behind iOS by several seconds in all tests. Android SQLite falls behind Android webSQL with a smaller margin. iOS shows SQLite is slightly faster than webSQL (awesome!).
Tests:
Test Results in ms:
1: iOS webSQL: 1755 -- iOS SQLite: 1748 -- Android webSQL: 5271 -- Android SQLite: 6665
iOS SQLite is 73% faster than Android SQLite
Android webSQL is 21% faster then Android SQLite
2: iOS webSQL: 1813 -- iOS SQLite: 1748 -- Android webSQL: 5316 -- Android SQLite: 7227
iOS SQLite is 76% faster than Android SQLite
Android webSQL is 26% faster then Android SQLite
3: iOS webSQL: 1862 -- iOS SQLite: 1768 -- Android webSQL: 6262 -- Android SQLite: 7980
iOS SQLite is 77% faster than Android SQLite
Android webSQL is 21% faster then Android SQLite
4: iOS webSQL: 51 -- iOS SQLite: 48 -- Android webSQL: 210 -- Android SQLite: 220
iOS SQLite is 78% faster than Android SQLite
Android webSQL is equal Android SQLite
I am personally interested in improving android performance. Hopefully getting it into the iOS performance range. After that I would be interested in further tuning both platforms. Are there any initial thoughts on where I should start?
The text was updated successfully, but these errors were encountered: