<commit_before>#!/bin/bash
#
# Print memory size available to the container, in megabytes
#

set -u
set -e

if [ ! -e /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
    echo "Control group's memory limit file is not available."
    exit 1
fi

MC_MEMORY_LIMIT=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)

# If it's some insane value (13 or more digits, nearing a terabyte), either the
# cgroup's memory limit is not set or we're not running in a container at all,
# so return whatever is reported by "free"
if [[ "${#MC_MEMORY_LIMIT}" -ge 13 ]]; then
    MC_MEMORY_LIMIT=$(free -b | grep Mem | awk '{ print $2 }')
fi

echo $(($MC_MEMORY_LIMIT / 1024 / 1024))<commit_msg>Pick memory limit from free -m / cgroup limit<commit_after>#!/bin/bash
#
# Print memory size available to the container, in megabytes
#

set -u
set -e

if [ ! -e /sys/fs/cgroup/memory/memory.limit_in_bytes ]; then
    echo "Control group's memory limit file is not available."
    exit 1
fi

# Read cgroup's memory limit and the total size of available memory, pick the smallest
MC_CGROUP_MEMORY_LIMIT=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
MC_RAM_SIZE=$(free -b | grep Mem | awk '{ print $2 }')

if [ "$MC_CGROUP_MEMORY_LIMIT" -gt "$MC_RAM_SIZE" ]; then
    MC_MEMORY_LIMIT="$MC_RAM_SIZE"
else
    MC_MEMORY_LIMIT="$MC_CGROUP_MEMORY_LIMIT"
fi

echo $(($MC_MEMORY_LIMIT / 1024 / 1024))
{'fraction_non_alphanumeric': 0.11901306240928883, 'fraction_numerical': 0.01741654571843251, 'mean_word_length': 4.032846715328467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5817008', 'n_tokens_mistral': 515, 'n_tokens_neox': 486, 'n_words': 157}