Skip to content

perf(backend): query dpkg once when listing the catalog - #7

Open
albertonoys wants to merge 1 commit into
CardputerZero:mainfrom
albertonoys:perf/summary-dpkg-snapshot
Open

albertonoys wants to merge 1 commit into
CardputerZero:mainfrom
albertonoys:perf/summary-dpkg-snapshot

Conversation

@albertonoys

Copy link
Copy Markdown

Problem

Opening the store takes ~35 s on a CardputerZero, almost all of it in the catalog summary:

  • --summary runs dpkg-query twice per app (146 runs for 73 apps).
  • Each run parses the whole dpkg status file: about 0.18 s on the device, which has a 1.8 MB status file and ~1900 packages.

Change

  • summary_output() takes one dpkg-query -W snapshot of every package, and package_state() answers from it while the summary is built.
  • Every other caller (install, plan, repair) still queries live, so those checks always see fresh state.
  • If the snapshot query fails, it falls back to per-package queries. A package missing from the snapshot is reported as absent, matching the old exit-code-1 handling.
  • If a package is listed for several architectures, the installed one wins.

Result

On a real device, --summary goes from 28.8 s to 2.2 s, with byte-for-byte identical output.

Tests

  • Both dpkg-query fakes answer the batched form.
  • A new check requires --summary to make exactly one dpkg-query call. The current binary fails it.
  • On the device, test_native_backend (1151 checks) and test_native_backend.sh pass.
  • test_package_repair_helper.sh was skipped: it needs root.

Not changed

ui_init still clears the registry, icon and screenshot cache on every launch (clear_cached_catalog()), so the store re-downloads all artwork and starts from an empty list each time, which costs about 5 s here. That looks deliberate, so I left it out of this PR.

- --summary ran dpkg-query twice per app (146 runs for 73 apps); each run parses the whole dpkg status file, ~0.2 s on the device, so opening the store spent ~29 s here
- summary_output now takes one dpkg-query -W snapshot of every package and answers package_state() from it; other callers still query live, so install and repair checks see fresh state
- a failed snapshot falls back to per-package queries; a package missing from the snapshot is reported as absent, as dpkg-query's exit 1 was
- on a CardputerZero with 1900 packages, --summary drops from 28.8 s to 2.2 s with identical output
- tests: dpkg-query fakes answer the batched form, and --summary must make exactly one call
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.

1 participant