Files
MarkBase Admin 8a66b9086a
CI / build (push) Waiting to run
CI / unit-tests (push) Blocked by required conditions
CI / lint (push) Blocked by required conditions
v2: Initial clean branch with unit tests + CI/CD pipeline
- Started from ac75faa (initial E4B-MarkBase integration)
- Kept Sources/ (all engine code) + Package.swift + .gitignore
- Removed all ad-hoc tests, documentation, scripts, Python files
- Added Tests/00_Unit/ (MathTest, TokenizerTest, SamplerTest)
- Added .gitea/workflows/ci.yaml (build + unit tests + lint)
- Added Scripts/check_resources.sh (memory-aware test runner)
- Added Tests/Manifest.json (resource requirements for all tests)
- Focus: 4-bit quantized models only
2026-07-05 13:29:25 +08:00

31 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# check_resources.sh — Check available system memory before running tests
# Usage: check_resources.sh <required_memory_gb>
set -euo pipefail
REQUIRED_GB="${1:-0}"
# Get available memory using vm_stat on macOS
if [[ "$(uname)" == "Darwin" ]]; then
PAGE_SIZE=$(vm_stat | head -1 | awk '{print $NF}' | sed 's/\.//')
FREE_PAGES=$(vm_stat | awk '/free/ {print $NF}' | sed 's/\.//')
if [[ -z "$FREE_PAGES" ]]; then
FREE_PAGES=$(vm_stat | awk '/Pages free/ {print $3}' | sed 's/\.//')
fi
AVAILABLE_GB=$(( FREE_PAGES * 16384 / 1073741824 )) # 16384 = page size on Apple Silicon
echo "Available memory: ~${AVAILABLE_GB}GB (free: ${FREE_PAGES} pages)"
else
AVAILABLE_GB=$(free -g | awk '/^Mem:/ {print $7}')
echo "Available memory: ~${AVAILABLE_GB}GB"
fi
if [[ "$AVAILABLE_GB" -lt "$REQUIRED_GB" ]]; then
echo "ERROR: Need ${REQUIRED_GB}GB but only ${AVAILABLE_GB}GB available"
echo "Run 'memory_pressure' to check memory status"
exit 1
fi
echo "OK: ${AVAILABLE_GB}GB >= ${REQUIRED_GB}GB required"
exit 0