Skip to content

Commit

Permalink
Added utility for measuring peak memory requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillam committed Aug 22, 2023
1 parent 8956249 commit ddf2dda
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,9 @@ Ensure you update any central list or configuration within Shogun that keeps tra

```
CONFIG_FILE=your_config_file.yaml
```
```

## Tools and Scripts

### docker_peak_mem.sh
This bash script keeps track of the maximum memory usage of all running containers. It uses `docker stats` to accomplish this. This is intended to help determine the necessary memory requirements for a lab server while testing new container builds.
24 changes: 24 additions & 0 deletions docker_peak_mem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Initialize peak memory usage variable for each container
declare -A peak_memory_usage

while true; do
# Get the memory usage for all running containers
docker_stats=$(docker stats --no-stream --format "{{.Name}} {{.MemUsage}}")

# Process each line of the output
while IFS= read -r line; do
container_id=$(echo $line | awk '{print $1}')
current_memory_usage=$(echo $line | awk '{print $2}' | sed 's/MiB//')

# Compare with the peak memory usage and update if necessary
if [[ ! ${peak_memory_usage[$container_id]} || $(echo "$current_memory_usage > ${peak_memory_usage[$container_id]}" | bc -l) -eq 1 ]]; then
peak_memory_usage[$container_id]=$current_memory_usage
echo "New peak memory usage for container $container_id: ${peak_memory_usage[$container_id]} MiB"
fi
done <<< "$docker_stats"

# Wait for 1 second before checking again
sleep 1
done

0 comments on commit ddf2dda

Please sign in to comment.