-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Implement Rust-based Database Access #8052
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8052 +/- ##
============================================
+ Coverage 36.87% 36.91% +0.03%
- Complexity 3734 3751 +17
============================================
Files 347 350 +3
Lines 35678 35724 +46
Branches 4725 4728 +3
============================================
+ Hits 13157 13186 +29
- Misses 21015 21033 +18
+ Partials 1506 1505 -1
Continue to review full report at Codecov.
|
By "Debugging over the Java/Rust boundary appears to be extremely difficult" I presume you mean the inability to step the Java debugger into Rust code? For issues that depend on internal transient state such as your DB layer, it would probably be helpful for developers to have an easy way to run AnkiDroid with a locally compiled version of the backend, which they can augment with print statements. But I suspect once the initial infrastructure is set up, the majority of issues that will come up will either solely depend on the input to a backend method, or the input combined with the currently open collection. It's not much different to debugging code that calls a web API - if you feed it good data and you get back bad results, you know the issue is not in your own code, and you can then take that input data and debug it in the other project, or report the issue upstream. |
TL;DR: Agreed with the final point. I doubt there's going to be much debugging required of the library (famous last words). Println-based debugging may be necessary, but I feel it's YAGNI right now to get a working setup: ankidroid/Anki-Android-Backend#24
Yep, there's been successful work in getting LLDB working, but it's far from the mixed-mode debugging experience from other toolchains/mixed languages: mozilla/rust-android-gradle#22. From vague readings about the quality of the debuggers, I'd only consider this as a last resort, println debugging is sadly likely going to be the way to go.
We're already printing the database queries being sent to the database to the debug logs. Instructions for a locally compiled backend are already in the PR (I've been doing most of my testing with a locally compiled backend); they could do with a little more polish to save a ~10LOC change while testing under Robolectric. Haven't implemented printing to logcat from Rust yet, which would be probably be the best form of debugging that we get for a fair while.
Agreed - I'd be surprised if we find issues with the upstream code as it's battle-tested. |
I actually prefer print debugging I find it much faster in combo with a test infrastructure than debugger fiddling personally :-), as long as it's possible it's fine by me. |
The list of knowledge is quite humorous to me - you had to learn All The Things to do this thing. Even android dependency publishing, what a PITA! |
I can imagine all tests pass, it looks really close. Most of my comments were about the last percent (or similar) of removing a couple TODOs, bike-shedding on a variable name or annotation etc |
All tests pass
This is temporary - we will later require the Rust Backend But for now, we have a java fallback which will work. Mostly aimed at handling class: RustBackendFailedException
Force pushed. Ready for re-review |
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.
Cleaner in a few ways, LGTM - I'll approve but I can't possibly hit the buttons on this one. You should have the honor - merge at will and hit that publish button
What could possibly go wrong
/ducks 🤣 but seriously launch it!
Purpose / Description
libAnki
) and instead use Anki Desktop's code (rslib
)rslib
is to transfer the database access to flow throughrslib
Approach
.so
created in: https://github.com/david-allison-1/Anki-Android-Backendanki-android-backend
) https://github.com/david-allison-1/Anki-Android-Backend/blob/rust-wip/docs/OVERVIEW.mdThoughts
get(String|Int etc...)()
on a cursor - logic is handled in the Java.Known issues
Collection.crt
)openCollection
will open the database and create it with schema and indices. This will not happen in the Java side, so the database setup is slightly different..so
, improving this currently is beyond my skillset.libAnki
How Has This Been Tested?
Learning
Runtime.load()
Checklist
if
statements)