{ "id": "174340", "key": "AC-6427", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "10000", "description": "", "name": "Done" }, "resolutiondate": "2019-12-21T07:25:56.000+0000", "created": "2019-11-06T12:57:21.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "updated": "2019-12-21T07:25:56.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [], "description": "We are experiencing a significant slowdown on Android when fetching data from an encrypted database using the appcelerator.encrypteddatabase module v3.1.0.\r\n\r\nUsing the sample todo app provided with the module running on a Nexus 6 device, when profiling the fetch calls, we are experiencing times of up to 1.5 seconds per fetch. For comparison, when fetching from a standard database without encryption, the same calls are taking around 0.058s.\r\n\r\nWe have currently tried implementing suggestions from AC-6207, however these have had no effect.", "attachment": [ { "id": "67161", "filename": "EncryptedDB_Log.txt", "author": { "name": "asankey", "key": "asankey", "displayName": "Andrew Sankey", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-12-03T09:08:33.000+0000", "size": 37716, "mimeType": "text/plain" }, { "id": "67162", "filename": "StandardDB_Log.txt", "author": { "name": "asankey", "key": "asankey", "displayName": "Andrew Sankey", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-12-03T09:08:38.000+0000", "size": 36347, "mimeType": "text/plain" } ], "flagged": false, "summary": "EncryptedDB - Android - Fetching from db very slow.", "creator": { "name": "asankey", "key": "asankey", "displayName": "Andrew Sankey", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "asankey", "key": "asankey", "displayName": "Andrew Sankey", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Nexus 6 Android 7.1.1 (Device)\r\nGoogle Pixel Android 9 (Emulator)\r\nNexus 5X Android 10 (Emulator)", "comment": { "comments": [ { "id": "452970", "author": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "body": "Hello!\r\nThanks for reaching out! Could you please add your SDK version and comparison log for with and without the encryption database?\r\n\r\nThanks ", "updateAuthor": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "created": "2019-12-02T15:47:31.000+0000", "updated": "2019-12-02T16:18:05.000+0000" }, { "id": "452995", "author": { "name": "asankey", "key": "asankey", "displayName": "Andrew Sankey", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The Titanium SDK used is 8.2.0.GA with the appcelerator.encrypteddatabase module v3.1.0.\r\nDevice being used is Motorola Nexus 6 running Android v7.1.1.\r\n\r\nUsing the sample todo app provided by the encrypted database, four todo entries where added to the database, then the fetch was profiled within the showTasks method found in index.js.\r\n\r\nWhen profiled with the encrypted database, these fetches where taking between 1.68 to 1.85 seconds. With the encrypted database removed, the same fetches where only taking approx. 0.05 seconds. \r\n\r\nSee logs attached.\r\n[^EncryptedDB_Log.txt] [^StandardDB_Log.txt] ", "updateAuthor": { "name": "asankey", "key": "asankey", "displayName": "Andrew Sankey", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-12-03T09:09:04.000+0000", "updated": "2019-12-03T09:09:04.000+0000" }, { "id": "453021", "author": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "body": "Hello!\r\nWe use the SQLCipher library to implement encrypted SQLite database support on Android and iOS. They provide the following guidance in improving performance...\r\nhttps://discuss.zetetic.net/t/sqlcipher-performance/14\r\n\r\nSo, transactions should be used when doing multiple INSERTs and UPDATEs as a single batch. And you should be using indexes to reduce the SELECT, INSER, and UPDATE execution times as well. Also, opening the database file is expensive as well and you should leave it open if you are actively using it. Don't open and close it per database transaction.\r\n\r\nNote that execution times on Android are going to be a bit slower compared to iOS because there is \"language-interop\" involved. On iOS, the JavaScript, SQLite, and encryption APIs are all implemented in C, so there is no language interop or extra string copies that need to happen. On Android, there's additional overhead with copying the JavaScript C/C++ stringss to/from Java strings (involves transcoding to/from UTF-8 and UTF-16 too).\r\n\r\n\r\nThanks ", "updateAuthor": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "created": "2019-12-04T14:46:01.000+0000", "updated": "2019-12-04T14:46:01.000+0000" }, { "id": "453062", "author": { "name": "mward", "key": "mward", "displayName": "Matt Ward", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi,\r\nThank you for your response on optimisation, however please can you perform some testing on the issue raised and confirm whether your can or cannot replicate.\r\n\r\nAs outlined in the issue the timings are based on simple fetch statements from the example code you provide with the encrypted module, whilst we understand there is overhead due to the encryption / decryption the fact are this has now risen from milliseconds to seconds over a couple of versions makes this library totally unusable.\r\n\r\nThanks Matt", "updateAuthor": { "name": "mward", "key": "mward", "displayName": "Matt Ward", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-12-06T17:03:46.000+0000", "updated": "2019-12-06T17:03:46.000+0000" }, { "id": "453247", "author": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "body": "Hello!\r\nYes, we can replicate this and it is not a platform bug.We use the SQLCipher library to implement encrypted SQLite database support on Android and iOS. Writes/read to file with encryption is especially expensive. To significantly improve performance, you need to reduce the number of file writes via database \"transactions\".\r\n\r\nThanks ", "updateAuthor": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "created": "2019-12-19T13:11:02.000+0000", "updated": "2019-12-19T13:11:02.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }