[pypy-commit] pypy default: ll2ctypes: Avoid keeping 20G all allocated in far_regions
Greg Price
noreply at buildbot.pypy.org
Wed Mar 20 03:51:26 CET 2013
Author: Greg Price <price at mit.edu>
Branch:
Changeset: r62540:f442d5262c40
Date: 2013-03-19 19:46 -0700
http://bitbucket.org/pypy/pypy/changeset/f442d5262c40/
Log: ll2ctypes: Avoid keeping 20G all allocated in far_regions
This helps avoid scaring Linux about how much memory is committed,
as we don't actually use close to all this memory.
diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py b/rpython/rtyper/lltypesystem/ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/ll2ctypes.py
@@ -84,12 +84,16 @@
if not far_regions:
from rpython.rlib import rmmap
if _64BIT:
- PIECESIZE = 0x80000000
+ PIECE_STRIDE = 0x80000000
else:
if _POSIX:
- PIECESIZE = 0x10000000
+ PIECE_STRIDE = 0x10000000
else:
- PIECESIZE = 0x08000000
+ PIECE_STRIDE = 0x08000000
+ if _POSIX:
+ PIECE_SIZE = 0x04000000
+ else:
+ PIECE_SIZE = PIECE_STRIDE
PIECES = 10
flags = (0,)
if _POSIX:
@@ -100,12 +104,16 @@
# XXX seems not to work
else:
assert False # should always generate flags
- m = rmmap.mmap(-1, PIECES * PIECESIZE, *flags)
+
+ m = rmmap.mmap(-1, PIECES * PIECE_STRIDE, *flags)
m.close = lambda : None # leak instead of giving a spurious
# error at CPython's shutdown
m._ll2ctypes_pieces = []
for i in range(PIECES):
- m._ll2ctypes_pieces.append((i * PIECESIZE, (i+1) * PIECESIZE))
+ start = i * PIECE_STRIDE
+ m._ll2ctypes_pieces.append((start, start + PIECE_SIZE))
+ if _POSIX:
+ m.unmap_range(start + PIECE_SIZE, PIECE_STRIDE - PIECE_SIZE)
far_regions = m
# ____________________________________________________________
More information about the pypy-commit
mailing list