[pypy-commit] pypy rgc-mem-pressure: try to apply some memory pressure to _hashlib
justinpeel
noreply at buildbot.pypy.org
Sun Oct 9 23:38:10 CEST 2011
Author: Justin Peel <notmuchtotell at gmail.com>
Branch: rgc-mem-pressure
Changeset: r47918:13feff9d23f3
Date: 2011-10-09 15:37 -0600
http://bitbucket.org/pypy/pypy/changeset/13feff9d23f3/
Log: try to apply some memory pressure to _hashlib
diff --git a/pypy/module/_hashlib/interp_hashlib.py b/pypy/module/_hashlib/interp_hashlib.py
--- a/pypy/module/_hashlib/interp_hashlib.py
+++ b/pypy/module/_hashlib/interp_hashlib.py
@@ -4,9 +4,9 @@
from pypy.interpreter.error import OperationError
from pypy.tool.sourcetools import func_renamer
from pypy.interpreter.baseobjspace import Wrappable
-from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.lltypesystem import lltype, llmemory, rffi
+from pypy.rlib import rgc, ropenssl
from pypy.rlib.objectmodel import keepalive_until_here
-from pypy.rlib import ropenssl
from pypy.rlib.rstring import StringBuilder
from pypy.module.thread.os_lock import Lock
@@ -29,6 +29,9 @@
space.wrap("unknown hash function"))
ctx = lltype.malloc(ropenssl.EVP_MD_CTX.TO, flavor='raw')
ropenssl.EVP_DigestInit(ctx, digest)
+ rgc.add_memory_pressure(ropenssl.EVP_MD_CTX.TO.hints['getsize']() +
+ ropenssl.EVP_MD.TO.hints['getsize']() +
+ self._digest_size())
self.ctx = ctx
def __del__(self):
diff --git a/pypy/rlib/ropenssl.py b/pypy/rlib/ropenssl.py
--- a/pypy/rlib/ropenssl.py
+++ b/pypy/rlib/ropenssl.py
@@ -25,6 +25,7 @@
'openssl/err.h',
'openssl/rand.h',
'openssl/evp.h',
+ 'openssl/ossl_typ.h',
'openssl/x509v3.h']
eci = ExternalCompilationInfo(
@@ -154,7 +155,7 @@
ssl_external('CRYPTO_set_id_callback',
[lltype.Ptr(lltype.FuncType([], rffi.LONG))],
lltype.Void)
-
+
if HAVE_OPENSSL_RAND:
ssl_external('RAND_add', [rffi.CCHARP, rffi.INT, rffi.DOUBLE], lltype.Void)
ssl_external('RAND_status', [], rffi.INT)
@@ -255,7 +256,7 @@
[BIO, rffi.VOIDP, rffi.VOIDP, rffi.VOIDP], X509)
EVP_MD_CTX = rffi.COpaquePtr('EVP_MD_CTX', compilation_info=eci)
-EVP_MD = rffi.COpaquePtr('EVP_MD')
+EVP_MD = rffi.COpaquePtr('EVP_MD', compilation_info=eci)
OpenSSL_add_all_digests = external(
'OpenSSL_add_all_digests', [], lltype.Void)
diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -48,7 +48,7 @@
self.TYPE = TYPE
def __repr__(self):
return '<Uninitialized %r>'%(self.TYPE,)
-
+
def saferecursive(func, defl, TLS=TLS):
def safe(*args):
@@ -537,9 +537,9 @@
return "Func ( %s ) -> %s" % (args, self.RESULT)
__str__ = saferecursive(__str__, '...')
- def _short_name(self):
+ def _short_name(self):
args = ', '.join([ARG._short_name() for ARG in self.ARGS])
- return "Func(%s)->%s" % (args, self.RESULT._short_name())
+ return "Func(%s)->%s" % (args, self.RESULT._short_name())
_short_name = saferecursive(_short_name, '...')
def _container_example(self):
@@ -553,7 +553,7 @@
class OpaqueType(ContainerType):
_gckind = 'raw'
-
+
def __init__(self, tag, hints={}):
""" if hints['render_structure'] is set, the type is internal and not considered
to come from somewhere else (it should be rendered as a structure) """
@@ -723,10 +723,10 @@
def __str__(self):
return '* %s' % (self.TO, )
-
+
def _short_name(self):
return 'Ptr %s' % (self.TO._short_name(), )
-
+
def _is_atomic(self):
return self.TO._gckind == 'raw'
@@ -1520,7 +1520,7 @@
and parentindex in (self._parent_type._names[0], 0)
and self._TYPE._gckind == typeOf(parent)._gckind):
# keep strong reference to parent, we share the same allocation
- self._keepparent = parent
+ self._keepparent = parent
def _parentstructure(self, check=True):
if self._wrparent is not None:
diff --git a/pypy/translator/c/test/test_newgc.py b/pypy/translator/c/test/test_newgc.py
--- a/pypy/translator/c/test/test_newgc.py
+++ b/pypy/translator/c/test/test_newgc.py
@@ -228,7 +228,7 @@
T = lltype.GcStruct("T", ('y', lltype.Signed),
('s', lltype.Ptr(S)))
ARRAY_Ts = lltype.GcArray(lltype.Ptr(T))
-
+
def f():
r = 0
for i in range(30):
@@ -250,7 +250,7 @@
def test_framework_varsized(self):
res = self.run('framework_varsized')
assert res == self.run_orig('framework_varsized')
-
+
def define_framework_using_lists(cls):
class A(object):
pass
@@ -271,7 +271,7 @@
N = 1000
res = self.run('framework_using_lists')
assert res == N*(N - 1)/2
-
+
def define_framework_static_roots(cls):
class A(object):
def __init__(self, y):
@@ -318,8 +318,8 @@
def test_framework_void_array(self):
res = self.run('framework_void_array')
assert res == 44
-
-
+
+
def define_framework_malloc_failure(cls):
def f():
a = [1] * (sys.maxint//2)
@@ -342,7 +342,7 @@
def test_framework_array_of_void(self):
res = self.run('framework_array_of_void')
assert res == 43 + 1000000
-
+
def define_framework_opaque(cls):
A = lltype.GcStruct('A', ('value', lltype.Signed))
O = lltype.GcOpaqueType('test.framework')
@@ -437,7 +437,7 @@
b = B()
return 0
return func
-
+
def test_del_raises(self):
self.run('del_raises') # does not raise
@@ -712,7 +712,7 @@
def test_callback_with_collect(self):
assert self.run('callback_with_collect')
-
+
def define_can_move(cls):
class A:
pass
@@ -1255,7 +1255,7 @@
l1 = []
l2 = []
l3 = []
-
+
def f():
for i in range(10):
s = lltype.malloc(S)
@@ -1298,7 +1298,7 @@
def test_string_builder(self):
res = self.run('string_builder')
assert res == "aabcbdddd"
-
+
def definestr_string_builder_over_allocation(cls):
import gc
def fn(_):
More information about the pypy-commit
mailing list