-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Hold for payment 2021-08-17] [Performance] Optimize AsyncStorage on Android #2667
Comments
Triggered auto assignment to @tgolen ( |
ProposalI will make the step by step witth a standalone RN APP as mentioned and develop what was described here. Finally I will implement the AsyncStorage.multiGet(). |
@mateusbra Please see our Contributing Guidelines for an explanation of what we're looking for in a proposal. |
@arielgreen
|
@kidroca gotcha — thanks. |
Job posting for this has expired. I'll repost to Upwork when we're ready to move forward with this one (I.e., when #2762 is complete). |
@kidroca Are you ready to move forward with this? If so, I’ll recreate the Upwork posting and send over an invite. |
I don't think we should wait for @kidroca -- let's go ahead and get someone working on it asap! It would be great if it could be @kidroca, but it sounds like @mateusbra might also be interested (and probably a whole bunch more). |
Yes, I am ProposalI've already worked on benchmarking and performance capturing logic. I will use a physical Android device - Samsung Galaxy S7 Edge Android 8.0 that tends to have a slow read speed at the moment I'll work and submit a PR against E.cash fork of react-native: https://github.com/Expensify/react-native One question, where should I push the "sample" app from step 1) Create a standalone RN app that benchmarks AsyncStorage
|
For this, I was thinking that it would live in a completely separate repo that you own (a free repo is fine). Would that work? |
Sure |
Upwork posting here. |
Here's some benchmark information so far: Setup
Before AsyncStorage updates10, 000 Operations50, 000 OperationsQuestionsDo you still want me to do 1M tests, for an average of 16ms it would take about 4.5hrs to write 1M entries? I think the fast speeds we see here are due to the fact that operations run in sequence and wait for each other, I've tried saving larger texts (1kb each) and the time is about the same (16.9ms per write, 8.3ms per read) Do you want to make a different benchmark that tries to write using as many parallel requests as possible in an attempt to review the issue I've described above? |
The relatively fast times got me to double check what versions of E.cash and Onyx use:
After a bit more investigation I've found this: AsyncStorage is moving away from the
The latest version of Some additional point we should check with these discoveries:
I'll investigate the new source of Edit: Clarification the benchmarks above are not using |
Wow, amazing find. Yes, let's not invest in abandoned code. Let's definitely redo the benchmark with the latest and greatest. |
Yeah, I agree. That's a good find, I had no idea it was abandoned. Let's
first see if we can upgrade to the latest version, ensure there are no
regressions, and then start benchmarking on that.
…On Mon, Jul 5, 2021 at 1:13 PM David Barrett ***@***.***> wrote:
Do you still want to contribute to AsyncStorage when it's not a part of
@react-native-community <https://github.com/react-native-community>
Wow, amazing find. Yes, let's not invest in abandoned code. Let's
definitely redo the benchmark with the latest and greatest.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2667 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJMAB3ROM73CCDNEHZ2KK3TWH765ANCNFSM44BATT7Q>
.
|
I've updated my fork of Onyx with the latest AsyncStorage and did the same with E.cash
I'll post some before/after benchmark data of E.cash init In the meantime do you want me to open a PR to update Onyx and E.cash with the new AsyncStorage repo? I might have misled you with "abandoned", I think AsyncStorage is still a project maintained by the react-native community but it was moved out for the reasons they've discussed (on what to stay in/out) |
Yeah, go ahead and do a PR to update that lib. Even if it's not totally
abandoned, I think we want to keep whichever is the most active and the
most generally accepted as "official".
…On Tue, Jul 6, 2021 at 11:19 AM Peter Velkov ***@***.***> wrote:
I've updated my fork of Onyx with the latest AsyncStorage and did the same
with E.cash
I've runned with enabling next (Room) and without it, but I can't see any
noticeable improvements
- btw (next/Room) would affect Android only as it's just for that
platform
I'll post some before/after benchmark data of E.cash init
In the meantime do you want me to open a PR to update Onyx and E.cash with
the new AsyncStorage repo?
We can decide if we want next enabled or not after some more tests
------------------------------
I might have misled you with "abandoned", I think AsyncStorage is still a
project maintained by the react-native community but it was moved out for
the reasons they've discussed (on what to stay in/out)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2667 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJMAB2H5QTEE35YXXR27XTTWM3JLANCNFSM44BATT7Q>
.
|
I've posted a comparison of
|
I've listed what have been done here: #2667 (comment) And now we're at
I've started working on that task, but discovered that though batching improves timings they are still far from 9-16ms for reads. Since then I've studied Onyx more and found some other places where it can improve and opened this PR #88 Before continuing with further work I would like to complete my contract for this assignment |
@kidroca All set; approved and paid the original milestone and added an additional milestone. Please proceed. |
@arielgreen Thanks I'm continuing with opening the first PR of the series |
PRs related to capturing metrics have been merged |
All good @MelvinBot |
Just giving a brief update of where we are at with this. 2 more PRs have been merged:
@kidroca I will create a PR to get that change into
Sound good? |
@marcaaron
Next is "LRU Cache update", I'll try to get the |
Nice, so, I've updated the open PR to include the latest changes and did another set of user timing tests on release builds. The 2nd PR did not yield anything significant in terms of user time. But I did have to fix a broken test. No issues observed besides that. The 3rd improved chat switch times by ~250ms on Android 🎉 |
@tgolen, @kidroca, @arielgreen it looks like no one is assigned to work on this job. |
I'm working on this. Will submit my last PR tomorrow. |
Thanks @kidroca — ignore MelvinBot's comment above, we were testing something. |
The 4th of the planned PRs was merged: Expensify/react-native-onyx#93 @arielgreen This would complete my current Upwork milestone. I think I can work on any approved future tasks under my hourly contract, we can keep this ticket open if necessary, though everything listed would have it's own issue We've identified some additional work related to storage performance that's worth pursuing
@marcaaron 1 and 2 might become unneeded if the experiment on 3 is successful - JSI can be called directly - we can assign component state in the constructor. Same is true for browser's local storage, though we'll have to fill some of the functionality (like multi merge) that AsyncStorage provided |
@kidroca I agree we should start investigating the JSI storage implementation. Probably the easiest way to prove the value is to patch Onyx to use MMKV and see if things improve then go from there. |
The 4th PR was merged here: #4509
We've started work/discussions on the items proposed above #2667 (comment) |
Excellent, thanks @kidroca. The 7-day period ends tomorrow for that one, so I'll pay out the milestone and close out that contract tomorrow. @marcaaron since this work is continuing, is it helpful to leave this GH issue open as a master issue to track all these improvements going forward? |
I think we can just close this one out. We are looking into some improvements to the storage layer here and a few other issues tagged with |
Paid. |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Problem
Though not carefully benchmarked, it's pretty obvious that the Android app is slow -- to start, to use, etc. And all things being equal, it would be better if it were faster. We don't know exactly what fraction of that time is spent reading/writing data from/to disk, but it's nonzero, and if it were faster, it would be a rising tide that floats all boats.
Solution
Do the following:
a. Reset - Deletes the database on disk
b. Write Sequential - Inserts a random number into keys 0 to 1M sequentially
c. Read Sequential - (only active if there is a database) Read rows 0 to 1M sequentially
a. Cold write sequential - Reset the database, reboot the phone, then start the app and tap "Write Sequential". This will measure the ability to write to a "cold" disk that has nothing cached.
b. Warm write - After doing "Cold write", tap "Write Sequential" again and see how overwriting the same database (presumably that is already cached) differs in performance.
c. Warm read - After "Warm write", tap "Read Sequential" and see how reading a warmed-up file performs.
d. Cold read - Reboot the phone, open the app, then tap "Read Sequential" again, to see how read performance differs when the file isn't cached
a. Stored procedures (to avoid recompiling SQL every time)
b. PRAGMA synchronous=OFF;
c. PRAGMA mmap_size=(1010241024); // 10MB memory map
d. Update the "Sequential Read" test to read keys in batches of 100, and re-test with the stock implementation (which just calls AsyncStorage.get() multiple times). Then implement a native version of AsyncStorage.multiGet() that makes a single query to SQLite, and re-test.
Also, test a native version of AsyncStorage.mutliGet() that does it all in one query.
Upwork job post
View all open jobs on Upwork
The text was updated successfully, but these errors were encountered: