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

fix: 5933 - less greedy language refresh #6038

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

monsieurtanuki
Copy link
Contributor

What

  • There was something wrong with the "language refresh" task.
  • It's a combination:
    • recent introduction of OxF (4 servers instead of 1), and there was a little bug when passing to 4 servers
    • the database query that retrieves the local products to download first is a bit expensive
  • The result of this combination is that the expensive query was called too often, more specifically in sequence for several product types with potentially no data, which could cause a UI freeze effect.
  • There are also ways to rewrite the expensive query. Actually there would be 2 queries for 2 distinct cases, and it would be faster (to be tested again). And we'd get rid of "nulls first" potential exceptions at the same time, which would make things go faster on some devices.

Part of

Impacted files

  • background_task_language_refresh.dart: now we restart only the dedicated product type queue instead of all
  • operation_type.dart: new getProductType method; minor refactoring
  • offline_tasks_page.dart: display the product type for tasks, when available

Impacted files:
* `background_task_language_refresh.dart`: now we restart only the dedicated product type queue instead of all
* `operation_type.dart`: new `getProductType` method; minor refactoring
* `offline_tasks_page.dart`: display the product type for tasks, when available
@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 35 lines in your changes missing coverage. Please review.

Project coverage is 6.46%. Comparing base (4d9c7fc) to head (b104637).
Report is 571 commits behind head on develop.

Files with missing lines Patch % Lines
packages/smooth_app/lib/database/dao_product.dart 0.00% 15 Missing ⚠️
...ages/smooth_app/lib/background/operation_type.dart 0.00% 11 Missing ⚠️
...b/background/background_task_language_refresh.dart 0.00% 6 Missing ⚠️
...kages/smooth_app/lib/pages/offline_tasks_page.dart 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #6038      +/-   ##
==========================================
- Coverage     9.54%   6.46%   -3.09%     
==========================================
  Files          325     443     +118     
  Lines        16411   25137    +8726     
==========================================
+ Hits          1567    1625      +58     
- Misses       14844   23512    +8668     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@monsieurtanuki
Copy link
Contributor Author

@teolemon I've just pushed a very interesting commit, focused on optimizing the "get the most interesting products that haven't got the correct language yet" database query:

  • using 2 simple queries (less than 0.1s each) rather than a single "left join" that proved more expensive (0.5s)
  • using a database cursor, which uses less memory and is adapted in this particular case

I do believe you shouldn't have the UI freeze effect now.
Could you please test that PR?
If the UI freeze effect is still there, there are other options to explore, but they may have impacts on the off-dart package and I'd prefer to avoid that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 💬 To discuss and validate
Development

Successfully merging this pull request may close these issues.

2 participants