-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Optimize form download with entities #6372
Conversation
a6d281f
to
db2fd33
Compare
A bit of a random thought -- could we put the form defs in the okhttp cache instead of having to set a real server URL and actually download a file? I think I've mentioned this before but I suspect that the search/pulldata import is artificially slow because of the UI feedback it gives every 100 rows. I tried to run the |
Interesting! The progress reporting happens on another thread, so I'd be surprised if there's any major impact there. I just experimented with removing progress reporting, and it looks like it gains me about a second in
I'm starting to think your device is cursed! Let's have a look at it together later as I'd really like to get numbers from it. |
Oh good, yes, I probably should have just looked at the implementation! I manually timed the This branch's
I previously had several passes on Some possible next steps:
|
Let's focus on some of the 4Gb devices we have for now. Instead of having me do the benchmark check with the A13 at release time, would it be reasonable for @getodk/testers do it as part of regression testing with one of their 4Gb devices for now? |
Yeah, it's feeling like the A13 is a bit of a nightmare to run tests on. We should give it a go manually with a self-signed released build at some point, as it's likely that debuggable builds and the extra overhead of the test runner aren't helping. I'll coordinate a target phone with @getodk/testers.
I'm not sure that I agree. Looking at the entity lists, "entities 100k" only has 7 properties which does not feel unrealistic to me whereas the "narrow" only has two. It's obviously hard to make a call about what's going to be "normal" at the moment, but basing our performance on entities with just two properties feels risky to me. I'm thinking in line with your suggestion above, we just focus on wider 4GB performance for now so we can say something like "we suggest using a device with 4GB or more of RAM for entity lists of 100k with a few properties (up to 7)". |
The thing that's not very realistic is that the 7 properties are uuids. This means they're each 36 characters and have no overlap between values. I agree that 7+ properties is absolutely realistic but my experience so far is that many of the values are short. I believe that there isn't much performance difference between 10 properties with 72 characters between them vs. 2 properties with 72 characters between them, does that sound right? The other unusual thing about uuid values is that there's absolutely no overlap between them. In typical usage, you'd see things like columns that represent a value from a select -- a city, grade, etc. The duplicate strings across the entity list would be interned and use up way less memory. |
Ooof yeah that makes sense. Let's maybe look at improving the tests with a different form in a follow up PR then. I like the idea of 5-7 entities, but with a more normal scale as you suggest. |
Pixel 3a on this branch:
|
Would like to bring that first download time down (although I think it's still with an acceptable range), but I think I'll wait to see where we're at once we merge this and start playing with #6376 as that makes optimizations to both initial and subsequent downloads. Just waiting for review on this one @grzesiek2010. |
|
||
/** | ||
* Prevents doing repeated [Cursor.getColumnIndex] lookups and also works around the lack of | ||
* support for column names including a "." there (due to the mysterious bug 903852). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a full link to that bug? It will be easier to find,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no public reference sadly! The best I can do is the @see
for the comment in the Android source.
@dbemke Yup! I'm guessing that it got fixed for creating the list, but not updating it. |
Tested with success! Verified on a device with Android 10 Verified cases:
|
Tested with Success Verified on device with Android 14 |
Closes #6344
This drops the benchmark target for first time entity form download to 25 seconds. As part of this work, I also fixed a bug related to special characters in property names.
Why is this the best possible solution? Were any other approaches considered?
I just needed to make a few tweaks to get down to 25 seconds. I chose this number due to the results of the new
SearchBenchmarkTest
which measure the performance of forms usingsearch()
. We'd expect the initial form load forsearch()
forms and the initial download for entities forms to be roughly the same as they both insert the same number of rows into a SQLite DB.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This again changes the entity DB structure, so the app should be uninstalled before testing. The main changes here are all related to entity form download so that's the core area to focus on when testing.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest