Anki-android: Investigate performance issues

Created on 9 Dec 2015  路  11Comments  路  Source: ankidroid/Anki-Android

Some users have reported performance issues with the 2.5 release. This issue will be used for tracking down the cause of the problem.

Some questions:


    1. Is your AnkiDroid data on an SD card?


    1. What is the path to your AnkiDroid directory (Settings -> Advanced -> Collection path)


    1. In which functions of the application do you encounter slow-downs? Please test things like searching in the card browser and emptying/rebuilding filtered decks. (Mainly, is it happening when reading data, saving data, or both?).


    1. Approximately how many decks and cards are in your collection? Use the card browser see the number of cards (select All decks).


    1. Does your collection have lots of sub-decks? Are they deeply nested (3 or more parents)?

The main concern is whether our recent switch to a different database journaling mode is the cause of the issues. To accurately test for this as the cause we need you to test an older version where this change was an optional setting.

Just to be safe, please sync your collection and ensure you have recent backups. Then, install this apk of a previous release. Note that you may need to uninstall your existing version of AnkiDroid which will clear your preferences.

In this apk there is a setting that switches between database modes: Settings -> Advanced -> Enable write-ahead-logging. Please test out AnkiDroid with this setting enabled and disabled and let us know how the performance of each compares.

Priority-High

All 11 comments

I'm also having performance issues with the latest release. Using the "back" button to switch to the previous card can take up to several seconds.

I'm experiencing bad performance on my device. Here are symptoms and answers to questions:

1) My AnkiDroid data is on an SD card

2) The path is /storage/17F7-802D/AnkiDroid

I had to set this up manually, because I want it to save to my SD card, not internal storage. On my device, since an Android upgrade where I chose to have removable SD card, the path /sdcard/ actually goes to internal storage, and /storage/17F7-802D goes to the real SD card.

3) I get a pause after certain actions, usually when I would expect AnkiDroid to be saving data. The time I notice it for sure is after a card is shown and I select a button (or do a gesture) to indicate "Again" or "Good". At this point, with AnkiDroid 2.5 I sometimes saw a delay of up to 3 seconds before the next card was shown. After upgrading to AnkiDroid 2.6 just the other day it got worse, up to 8 seconds before the next card is shown. The gesture/button is definitely recognised immediately, because the coloured dots are shown immediately, but the next card is not.

Sometimes it does not happen, I think with some decks. On others, I get the pause about every 5 to 10 cards (I think - it might be less but long pauses makes you feel like it is very often).

Also, the 'writing changes to DB' phase of syncing seems to be slower than I expect, but it's difficult to be sure.

4+5) I have about 3000 cards in my collection, roughly split into about 20 decks, none of which are 'sub' decks.

I tried the APK you linked to. With it, I am getting the same 2-3 second pauses I was getting before with 2.5. When I enabled the 'write ahead logging' option, it seems that the frequency of the pauses goes down, but they don't go away entirely (something like once every 20 cards), and can be 4 to 5 seconds. I'll keep this on and see if I have more observations after a while.

I can supply my entire DB if you want, it is not private. I have SDK tools and could get the files off the device from my Linux laptop. I could also run some tests using SDK tools if you want, but my knowledge of Android dev is extremely limited, you'll have to tell me the exactly the commands to run.

I don't recall there being any changes between 2.5 and 2.6 that impacts database transactions so I'm surprised (and somewhat confused) to hear about your experience.

The best thing you could provide would be a log file from a debug session that we can walk through and see exactly where the pauses are occurring. Hopefully the guide on the wiki is clear enough to help you figure out how to do that if you are interested. From the way you've described it, there is also a possibility that some of your cards (or templates) are triggering some condition that takes a really long time to render.

At this stage we are almost certainly not going to re-introduce the WAL journal mode and I had planned on closing this issue after the release went out.

OK, thanks for the pointers, I will hopefully look into that and provide a debug log, in a new issue if necessary, but I won't have time to do it soon, it might be a month or so.

I'm experiencing very similar problems to @spookylukey: I have normal decks but experience occasional long pauses, especially when using the back undo button. Syncing takes ~15s.

I've found that for me, _sometimes_ the issue can be resolved by creating a "fresh" database:

1) Sync to Ankiweb
2) In advanced settings, change the location to a new place, effectively creating a new DB
3) Sync from Ankiweb again, downloading all my data into the new DB.

Sometimes this doesn't work however.

I now have a collection of DBs! One is terrible - every 2 or 3 cards, it pauses for about 8 seconds. It also seems to depend on which deck I'm using. I'm happy to send the devs the DB files, but I'm afraid I won't be able to do any more debugging.

I can take a look if you send me your collection but I doubt there will be anything interesting to learn from it. It seems like your SD card is struggling with small and frequent IO.

@zaz
Tapping back to close an Activity triggers a database save. 15s sync time is normal.

And couldn't the next 10 or so cards be buffered in order to get rid of most of this slow io?

7 芯泻褌褟斜褉褟 2016 谐. 9:29:07 GMT+03:00, Houssam Salem [email protected] 锌懈褕械褌:

I can take a look if you send me your collection but I doubt there will
be anything interesting to learn from it. It seems like your SD card is
struggling with small and frequent IO.

@zaz
Tapping back to close an Activity triggers a database save. 15s sync
time is normal.

You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/ankidroid/Anki-Android/issues/3979#issuecomment-252163423

Potentially, but it would complicate things quite a bit.

I'm closing this but it's not because I am not interested in performance - #4864 - we are implementing analytics where we could put timing monitors in, and there are features in current development tools that allow pinpointing things as well. We just don't have good reproduction scenarios here at the moment. If anyone has a collection that is performing badly and the scenario to make it do so, by all means post it up

FWIW, my performance problems were fixed by buying a faster SD card.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SimonePols picture SimonePols  路  3Comments

Acelya-9028 picture Acelya-9028  路  4Comments

infinyte7 picture infinyte7  路  4Comments

OoDeLally picture OoDeLally  路  4Comments

david-allison-1 picture david-allison-1  路  4Comments