refactor: extract Redis I/O threads configuration into reusable function - #230
Merged
Merged
Conversation
…_io_threads function Agent-Logs-Url: https://github.com/EngineScript/EngineScript/sessions/941a899e-7964-4104-9aec-ca3b624d7a22 Co-authored-by: PDowney <11467177+PDowney@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor Redis I/O threads configuration to improve maintainability
refactor: extract Redis I/O threads configuration into reusable function
May 2, 2026
Removed details about refactoring Redis I/O threads configuration from the changelog.
PDowney
approved these changes
May 2, 2026
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
PDowney
marked this pull request as ready for review
May 2, 2026 06:12
|
github-actions
Bot
deleted the
copilot/refactor-redis-io-threads-configuration
branch
May 2, 2026 06:13
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Redis install script to centralize Redis I/O threads tuning into a reusable function, reducing duplication across CPU-count branches.
Changes:
- Extracted Redis
io-threads/io-threads-do-readssedupdates intoconfigure_redis_io_threads(). - Replaced duplicated per-CPU branches with calls to the new helper.
Comment on lines
+48
to
+62
| configure_redis_io_threads() { | ||
| local thread_count="$1" | ||
| sed -i "s|^# io-threads 4|io-threads ${thread_count}|" /etc/redis/redis.conf | ||
| sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf | ||
| elif [[ "${CPU_COUNT}" -ge '12' && "${CPU_COUNT}" -le '15' ]]; then | ||
| sed -i "s|^# io-threads 4|io-threads 6|" /etc/redis/redis.conf | ||
| sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf | ||
| elif [[ "${CPU_COUNT}" -ge '7' && "${CPU_COUNT}" -le '11' ]]; then | ||
| sed -i "s|^# io-threads 4|io-threads 4|" /etc/redis/redis.conf | ||
| sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf | ||
| elif [[ "${CPU_COUNT}" -ge '4' && "${CPU_COUNT}" -le '6' ]]; then | ||
| sed -i "s|^# io-threads 4|io-threads 2|" /etc/redis/redis.conf | ||
| sed -i "s|^# io-threads-do-reads no|io-threads-do-reads yes|" /etc/redis/redis.conf | ||
| fi | ||
| } | ||
|
|
||
| if [[ "${CPU_COUNT}" -ge '16' ]]; then | ||
| configure_redis_io_threads 8 | ||
| elif [[ "${CPU_COUNT}" -ge '12' && "${CPU_COUNT}" -le '15' ]]; then | ||
| configure_redis_io_threads 6 | ||
| elif [[ "${CPU_COUNT}" -ge '7' && "${CPU_COUNT}" -le '11' ]]; then | ||
| configure_redis_io_threads 4 | ||
| elif [[ "${CPU_COUNT}" -ge '4' && "${CPU_COUNT}" -le '6' ]]; then | ||
| configure_redis_io_threads 2 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Redundant
sedcommands forio-threads/io-threads-do-readswere duplicated verbatim across four CPU-count branches inredis-install.sh. This refactor centralises them into a single parameterised function.Software Version Updates
No version changes — this is a code quality refactor.
Changed Versions
N/A
Version Diff
Verification Checklist
Notes
Behaviour is identical to the original — only structure changed.
elifindentation also corrected to standard Bashif/elif/fistyle.CHANGELOG.mdupdated.Original prompt