Files
Felipe Cardoso af0515d05d fix: address code review findings (HIGH + MEDIUM)
- Replace GNU \b with portable word-boundary sed patterns in kernel-params
- Warn on unknown CLI arguments instead of silently swallowing
- Add floor check on recommended_gttsize_mib to prevent negative values
- Fix Python operator precedence in benchmark log parser
- Add root checks to tuned-profile.sh and rollback.sh
- Remove redundant sudo calls (scripts already require root at entry)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 20:19:44 +01:00

62 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# Switch tuned profile to accelerator-performance
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../../lib/common.sh"
source "$SCRIPT_DIR/../../lib/detect.sh"
RECOMMENDED="accelerator-performance"
log_header "Tuned Profile Optimization"
if [[ $EUID -ne 0 ]]; then
log_error "This script requires root. Re-run with: sudo make optimize-tuned"
exit 1
fi
if ! is_cmd tuned-adm; then
log_error "tuned is not installed. Install with: sudo dnf install tuned"
exit 1
fi
current="$(detect_tuned_profile)"
log_info "Current profile: $current"
if [[ "$current" == "$RECOMMENDED" ]]; then
log_success "Already using $RECOMMENDED"
exit 0
fi
# Check availability
if ! tuned-adm list 2>/dev/null | grep -q "$RECOMMENDED"; then
log_error "$RECOMMENDED profile not available"
log_info "Available profiles:"
tuned-adm list 2>/dev/null | grep "^-" | sed 's/^/ /'
exit 1
fi
echo ""
log_info "Recommended: $RECOMMENDED"
log_info "Description: Throughput performance with disabled higher latency STOP states"
log_info "Benefit: 5-8% improvement in prompt processing (pp) benchmarks"
log_info "No reboot required."
echo ""
if ! confirm "Switch to $RECOMMENDED?"; then
log_info "Skipped"
exit 0
fi
# Save current for rollback
echo "$current" > "$(data_dir backups)/tuned-previous-profile.txt"
tuned-adm profile "$RECOMMENDED"
new_profile="$(detect_tuned_profile)"
if [[ "$new_profile" == "$RECOMMENDED" ]]; then
log_success "Profile switched to: $new_profile"
else
log_error "Profile switch may have failed. Current: $new_profile"
fi