-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
PERF: Use backend to load Note
#14948
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
Conversation
Added in 19e92c1 Doesn't add much value, causes spam in CardBrowser
a505a6d
to
ad6e8f4
Compare
Removes a cast. Backend uses an **immutable** list but this is not an ArrayList, and we still want this value to be mutable due to other methods on the API surface
a4ab27b
to
733837a
Compare
Removes a cast. Backend uses an **immutable** list but this is not an ArrayList, and we still want this value to be mutable due to other methods on the API surface
This is what the backend uses: anki.notes.Note.getMtimeSecs is an uint32
This may have caused issue 14796, as the inheritor was inheriting from RobolectricTest() After fixing `Note` to use the backend, I got one non-reproducible error: `java.lang.UnsatisfiedLinkError: 'byte[][] net.ankiweb.rsdroid.NativeMethods.openBackend(byte[])'` I strongly suspect that it was this class which caused the issue. If this is incorrect, it's a small tiem penalty to unit tests
This reduced the time to load 1 million notes from ~1m30 -> ~30s https://github.com/ankitects/anki/blob/db93939ded947d74bb25bd8552a2b2356a096509/pylib/anki/notes.py#L54-L67
733837a
to
1639987
Compare
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.
Pretty good
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.
Looks good!
waiting for merge queue to empty so I don't thrash it with the squash merge from here then goes in |
This one gave me a fit locally. 2 macOS machines ran tests with this PR rebased to main no problem but windows consistent failures. Stopped gradle daemons, gradle clean with |
Was the failure: If so, revert on the first sign of failure in CI |
Nope, it's this, sometimes, I cannot get it to reproduce but I did just see it on a macOS machine so I've seen it cross-platform now. CI has zero instances, and locally I'm green again, I dunno
|
* log: remove 'note.load' Added in 19e92c1 Doesn't add much value, causes spam in CardBrowser * refactor: Kotlin: note.tags -> MutableList Removes a cast. Backend uses an **immutable** list but this is not an ArrayList, and we still want this value to be mutable due to other methods on the API surface * refactor: Kotlin: note.fields -> MutableList Removes a cast. Backend uses an **immutable** list but this is not an ArrayList, and we still want this value to be mutable due to other methods on the API surface * refactor: Kotlin: note.mod -> Int This is what the backend uses: anki.notes.Note.getMtimeSecs is an uint32 * refactor: note: remove 'scm' unused * refactor: note: remove 'flags' unused * refactor: note: remove 'data' unused * tests: fix - use RunWith(AndroidJUnit4) This may have caused issue 14796, as the inheritor was inheriting from RobolectricTest() After fixing `Note` to use the backend, I got one non-reproducible error: `java.lang.UnsatisfiedLinkError: 'byte[][] net.ankiweb.rsdroid.NativeMethods.openBackend(byte[])'` I strongly suspect that it was this class which caused the issue. If this is incorrect, it's a small tiem penalty to unit tests * note: load from Backend This reduced the time to load 1 million notes from ~1m30 -> ~30s https://github.com/ankitects/anki/blob/db93939ded947d74bb25bd8552a2b2356a096509/pylib/anki/notes.py#L54-L67
Purpose / Description
Match Anki Desktop's implementation, and get a 3x speedup (1m30 -> 30s to load 1MM notes)
❗️WARN: while unit testing, I had a failure of:
RunWith(AndroidJUnit4::class)
#14796I have annotated the class which I believe is the problem, but this is not guaranteed to fix the issue. I have performed many retests and have been unable to reproduce the test failure
Approach
How Has This Been Tested?
1m 27 -> 28s to load 1 million notes (~87 -> 27 micros)
Learning (optional, can help others)
https://github.com/ankitects/anki/blob/db93939ded947d74bb25bd8552a2b2356a096509/pylib/anki/notes.py#L54-L67
Backend Codegen is problematic: it exposes a
java.util.List
, but this is actually acom.google.protobuf.Internal.ProtobufList
https://protobuf.dev/reference/java/api-docs/com/google/protobuf/Internal.ProtobufList
Checklist