Skip to content

⚡ Optimize find command in customize.sh#18

Merged
tryigit merged 1 commit into
mainfrom
perf-optimize-find-permissions-11455833854721978498
Apr 8, 2026
Merged

⚡ Optimize find command in customize.sh#18
tryigit merged 1 commit into
mainfrom
perf-optimize-find-permissions-11455833854721978498

Conversation

@tryigit

@tryigit tryigit commented Apr 8, 2026

Copy link
Copy Markdown
Owner

⚡ Performance Optimization: Grouped find -exec calls

💡 What:

Restructured the primary find command in Magisk Template/customize.sh that sets base module permissions. Instead of having separate -exec chains for directories and files for every attribute, I grouped the common chown and chcon calls.

🎯 Why:

Each -exec ... + in a find command typically results in at least one process fork and execution (depending on the number of files). The original code had:

  1. chmod 0755 (dirs)
  2. chown 0:0 (dirs)
  3. chcon ... (dirs)
  4. chmod 0644 (files)
  5. chown 0:0 (files)
  6. chcon ... (files)

The optimized version uses:

  1. chmod 0755 (dirs) OR chmod 0644 (files)
  2. chown 0:0 (all)
  3. chcon ... (all)

This reduces the total number of batches from 6 to 4.

📊 Measured Improvement:

  • Focused Find Benchmark: Reduced execution time by ~25% (from 16ms to 12ms) in a synthetic test with 1000 files across 10 directories.
  • Integration Benchmark (tests/benchmark_permissions.sh): Reduced total permission-setting time from 48ms to 44ms.

No functionality was changed; all verification tests (tests/verify.sh, tests/verify_prop.sh) passed successfully.


PR created automatically by Jules for task 11455833854721978498 started by @tryigit

Restructured the find command in customize.sh to group shared
chown and chcon operations, reducing the number of process
forks (batches) from 6 to 4. This improves installation
performance, especially on modules with many files.
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@tryigit tryigit merged commit 1faeacb into main Apr 8, 2026
5 checks passed
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