Skip to content

fix: Improve runtime performance for product decoding and barcode list operations#7501

Open
lguiza wants to merge 2 commits into
openfoodfacts:developfrom
lguiza:perf/runtime-optimizations
Open

fix: Improve runtime performance for product decoding and barcode list operations#7501
lguiza wants to merge 2 commits into
openfoodfacts:developfrom
lguiza:perf/runtime-optimizations

Conversation

@lguiza
Copy link
Copy Markdown

@lguiza lguiza commented May 13, 2026

Summary

This pull request introduces several runtime performance optimizations identified during the Sprint 4 profiling and technical audit process.

The implemented optimizations focus on reducing CPU overhead and improving collection lookup efficiency during local database iteration workflows.

Implemented optimizations

1. Optimize barcode exclusion lookups

Replaced repeated List.contains() checks with Set.contains() during local product scan iterations in dao_product.dart.

Expected benefit:

  • Faster lookup operations during cursor-based scans
  • Lower CPU usage for large exclusion lists

2. Optimize barcode membership checks in bulkSet

Reworked internal membership checks in dao_product_list.dart using LinkedHashSet to preserve insertion order while improving lookup complexity.

Expected benefit:

  • Faster bulk updates for large barcode lists
  • Reduced repeated linear scans

Context

These optimizations were identified during runtime profiling using Flutter DevTools and Xcode Instruments as part of the Sprint 4 technical audit report.

The profiling process revealed repeated list membership checks during database iteration flows and potentially expensive lookup patterns in barcode list operations.

Notes

The changes are intentionally localized and do not modify the application's high-level architecture or persistence strategy.

Copy link
Copy Markdown
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

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

Hi @lguiza!

I have the impression that your code doesn't even compile. Let alone the format.

Would you please confirm that you actually typed it, that you tested it once, and that you measured performance improvements on typical use-cases.

You mention "Sprint 4 profiling and technical audit process".
I wasn't aware of that - which is OK - would you somehow link to that report, or create an issue about what you tried to solve.

Thank you.

@teolemon teolemon changed the title Improve runtime performance for product decoding and barcode list operations fix: Improve runtime performance for product decoding and barcode list operations May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: 💬 To discuss and validate

Development

Successfully merging this pull request may close these issues.

2 participants