Skip to content

Updater speed improvements during "Saving Application Details"

I've been able to reproduce #324 (closed) OutOfMemory errors on an emulator with 12MiB of heap space. This branch did not have an OOM error when updating with F-Droid and F-Droid Archive repos enabled. They successfully update without problem.

Fixes #45 (closed).

The "Saving Application Details" stage of repository updating is where each apk has its suggested version calculated, icon URLs calculated, etc. These all require correlated subqueries resulting in a full scan of the apk table for each row in the app table. This takes in the order of 25 seconds on my Moto X 2nd Gen.

This branch improves this process by doing the queries in an sqlite in-memory database, with the results transferred to the database on disk when done. The time required drops from 25 seconds to ~0.5 seconds on my device.

Note: I was hoping this would also improve the "Processing ..." Part of the udpater, given it was inserting into an in memory table instead of on disk. If it did have any effect, it was negligible though, so that part is still likely slower than it could be. Each 50 apps (and their associated apks) takes between 150ms and 500ms on my Moto X.

Secondary Note: When creating the in memory database, I create indexes for some columns as per before. This technically should slow down the inserts we do, however in practice they had almost no effect. As such, I've left the index creation there because it is required for the correlated subqueries to not suck.

Merge request reports