-
Notifications
You must be signed in to change notification settings - Fork 0
Adjust host zram percentage of total memory #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
3f0fcc0 to
a85787f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new zram service to the Docker Compose configuration to help alleviate memory pressure by compressing inactive pages. The service creates a compressed RAM disk that acts as swap space, using a configurable percentage of total system memory (defaulting to 50%) with the LZ4 compression algorithm.
- Adds a new zram service that creates compressed swap space using a percentage of total memory
- Implements configurable compression algorithm and memory percentage through environment variables
- Includes cleanup logic to disable existing swap devices and remove existing zram devices before setup
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
docker-compose.yml
Outdated
| for swap in ${swaps}; do | ||
| # Swap devices reported by /proc/swaps in the container are missing the /dev/ prefix | ||
| echo "Disabling swap device ${swap##*/}..." | ||
| swapoff /dev/${swap##*/} |
Copilot
AI
Aug 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter expansion ${swap##*/} removes everything up to the last slash, but according to the comment on line 244, swap devices from /proc/swaps are already missing the /dev/ prefix. This means the expansion is unnecessary and could potentially cause issues if the swap device name contains slashes.
| swapoff /dev/${swap##*/} | |
| echo "Disabling swap device ${swap}..." | |
| swapoff /dev/${swap} |
docker-compose.yml
Outdated
| for swap in ${swaps}; do | ||
| # Swap devices reported by /proc/swaps in the container are missing the /dev/ prefix | ||
| echo "Disabling swap device ${swap##*/}..." | ||
| swapoff /dev/${swap##*/} |
Copilot
AI
Aug 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the previous line, the parameter expansion ${swap##*/} is redundant since the comment states swap devices are already missing the /dev/ prefix. This should be swapoff /dev/${swap} to avoid potential issues.
| swapoff /dev/${swap##*/} | |
| echo "Disabling swap device ${swap}..." | |
| swapoff /dev/${swap} |
fbc6f5c to
e74b13e
Compare
|
/rebase |
e74b13e to
64a2bbd
Compare
|
/rebase |
64a2bbd to
01ec4b9
Compare
|
/rebase |
01ec4b9 to
c404840
Compare
|
/rebase |
c404840 to
12c2e32
Compare
|
/rebase |
To alleviate memory pressure, increase zram to 50% or a given value of total memory at runtime. This allows the host to compress inactive pages to reduce contention. This service optionally allows for the maximum zram percentage and compression algorithm to be modified at runtime using variables. Change-type: minor Signed-off-by: Kyle Harding <[email protected]>
12c2e32 to
db505f6
Compare
Pull request was converted to draft
To alleviate memory pressure, increase zram to 50% or a given value of total memory at runtime. This allows the host to compress inactive pages to reduce contention.
This service optionally allows for the maximum zram percentage and compression algorithm to be modified at runtime using variables.
Change-type: minor
Based on: #276
See: https://balena.fibery.io/Security/Information_Security_and_Reliability_Incident/GitHub-Runners-Failure-during-vcpu-run-Out-of-memory-(os-error-12)-130