Skip to content

[Perf] install-deps.sh: O(n^2) loop spawns a yay -D --asdeps subprocess per match (~10-20s per install) #3571

Description

@carabistouflette

Step 1. Before you submit

  • I have read the Troubleshooting and Usage pages.
  • I've successfully updated to the latest version following the guidance.
  • I've successfully updated the system packages to the latest.
  • I've ticked the checkboxes without reading their contents

Step 2. Quick diagnose info

Quick diagnose
N/A — code-level performance finding from static analysis (no live-session repro).

Step 3. Describe the issue

sdata/dist-arch/install-deps.sh:29-34implicitize_old_dependencies() runs a nested O(explicit × old-deps) loop and spawns a separate yay -D --asdeps "$i" subprocess per match:

for i in "${explicitly_installed[@]}"; do for j in "${old_deps_list[@]}"; do
    [ "$i" = "$j" ] && yay -D --asdeps "$i"
done; done

Each yay invocation costs ~1 s of startup. With ~10-20 matches per install, this adds ~10-20 s to every setup install run, on top of the O(n²) comparisons.

Suggested fix

Collect matches in an array, then issue a single batched call:

matches=()
for i in "${explicitly_installed[@]}"; do for j in "${old_deps_list[@]}"; do
    [ "$i" = "$j" ] && matches+=("$i")
done; done
(( ${#matches[@]} )) && yay -D --asdeps "${matches[@]}"

Reminder

  • I agree that it's usually impossible for others to help me without my logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions