Commit b6453e8
authored
firestore: re-write BackgroundQueue to NOT use the deprecated AsyncTask thread pool (#7376)
This change results in a significant performance improvement of queries
with a large number of documents in their result set.
In my testing, the performance improved by 91% from 3022 ms down to 265
ms on a real device! For some reason, there were _no_ performance gains
on the Android emulator. This must have something to do with how
different Android OS versions manage the threads in the (deprecated)
AsyncTask thread pool.
The test environment was as follows:
- Pixel 7 Pro real device running Android 16.
- Test called collectionRef.whereGreaterThan("foo",
50).get(Source.CACHE) 200 times.
- Calculated the average amount of time it took for the query results to
be received.
- collectionRef is a Firestore collection containing 10,000 documents,
of which 50% match the "whereGreaterThan" filter.
- Local cache had no other documents in it.
- Test app was compiled in "release" mode with
"proguard-android-optimize.txt" r8 configuration.1 parent 9f8a0f1 commit b6453e8
File tree
6 files changed
+110
-74
lines changed- firebase-firestore
- src
- main/java/com/google/firebase/firestore
- local
- util
- test/java/com/google/firebase/firestore/core
6 files changed
+110
-74
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
Lines changed: 10 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| |||
204 | 202 | | |
205 | 203 | | |
206 | 204 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 205 | + | |
211 | 206 | | |
212 | 207 | | |
213 | 208 | | |
214 | 209 | | |
215 | 210 | | |
216 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| |||
Lines changed: 10 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
308 | 306 | | |
309 | 307 | | |
310 | 308 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 309 | + | |
315 | 310 | | |
316 | 311 | | |
317 | 312 | | |
| |||
323 | 318 | | |
324 | 319 | | |
325 | 320 | | |
326 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
| |||
Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
Lines changed: 1 addition & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
991 | 989 | | |
992 | 990 | | |
993 | 991 | | |
994 | | - | |
995 | | - | |
996 | | - | |
997 | | - | |
| 992 | + | |
998 | 993 | | |
999 | 994 | | |
1000 | 995 | | |
| |||
0 commit comments