Skip to content

⚡ perf: use -delete instead of -exec rm for files in find#17

Merged
tryigit merged 1 commit into
mainfrom
perf-optimization-find-delete-2030324025241024058
Apr 1, 2026
Merged

⚡ perf: use -delete instead of -exec rm for files in find#17
tryigit merged 1 commit into
mainfrom
perf-optimization-find-delete-2030324025241024058

Conversation

@tryigit

@tryigit tryigit commented Apr 1, 2026

Copy link
Copy Markdown
Owner

⚡ Optimized GPU Cache Cleaning Performance

💡 What:

Replaced -exec rm -f {} + with the more efficient -delete flag in the find command used by gpu_cache_cleaner in Magisk Template/customize.sh.

🎯 Why:

Spawning an external rm process (even with the + argument to group files) introduces significant CPU and I/O overhead compared to the built-in -delete action in find.

📊 Measured Improvement:

Using the updated tests/benchmark.sh script, the performance improvement was measured by simulating a large number of cache files and directories:

Implementation Duration (ns) Relative Performance
Current (-exec rm) 354,014,616 100% (Baseline)
Optimized (-delete) 183,368,679 ~52% (48% faster)

The optimized version is consistently nearly twice as fast in the benchmark scenario.

✅ Verification:

  • Ran tests/verify.sh: PASS (Confirmed that shader cache and gpu cache directories/files are still correctly removed).
  • Ran tests/benchmark.sh: Confirmed significant performance gain.
  • Code review: Correct

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

Replaced the second pass of `find` in `gpu_cache_cleaner` with the
built-in `-delete` predicate. This optimization avoids the overhead of
spawning an external `rm` process, significantly improving performance
as demonstrated by `tests/benchmark.sh`.

Modified `tests/benchmark.sh` to provide more accurate comparisons
between the current and optimized implementations.

- Baseline (current): ~354ms
- Optimized (-delete): ~183ms
- Improvement: ~48% reduction in execution time
@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 47be4d1 into main Apr 1, 2026
6 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