Skip to content

⚡ Bolt: Optimize swap-ssd-health.sh parsing and fix calculation bugs - #4

Merged
simien merged 1 commit into
mainfrom
bolt-optimize-swap-health-2568319239102810731
Jan 3, 2026
Merged

⚡ Bolt: Optimize swap-ssd-health.sh parsing and fix calculation bugs#4
simien merged 1 commit into
mainfrom
bolt-optimize-swap-health-2568319239102810731

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

💡 What: Optimized ops/monitoring/swap-ssd-health.sh to use efficient single-pass awk parsing instead of multiple pipeline chains. Fixed critical bugs in swap usage calculation and pageouts detection.

🎯 Why:

  1. Performance: The original script spawned ~15 subprocesses to extract 5 values. The optimized version spawns ~4.
  2. Correctness: USED_SWAP was incorrectly parsing field $4 (total) instead of field $7 (used), leading to 100% swap usage reports.
  3. Compatibility: vm_stat output for 'Pageouts' varies in case across macOS versions; added case-insensitive matching.

📊 Impact:

  • Reduces subprocess creation overhead by ~70%.
  • Fixes false positive "100% Swap Usage" warnings.
  • Ensures reliable detection of active swapping.

🔬 Measurement:
Verified using a test harness (tests/test_swap_ssd_health.sh) that mocked sysctl, vm_stat, diskutil, and smartctl output to confirm correct parsing and calculation logic.


PR created automatically by Jules for task 2568319239102810731 started by @simien

…ugs:

- Replaced multiple subprocess chains with single awk passes for `sysctl`, `vm_stat`, and `smartctl` parsing.
- Fixed a bug where `USED_SWAP` was incorrectly extracting the `TOTAL_SWAP` value (field $4 vs field $7).
- Fixed a case sensitivity issue with 'Pageouts' detection in `vm_stat`.
- Improved error handling for missing SMART attributes.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 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!


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

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

@simien
simien merged commit b8180a5 into main Jan 3, 2026
3 checks passed
@simien
simien deleted the bolt-optimize-swap-health-2568319239102810731 branch January 4, 2026 01:25
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