-
Notifications
You must be signed in to change notification settings - Fork 20
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
Performance issues after updating to sqlcipher-android from android-database-sqlcipher #27
Comments
Hi @eygraber, It appears your application is opening many connections to the same, or different databases. The log statement for keying operation returning Do you have a large number of database files you maintain connections to? If you only have a single database, it would be good to review why the application appears to open the connection repeatedly. |
I only have one database file and access to it is managed by a singleton that opens the connection when it is instantiated. There is a 3rd party layer in between that I'm investigating. Is the design of sqlcipher-android different than android-database-sqlcipher in this regard? Because there's no performance issue with the same code using android-database-sqlcipher. |
Hi @eygraber, Yes,
|
That sounds like it may be it. I'm using WAL and when the app starts it makes a bunch of parallel API calls and writes their responses to the db. Is there any way to configure the pooling so I can test if that's the issue? |
Hi @eygraber, The connection pool isn't configurable currently. Can you try disabling WAL mode to see if your performance behavior changes? |
Yes disabling WAL resolves the performance issues. I still see |
Hi @eygraber, Do you have a small example where that is occurring with a single connection and WAL mode disabled? The connection pool does distinguish between a primary and non-primary connection based on the connection flags. |
I'm sorry I don't. This is a pretty large app that I can't share. I'll see if I can get it to happen in a repro project. |
Hi @developernotes, I'm also facing this issue after migrating to sqlcipher. Any suggestions to resolve the issue unblock us. Please check this android example where I've implementated sqlcipher and observing JNI issue. Logs from this sample: 2024-04-17 17:51:33.993 9710-9710 SQLiteConnection com.ex.myapplication I Database keying operation returned:0 |
Hey @developernotes after migrating to sqlcipher-android I can clearly see that, it is taking much time to return result. Steps -
|
Hi @EpariNigam, I believe what you are seeing can be attributed to key derivation within your sample. If you adjust your
|
Hey @developernotes Is there no other solution, other than this? Is it like on new library the key derivation is slower compared to old library or was there no key derivation technique used in old library? |
@EpariNigam The number of key derivation rounds was increased in SQLCipher 4 by a factor of 4x. This was to increase security against brute force and dictionary attacks. You have a couple options:
Regardless, before doing either of those, you should review the general performance optimization guidelines for your application. If you are adhering to the guidelines and using long running connections the impact of key derivation should be very minimal, since it only happens once per connection. |
@EpariNigam disregard my earlier comment. It was directed more at general performance of key derivation, which I now recognize is different than the issue you're facing. We can take a look at this a bit closer, however, I cannot provide a time frame for an update at the moment. |
Hey @sjlombardo, Thanks for your reply. Will look forward on further insights on this. |
Hey @developernotes @sjlombardo, Any update on this? |
Hey @sjlombardo @developernotes any update on this? |
I updated my app from android-database-sqlcipher 4.5.4 to sqlcipher-android 4.5.5 (I also tried sqlcipher-android 4.5.4 and have the same issue).
When my app starts I make a few network calls and store the responses in the db. After the update to sqlcipher-android the startup performance of my app is absolutely trashed. It takes multiple seconds for my UI to render. I see the following in the logs:
This only seems to happen on a cold app open, and happens on both debug and release builds.
I'm trying to profile the build to see what's going on, but Android Studio isn't cooperating at the moment.
The text was updated successfully, but these errors were encountered: