Skip to content
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

Objectbox in Isolate #18

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Objectbox in Isolate #18

wants to merge 14 commits into from

Conversation

iebb
Copy link

@iebb iebb commented Oct 7, 2024

This pull request moves the entire ObjectBox adapter into isolates, which reduces UI lags.

Changes

All ObjectBox calls are changed into messages passing between isolates, which could have a lesser impact on the main isolate. (Demo is working with less spinner lags)

  • All calling methods are converted into SendPort / RecvPort calls
  • Changed String concatenation to StringBuffer which can have ~20% performance gain
    • from functions decodeFromIndex and encodeToIndex

Tests

All tests are now functional. In previous revision the database wasn't correctly destroyed thus containing leftover from previous testcases.

Benchmark

Benchmark on Rakuten BIG (aka ZTE-ZR01) - $30 low-end phone, with Android 10, SnapDragon 765G, 6G RAM

Device Specs: https://network.mobile.rakuten.co.jp/product/smartphone/rakuten-big/

Performing 3k bulk-inserts:

Original:

Screen lags for 8 seconds and insertion is done
Entire app is blocked

Modified:

Screen does not lag at all. Inserting took 14 seconds
Non-blocking, execution time is ~1.5x slower

According to flutter/flutter#145450 - Isolates is likely to run on slower cores instead of performance cores on low-end devices.

Conclusion

It can be used to improve UI responsiveness, without hurting performance too much. For non-heavy workloads it might be a better choice to reduce UI lags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please maintain the flutter version on 3.22.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants