File: memory-check.sh

package info (click to toggle)
pypy 2.4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 86,992 kB
  • ctags: 170,715
  • sloc: python: 1,030,417; ansic: 43,437; cpp: 5,241; asm: 5,169; sh: 458; makefile: 408; xml: 231; lisp: 45
file content (55 lines) | stat: -rwxr-xr-x 1,749 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# Determine if we have enough RAM
# PyPy upstream claims it needs at least 2GiB on 32bit and 4GiB on 64bit
# (pointers dominate the memory)

set -e -u

# We don't enforce this on Ubuntu, which has less minority architectures.
if dpkg-vendor --derives-from Ubuntu; then
	# Only get out of jail free on the primary archive buildds
	# Do the RAM check for PPA builds
	if grep -q '^Purpose: *PRIMARY' /CurrentlyBuilding; then
		exit 0
	fi
fi

# Memory we will require on 32-bit archs
# This estimate is on the low side, we'll be spilling over into swap, but
# should still be able to build within a couple of days.
REQ_32_MEM=1400

# x86 has JIT enabled (which will need more) and machines with >= 4GB of RAM
# aren't rare, so let's be a little more conservative (c.f. #713787)
# (except kfreebsd-amd64 which currently has 3GB buildds, sigh)
if dpkg-architecture -iany-i386 || dpkg-architecture -ilinux-amd64; then
	REQ_32_MEM=2000
fi

MEM=$(sed -rne 's/^MemTotal: *([0-9]+) kB$$/\1/p' /proc/meminfo)
MEM=$((MEM / 1024))
SWAP=$(sed -rne 's/^SwapTotal: *([0-9]+) kB$$/\1/p' /proc/meminfo)
SWAP=$((SWAP / 1024))

BITS=$(dpkg-architecture -qDEB_HOST_ARCH_BITS)
if [ $BITS -ge 64 ]; then
	REQ_MEM=$(($REQ_32_MEM * 2))
else
	REQ_MEM=$REQ_32_MEM
fi

echo "PyPy requires >= $REQ_MEM MiB of RAM to build (on a $BITS-bit machine)."
echo "This machine has $MEM MiB of RAM."

if dpkg-architecture -qDEB_BUILD_ARCH | grep -q s390; then
	MEM=$(($MEM + $SWAP))
	echo "Counting the $SWAP MiB of swap too, as s390 apparently has very fast swap."
fi

if [ $REQ_MEM -lt $MEM ]; then
	echo "Assuming we have enough RAM to build."
else
	echo "You probably don't have enough RAM to build PyPy in any reasonable amount of time." >&2
	echo "Aborting" >&2
	exit 1
fi