[pypy-commit] pypy cppyy-packaging: rename destruct -> __destruct__ to not interfere with user defined methods
Author: Wim LavrijsenBranch: cppyy-packaging Changeset: r92007:a0f6d0e8e563 Date: 2017-07-31 16:43 -0700 http://bitbucket.org/pypy/pypy/changeset/a0f6d0e8e563/ Log:rename destruct -> __destruct__ to not interfere with user defined methods diff --git a/pypy/module/_cppyy/interp_cppyy.py b/pypy/module/_cppyy/interp_cppyy.py --- a/pypy/module/_cppyy/interp_cppyy.py +++ b/pypy/module/_cppyy/interp_cppyy.py @@ -1195,7 +1195,7 @@ __len__ = interp2app(W_CPPInstance.instance__len__), __cmp__ = interp2app(W_CPPInstance.instance__cmp__), __repr__ = interp2app(W_CPPInstance.instance__repr__), -destruct = interp2app(W_CPPInstance.destruct), +__destruct__ = interp2app(W_CPPInstance.destruct), ) W_CPPInstance.typedef.acceptable_as_base_class = True diff --git a/pypy/module/_cppyy/test/test_advancedcpp.py b/pypy/module/_cppyy/test/test_advancedcpp.py --- a/pypy/module/_cppyy/test/test_advancedcpp.py +++ b/pypy/module/_cppyy/test/test_advancedcpp.py @@ -32,25 +32,25 @@ assert d.m_a == t(11) assert d.m_b == t(22) assert d.m_c == t(33) -d.destruct() +d.__destruct__() d = defaulter(0) assert d.m_a == t(0) assert d.m_b == t(22) assert d.m_c == t(33) -d.destruct() +d.__destruct__() d = defaulter(1, 2) assert d.m_a == t(1) assert d.m_b == t(2) assert d.m_c == t(33) -d.destruct() +d.__destruct__() d = defaulter(3, 4, 5) assert d.m_a == t(3) assert d.m_b == t(4) assert d.m_c == t(5) -d.destruct() +d.__destruct__() test_defaulter('short', int) test_defaulter('ushort', int) test_defaulter('int', int) @@ -87,7 +87,7 @@ assert b.m_db == 11.11 assert b.get_base_value() == 11.11 -b.destruct() +b.__destruct__() d = derived_class() assert isinstance(d, derived_class) @@ -114,7 +114,7 @@ assert d.m_db== 11.11 assert d.get_base_value()== 11.11 -d.destruct() +d.__destruct__() def test03_namespaces(self): """Test access to namespaces and inner classes""" @@ -219,7 +219,7 @@ t1 = gbl.T1(int)() assert t1.m_t1== 1 assert t1.get_value() == 1 -t1.destruct() +t1.__destruct__() #- t1 = gbl.T1(int)(11) @@ -228,14 +228,14 @@ t1.m_t1 = 111 assert t1.get_value() == 111 assert t1.m_t1== 111 -t1.destruct() +t1.__destruct__() #- t2 = gbl.T2(gbl.T1(int))(gbl.T1(int)(32)) t2.m_t2.m_t1 = 32 assert t2.m_t2.get_value() == 32 assert t2.m_t2.m_t1== 32 -t2.destruct() +t2.__destruct__() def test05_abstract_classes(self): @@ -296,7 +296,7 @@ b.m_db = 22.22 assert b.m_db == 22.22 -b.destruct() +b.__destruct__() #- c1 = c_class_1() @@ -317,7 +317,7 @@ assert c1.m_c == 33 assert c1.get_value() == 33 -c1.destruct() +c1.__destruct__() #- d = d_class() @@ -345,7 +345,7 @@ assert d.m_d == 44 assert d.get_value() == 44 -d.destruct() +d.__destruct__() def test07_pass_by_reference(self): """Test reference passing when using virtual inheritance""" @@ -361,7 +361,7 @@ b.m_a, b.m_b = 11, 22 assert gbl.get_a(b) == 11 assert gbl.get_b(b) == 22 -b.destruct() +b.__destruct__() #- c = c_class() @@ -369,7 +369,7 @@ assert gbl.get_a(c) == 11 assert gbl.get_b(c) == 22 assert gbl.get_c(c) == 33 -c.destruct() +c.__destruct__() #- d = d_class() @@ -378,7 +378,7 @@ assert gbl.get_b(d) == 22 assert gbl.get_c(d) == 33 assert gbl.get_d(d) == 44 -d.destruct() +d.__destruct__() def test08_void_pointer_passing(self): """Test passing of variants of void pointer arguments""" @@ -462,8 +462,8 @@ assert not dd1a is dd2 assert not dd1b is dd2 -d2.destruct() -d1.destruct() +d2.__destruct__() +d1.__destruct__() def test11_multi_methods(self): """Test calling of methods from multiple inheritance""" @@ -533,12 +533,12 @@ c1 = _cppyy.gbl.create_c1() assert type(c1) == _cppyy.gbl.c_class_1 assert c1.m_c == 3 -c1.destruct() +c1.__destruct__() c2 = _cppyy.gbl.create_c2() assert type(c2) == _cppyy.gbl.c_class_2 assert c2.m_c == 3 -c2.destruct() +
[pypy-commit] pypy cppyy-packaging: remove old genreflex method ptr patch (not needed with Cling)
Author: Wim LavrijsenBranch: cppyy-packaging Changeset: r92009:f141497a5252 Date: 2017-07-31 16:49 -0700 http://bitbucket.org/pypy/pypy/changeset/f141497a5252/ Log:remove old genreflex method ptr patch (not needed with Cling) diff --git a/pypy/module/_cppyy/genreflex-methptrgetter.patch b/pypy/module/_cppyy/genreflex-methptrgetter.patch deleted file mode 100644 --- a/pypy/module/_cppyy/genreflex-methptrgetter.patch +++ /dev/null @@ -1,125 +0,0 @@ -Index: cint/reflex/python/genreflex/gendict.py -=== cint/reflex/python/genreflex/gendict.py(revision 43705) -+++ cint/reflex/python/genreflex/gendict.py(working copy) -@@ -52,6 +52,7 @@ - self.typedefs_for_usr = [] - self.gccxmlvers = gccxmlvers - self.split = opts.get('split', '') -+self.with_methptrgetter = opts.get('with_methptrgetter', False) - # The next is to avoid a known problem with gccxml that it generates a - # references to id equal '_0' which is not defined anywhere - self.xref['_0'] = {'elem':'Unknown', 'attrs':{'id':'_0','name':''}, 'subelems':[]} -@@ -1328,6 +1329,8 @@ - bases = self.getBases( attrs['id'] ) - if inner and attrs.has_key('demangled') and self.isUnnamedType(attrs['demangled']) : - cls = attrs['demangled'] -+ if self.xref[attrs['id']]['elem'] == 'Union': -+ return 80*' ' - clt = '' - else: - cls = self.genTypeName(attrs['id'],const=True,colon=True) -@@ -1365,7 +1368,7 @@ - # Inner class/struct/union/enum. - for m in memList : - member = self.xref[m] --if member['elem'] in ('Class','Struct','Union','Enumeration') \ -+if member['elem'] in ('Class','Struct','Enumeration') \ -and member['attrs'].get('access') in ('private','protected') \ -and not self.isUnnamedType(member['attrs'].get('demangled')): - cmem = self.genTypeName(member['attrs']['id'],const=True,colon=True) -@@ -2003,8 +2006,15 @@ - else: params = '0' - s = ' .AddFunctionMember(%s, Reflex::Literal("%s"), %s%s, 0, %s, %s)' % (self.genTypeID(id), name, type, id, params, mod) - s += self.genCommentProperty(attrs) -+s += self.genMethPtrGetterProperty(type, attrs) - return s - #-- -+ def genMethPtrGetterProperty(self, type, attrs): -+funcname = self.nameOfMethPtrGetter(type, attrs) -+if funcname is None: -+ return '' -+return '\n .AddProperty("MethPtrGetter", (void*)%s)' % funcname -+#-- - def genMCODef(self, type, name, attrs, args): - id = attrs['id'] - cl = self.genTypeName(attrs['context'],colon=True) -@@ -2071,8 +2081,44 @@ - if returns == 'void' : body += ' }\n' - else : body += ' }\n' - body += '}\n' --return head + body; -+methptrgetter = self.genMethPtrGetter(type, name, attrs, args) -+return head + body + methptrgetter - #-- -+ def nameOfMethPtrGetter(self, type, attrs): -+id = attrs['id'] -+if self.with_methptrgetter and 'static' not in attrs and type in ('operator', 'method'): -+ return '%s%s_methptrgetter' % (type, id) -+return None -+#-- -+ def genMethPtrGetter(self, type, name, attrs, args): -+funcname = self.nameOfMethPtrGetter(type, attrs) -+if funcname is None: -+ return '' -+id = attrs['id'] -+cl = self.genTypeName(attrs['context'],colon=True) -+rettype = self.genTypeName(attrs['returns'],enum=True, const=True, colon=True) -+arg_type_list = [self.genTypeName(arg['type'], colon=True) for arg in args] -+constness = attrs.get('const', 0) and 'const' or '' -+lines = [] -+a = lines.append -+a('static void* %s(void* o)' % (funcname,)) -+a('{') -+if name == 'EmitVA': -+ # TODO: this is for ROOT TQObject, the problem being that ellipses is not -+ # exposed in the arguments and that makes the generated code fail if the named -+ # method is overloaded as is with TQObject::EmitVA -+ a(' return (void*)0;') -+else: -+ # declare a variable "meth" which is a member pointer -+ a(' %s (%s::*meth)(%s)%s;' % (rettype, cl, ', '.join(arg_type_list), constness)) -+ a(' meth = (%s (%s::*)(%s)%s)&%s::%s;' % \ -+ (rettype, cl, ', '.join(arg_type_list), constness, cl, name)) -+ a(' %s* obj = (%s*)o;' % (cl, cl)) -+ a(' return (void*)(obj->*meth);') -+a('}') -+return '\n'.join(lines) -+ -+#-- - def getDefaultArgs(self, args): - n = 0 - for a in args : -Index:
[pypy-commit] pypy cppyy-packaging: remove backend code (lives in http://bitbucket/wlav/cppyy-backend and is shared with CPython) and the builtin capi option
Author: Wim LavrijsenBranch: cppyy-packaging Changeset: r92008:80bd00a75270 Date: 2017-07-31 16:48 -0700 http://bitbucket.org/pypy/pypy/changeset/80bd00a75270/ Log:remove backend code (lives in http://bitbucket/wlav/cppyy-backend and is shared with CPython) and the builtin capi option (never used in production) diff too long, truncating to 2000 out of 3411 lines diff --git a/pypy/module/_cppyy/backend/create_cppyy_package.py b/pypy/module/_cppyy/backend/create_cppyy_package.py deleted file mode 100755 --- a/pypy/module/_cppyy/backend/create_cppyy_package.py +++ /dev/null @@ -1,649 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function - -import os, sys -import argparse, re, shutil, tarfile, urllib2 - - -DEBUG_TESTBUILD = False - -TARBALL_CACHE_DIR = 'releases' - -ROOT_KEEP = ['build', 'cmake', 'config', 'core', 'etc', 'interpreter', - 'io', 'LICENSE', 'net', 'Makefile', 'CMakeLists.txt', 'math', - 'main'] # main only needed in more recent root b/c of rootcling -ROOT_CORE_KEEP = ['CMakeLists.txt', 'base', 'clib', 'clingutils', 'cont', - 'dictgen', 'foundation', 'lzma', 'macosx', 'meta', - 'metacling', 'metautils', 'rootcling_stage1', 'textinput', - 'thread', 'unix', 'utils', 'winnt', 'zip'] -ROOT_IO_KEEP = ['CMakeLists.txt', 'io', 'rootpcm'] -ROOT_NET_KEEP = ['CMakeLists.txt', 'net'] -ROOT_MATH_KEEP = ['CMakeLists.txt', 'mathcore'] -ROOT_ETC_KEEP = ['Makefile.arch', 'class.rules', 'cmake', 'dictpch', - 'gdb-backtrace.sh', 'gitinfo.txt', 'helgrind-root.supp', - 'hostcert.conf', 'system.plugins-ios', - 'valgrind-root-python.supp', 'valgrind-root.supp', 'vmc'] - -ROOT_EXPLICIT_REMOVE = ['core/base/v7', 'math/mathcore/v7', 'io/io/v7'] - - -ERR_RELEASE_NOT_FOUND = 2 - - -# -## CLI arguments -# -class ReleaseValidation(argparse.Action): -def __call__(self, parser, namespace, value, option_string=None): -if not re.match(r'6\.\d\d\.\d\d', value): -raise argparse.ArgumentTypeError( -"release number should of the form '6.dd.dd'") -setattr(namespace, self.dest, value) -return value - -parser = argparse.ArgumentParser( -description='Build PyPi package for cppyy containing the minimum of ROOT') -parser.add_argument('-r', '--release', type=str, nargs='?', -action=ReleaseValidation, help='ROOT release to use') - -args = parser.parse_args() - - -# -## ROOT source pull and cleansing -# -def clean_directory(directory, keeplist, trim_cmake=True): -removed_entries = [] -for entry in os.listdir(directory): -if entry[0] == '.' or entry in keeplist: -continue -removed_entries.append(entry) -entry = os.path.join(directory, entry) -print('now removing', entry) -if os.path.isdir(entry): -shutil.rmtree(entry) -else: -os.remove(entry) - -if not trim_cmake: -return - -# now take the removed entries out of the CMakeLists.txt -if removed_entries: -inp = os.path.join(directory, 'CMakeLists.txt') -print('trimming', inp) -outp = inp+'.new' -new_cml = open(outp, 'w') -for line in open(inp).readlines(): -if ('add_subdirectory' in line) or\ - ('COMMAND' in line and 'copy' in line) or\ - ('ROOT_ADD_TEST_SUBDIRECTORY' in line) or\ - ('install(DIRECTORY' in line): -for sub in removed_entries: -if sub in line: -line = '#'+line -break -new_cml.write(line) -new_cml.close() -os.rename(outp, inp) -else: -print('reusing existing %s/CMakeLists.txt' % (directory,)) - - -class ReleaseValidation(argparse.Action): -def __call__(self, parser, namespace, value, option_string=None): -if not re.match(r'6\.\d\d\.\d\d', value): -raise argparse.ArgumentTypeError( -"release number should of the form '6.dd.dd'") -setattr(namespace, self.dest, value) -return value - -parser = argparse.ArgumentParser( -description='Build PyPi package for cppyy containing the minimum of ROOT') -parser.add_argument('-r', '--release', type=str, nargs='?', -action=ReleaseValidation, help='ROOT release to use') - -args = parser.parse_args() - -if not os.path.exists(TARBALL_CACHE_DIR): -os.mkdir(TARBALL_CACHE_DIR) - -if args.release: - # use provided release -fn = 'root_v%s.source.tar.gz' % args.release -addr = 'https://root.cern.ch/download/'+fn -if not os.path.exists(os.path.join(TARBALL_CACHE_DIR, fn)): -try: -print('retrieving', fn) -resp = urllib2.urlopen(addr, fn) -out = open(os.path.join(TARBALL_CACHE_DIR, fn), 'wb') -out.write(resp.read()) -
[pypy-commit] pypy cppyy-packaging: remove benchmarking code
Author: Wim LavrijsenBranch: cppyy-packaging Changeset: r92010:74ed34cfb42c Date: 2017-07-31 16:51 -0700 http://bitbucket.org/pypy/pypy/changeset/74ed34cfb42c/ Log:remove benchmarking code diff --git a/pypy/module/_cppyy/bench/Makefile b/pypy/module/_cppyy/bench/Makefile deleted file mode 100644 --- a/pypy/module/_cppyy/bench/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -all: bench02Dict_reflex.so - -ROOTSYS := ${ROOTSYS} - -ifeq ($(ROOTSYS),) - genreflex=genreflex - cppflags= -else - genreflex=$(ROOTSYS)/bin/genreflex - cppflags=-I$(ROOTSYS)/include -L$(ROOTSYS)/lib -endif - -PLATFORM := $(shell uname -s) -ifeq ($(PLATFORM),Darwin) - cppflags+=-dynamiclib -single_module -arch x86_64 -endif - -ifeq ($(shell $(genreflex) --help | grep -- --with-methptrgetter),) - genreflexflags= - cppflags2=-O3 -fPIC -else - genreflexflags=--with-methptrgetter - cppflags2=-Wno-pmf-conversions -O3 -fPIC -endif - - -bench02Dict_reflex.so: bench02.h bench02.cxx bench02.xml - $(genreflex) bench02.h $(genreflexflags) --selection=bench02.xml -I$(ROOTSYS)/include - g++ -o $@ bench02.cxx bench02_rflx.cpp -I$(ROOTSYS)/include -shared -std=c++11 -lHistPainter `root-config --libs` $(cppflags) $(cppflags2) diff --git a/pypy/module/_cppyy/bench/bench02.cxx b/pypy/module/_cppyy/bench/bench02.cxx deleted file mode 100644 --- a/pypy/module/_cppyy/bench/bench02.cxx +++ /dev/null @@ -1,79 +0,0 @@ -#include "bench02.h" - -#include "TROOT.h" -#include "TApplication.h" -#include "TDirectory.h" -#include "TInterpreter.h" -#include "TSystem.h" -#include "TBenchmark.h" -#include "TStyle.h" -#include "TError.h" -#include "Getline.h" -#include "TVirtualX.h" - -#include "Api.h" - -#include - -TClass *TClass::GetClass(const char*, Bool_t, Bool_t) { -static TClass* dummy = new TClass("__dummy__", kTRUE); -return dummy; // is deleted by gROOT at shutdown -} - -class TTestApplication : public TApplication { -public: -TTestApplication( -const char* acn, Int_t* argc, char** argv, Bool_t bLoadLibs = kTRUE); -virtual ~TTestApplication(); -}; - -TTestApplication::TTestApplication( -const char* acn, int* argc, char** argv, bool do_load) : TApplication(acn, argc, argv) { -if (do_load) { -// follow TRint to minimize differences with CINT -ProcessLine("#include ", kTRUE); -ProcessLine("#include <_string>", kTRUE); // for std::string iostream. -ProcessLine("#include ", kTRUE); // needed because they're used within the -ProcessLine("#include ", kTRUE); // core ROOT dicts and CINT won't be able - // to properly unload these files -} - -// save current interpreter context -gInterpreter->SaveContext(); -gInterpreter->SaveGlobalsContext(); - -// prevent crashes on accessing history -Gl_histinit((char*)"-"); - -// prevent ROOT from exiting python -SetReturnFromRun(kTRUE); -} - -TTestApplication::~TTestApplication() {} - -static const char* appname = "pypy-cppyy"; - -Bench02RootApp::Bench02RootApp() { -gROOT->SetBatch(kTRUE); -if (!gApplication) { -int argc = 1; -char* argv[1]; argv[0] = (char*)appname; -gApplication = new TTestApplication(appname, , argv, kFALSE); -} -} - -Bench02RootApp::~Bench02RootApp() { -// TODO: ROOT globals cleanup ... (?) -} - -void Bench02RootApp::report() { -std::cout << "gROOT is: " << gROOT << std::endl; -std::cout << "gApplication is: " << gApplication << std::endl; -} - -void Bench02RootApp::close_file(TFile* f) { -std::cout << "closing file " << f->GetName() << " ... " << std::endl; -f->Write(); -f->Close(); -std::cout << "... file closed" << std::endl; -} diff --git a/pypy/module/_cppyy/bench/bench02.h b/pypy/module/_cppyy/bench/bench02.h deleted file mode 100644 --- a/pypy/module/_cppyy/bench/bench02.h +++ /dev/null @@ -1,72 +0,0 @@ -#include "TString.h" - -#include "TCanvas.h" -#include "TFile.h" -#include "TProfile.h" -#include "TNtuple.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TRandom.h" -#include "TRandom3.h" - -#include "TROOT.h" -#include "TApplication.h" -#include "TSystem.h" - -#include "TArchiveFile.h" -#include "TBasket.h" -#include "TBenchmark.h" -#include "TBox.h" -#include "TBranchRef.h" -#include "TBrowser.h" -#include "TClassGenerator.h" -#include "TClassRef.h" -#include "TClassStreamer.h" -#include "TContextMenu.h" -#include "TEntryList.h" -#include "TEventList.h" -#include "TF1.h" -#include "TFileCacheRead.h" -#include "TFileCacheWrite.h" -#include "TFileMergeInfo.h" -#include "TFitResult.h" -#include "TFolder.h" -//#include "TFormulaPrimitive.h" -#include "TFunction.h" -#include "TFrame.h" -#include "TGlobal.h" -#include "THashList.h" -#include "TInetAddress.h" -#include "TInterpreter.h" -#include "TKey.h" -#include "TLegend.h" -#include "TMethodCall.h" -#include "TPluginManager.h" -#include "TProcessUUID.h" -#include
[pypy-commit] stmgc c8-tcp-style-trx-length: Disable slow start
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2135:d9897d451fff Date: 2017-07-23 13:36 +0200 http://bitbucket.org/pypy/stmgc/changeset/d9897d451fff/ Log:Disable slow start diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -55,10 +55,10 @@ if (new > 1) { new = 1; } -if (tl->linear_transaction_length_increment != 0) { -// thread had to abort before: slow start -set_backoff(tl, new); -} +// if (tl->linear_transaction_length_increment != 0) { +// // thread had to abort before: slow start +// set_backoff(tl, new); +// } } else { // not abort and backoff != 0 // in backoff, linear increase up to 1 new = previous + tl->linear_transaction_length_increment; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Distinguish min and default trx length to allow shrinking to single instruction level
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2132:c6265dd2c77c Date: 2017-07-21 11:29 +0200 http://bitbucket.org/pypy/stmgc/changeset/c6265dd2c77c/ Log:Distinguish min and default trx length to allow shrinking to single instruction level diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -22,12 +22,18 @@ // #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000L // corresponds to ~4 KB nursery fill -#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) +#define STM_DEFAULT_REL_TRANSACTION_LENGTH (0.01) +// commit after ~4 B or likely after every instruction +#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.1) + #define BACKOFF_COUNT (10) -#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) +#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_DEFAULT_REL_TRANSACTION_LENGTH)) static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) { -// the shorter the trx, the more backoff: 100 at min trx length, proportional decrease to 5 at max trx length (think a/x + b = backoff) +/* the shorter the trx, the more backoff: +think a*x + b = backoff, x := -log(rel-trx-len), +backoff is + b at default trx length, +linear decrease to b at max trx length */ tl->transaction_length_backoff = (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + 5); // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); diff --git a/c8/stm/setup.c b/c8/stm/setup.c --- a/c8/stm/setup.c +++ b/c8/stm/setup.c @@ -247,7 +247,7 @@ tl->thread_local_counter = ++thread_local_counters; /* init adaptive transaction length mode */ -tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH; +tl->relative_transaction_length = STM_DEFAULT_REL_TRANSACTION_LENGTH; tl->transaction_length_backoff = 0; tl->linear_transaction_length_increment = 0; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Initialize trx len roughly to old default of 1MB and hard cap on lower limit of 4KB
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2140:3bc9bfa7d481 Date: 2017-07-24 16:24 +0200 http://bitbucket.org/pypy/stmgc/changeset/3bc9bfa7d481/ Log:Initialize trx len roughly to old default of 1MB and hard cap on lower limit of 4KB diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -17,12 +17,14 @@ #define DEFAULT_FILL_MARK_NURSERY_BYTES (NURSERY_SIZE / 4) -// #define LARGE_FILL_MARK_NURSERY_BYTES DEFAULT_FILL_MARK_NURSERY_BYTES +// corresponds to ~4 GB #define LARGE_FILL_MARK_NURSERY_BYTES 0x1L -// #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000L +// corresponds to ~4 MB nursery fill +#define STM_DEFAULT_RELATIVE_TRANSACTION_LENGTH (0.001) // corresponds to ~4 KB nursery fill #define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) + #define BACKOFF_COUNT (20) #define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) @@ -45,8 +47,7 @@ if (aborts) { new = previous / multiplier; if (new < STM_MIN_RELATIVE_TRANSACTION_LENGTH) { -// reached min trx length, only decrease slowly -new = 0.9 * previous; +new = STM_MIN_RELATIVE_TRANSACTION_LENGTH; } set_backoff(tl, new); } else if (tl->transaction_length_backoff == 0) { diff --git a/c8/stm/setup.c b/c8/stm/setup.c --- a/c8/stm/setup.c +++ b/c8/stm/setup.c @@ -247,7 +247,7 @@ tl->thread_local_counter = ++thread_local_counters; /* init adaptive transaction length mode */ -tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH; +tl->relative_transaction_length = STM_DEFAULT_RELATIVE_TRANSACTION_LENGTH; tl->transaction_length_backoff = 0; tl->linear_transaction_length_increment = 0; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Backed out changeset dbea548c4c6e
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2136:5563999ed658 Date: 2017-07-23 13:37 +0200 http://bitbucket.org/pypy/stmgc/changeset/5563999ed658/ Log:Backed out changeset dbea548c4c6e diff --git a/c8/stm/core.c b/c8/stm/core.c --- a/c8/stm/core.c +++ b/c8/stm/core.c @@ -347,9 +347,6 @@ } if (thread_local_for_logging != NULL) { -if (needs_abort) { -stm_transaction_length_handle_validation(thread_local_for_logging, true); -} stop_timer_and_publish_for_thread( thread_local_for_logging, STM_DURATION_VALIDATION); } @@ -1585,6 +1582,8 @@ tl->self_or_0_if_atomic = (intptr_t)tl; /* clear the 'atomic' flag */ STM_PSEGMENT->atomic_nesting_levels = 0; +stm_transaction_length_handle_validation(tl, true); + if (tl->mem_clear_on_abort) memset(tl->mem_clear_on_abort, 0, tl->mem_bytes_to_clear_on_abort); if (tl->mem_reset_on_abort) { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Backed out changeset feed32340eb2
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2138:48e819b53680 Date: 2017-07-24 10:42 +0200 http://bitbucket.org/pypy/stmgc/changeset/48e819b53680/ Log:Backed out changeset feed32340eb2 diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -32,7 +32,7 @@ backoff is + b at default trx length, linear decrease to b at max trx length */ const int b = 5; -tl->transaction_length_backoff += +tl->transaction_length_backoff = (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + b); // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); tl->linear_transaction_length_increment = rel_trx_len / (BACKOFF_COUNT + b); ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Set backoff to best working value so far and re-enable slow start
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2139:6a3c6e601284 Date: 2017-07-24 11:10 +0200 http://bitbucket.org/pypy/stmgc/changeset/6a3c6e601284/ Log:Set backoff to best working value so far and re-enable slow start diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -23,7 +23,7 @@ // corresponds to ~4 KB nursery fill #define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) -#define BACKOFF_COUNT (5) +#define BACKOFF_COUNT (20) #define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) { @@ -32,10 +32,10 @@ backoff is + b at default trx length, linear decrease to b at max trx length */ const int b = 5; -tl->transaction_length_backoff = -(int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + b); +int new_backoff = (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + b); +tl->transaction_length_backoff = new_backoff; // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); -tl->linear_transaction_length_increment = rel_trx_len / (BACKOFF_COUNT + b); +tl->linear_transaction_length_increment = rel_trx_len / new_backoff; } static inline double get_new_transaction_length(stm_thread_local_t *tl, bool aborts) { @@ -55,10 +55,10 @@ if (new > 1) { new = 1; } -// if (tl->linear_transaction_length_increment != 0) { -// // thread had to abort before: slow start -// set_backoff(tl, new); -// } +if (tl->linear_transaction_length_increment != 0) { +// thread had to abort before: slow start +set_backoff(tl, new); +} } else { // not abort and backoff != 0 // in backoff, linear increase up to 1 new = previous + tl->linear_transaction_length_increment; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Grow backoff cumulatively on repeated aborts
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2137:feed32340eb2 Date: 2017-07-23 17:29 +0200 http://bitbucket.org/pypy/stmgc/changeset/feed32340eb2/ Log:Grow backoff cumulatively on repeated aborts diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -32,7 +32,7 @@ backoff is + b at default trx length, linear decrease to b at max trx length */ const int b = 5; -tl->transaction_length_backoff = +tl->transaction_length_backoff += (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + b); // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); tl->linear_transaction_length_increment = rel_trx_len / (BACKOFF_COUNT + b); ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Backed out changeset c6265dd2c77c
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2133:08a8d7fd1866 Date: 2017-07-21 14:19 +0200 http://bitbucket.org/pypy/stmgc/changeset/08a8d7fd1866/ Log:Backed out changeset c6265dd2c77c diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -22,18 +22,12 @@ // #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000L // corresponds to ~4 KB nursery fill -#define STM_DEFAULT_REL_TRANSACTION_LENGTH (0.01) -// commit after ~4 B or likely after every instruction -#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.1) - +#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) #define BACKOFF_COUNT (10) -#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_DEFAULT_REL_TRANSACTION_LENGTH)) +#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) { -/* the shorter the trx, the more backoff: -think a*x + b = backoff, x := -log(rel-trx-len), -backoff is + b at default trx length, -linear decrease to b at max trx length */ +// the shorter the trx, the more backoff: 100 at min trx length, proportional decrease to 5 at max trx length (think a/x + b = backoff) tl->transaction_length_backoff = (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + 5); // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); diff --git a/c8/stm/setup.c b/c8/stm/setup.c --- a/c8/stm/setup.c +++ b/c8/stm/setup.c @@ -247,7 +247,7 @@ tl->thread_local_counter = ++thread_local_counters; /* init adaptive transaction length mode */ -tl->relative_transaction_length = STM_DEFAULT_REL_TRANSACTION_LENGTH; +tl->relative_transaction_length = STM_MIN_RELATIVE_TRANSACTION_LENGTH; tl->transaction_length_backoff = 0; tl->linear_transaction_length_increment = 0; ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Merge warm up complete event
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2141:2828bbba12a4 Date: 2017-07-29 11:25 +0200 http://bitbucket.org/pypy/stmgc/changeset/2828bbba12a4/ Log:Merge warm up complete event diff --git a/c8/stmgc.h b/c8/stmgc.h --- a/c8/stmgc.h +++ b/c8/stmgc.h @@ -583,6 +583,8 @@ STM_GC_MAJOR_DONE, /* execution duration profiling events */ +STM_WARMUP_COMPLETE, + STM_DURATION_START_TRX, STM_DURATION_WRITE_GC_ONLY, STM_DURATION_WRITE_SLOWPATH, @@ -613,6 +615,7 @@ "gc major start", \ "gc major done",\ /* names of duration events */ \ +"marks completion of benchmark warm up phase" \ "duration of transaction start",\ "duration of gc due to write", \ "duration of write slowpath", \ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Decrease trx len just ten percent at a time below min
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2134:70e630a22710 Date: 2017-07-21 14:42 +0200 http://bitbucket.org/pypy/stmgc/changeset/70e630a22710/ Log:Decrease trx len just ten percent at a time below min diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -23,15 +23,19 @@ // corresponds to ~4 KB nursery fill #define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) -#define BACKOFF_COUNT (10) +#define BACKOFF_COUNT (5) #define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) { -// the shorter the trx, the more backoff: 100 at min trx length, proportional decrease to 5 at max trx length (think a/x + b = backoff) +/* the shorter the trx, the more backoff: +think a*x + b = backoff, x := -log(rel-trx-len), +backoff is + b at default trx length, +linear decrease to b at max trx length */ +const int b = 5; tl->transaction_length_backoff = -(int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + 5); +(int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + b); // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); -tl->linear_transaction_length_increment = rel_trx_len / BACKOFF_COUNT; +tl->linear_transaction_length_increment = rel_trx_len / (BACKOFF_COUNT + b); } static inline double get_new_transaction_length(stm_thread_local_t *tl, bool aborts) { @@ -41,7 +45,8 @@ if (aborts) { new = previous / multiplier; if (new < STM_MIN_RELATIVE_TRANSACTION_LENGTH) { -new = STM_MIN_RELATIVE_TRANSACTION_LENGTH; +// reached min trx length, only decrease slowly +new = 0.9 * previous; } set_backoff(tl, new); } else if (tl->transaction_length_backoff == 0) { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Increase min trx length and fix capping trx length
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2131:d86628e2626c Date: 2017-07-20 20:15 +0200 http://bitbucket.org/pypy/stmgc/changeset/d86628e2626c/ Log:Increase min trx length and fix capping trx length diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -21,9 +21,9 @@ #define LARGE_FILL_MARK_NURSERY_BYTES 0x1L // #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000L -// corresponds to ~430 bytes nursery fill -#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.001) -#define BACKOFF_COUNT (20) +// corresponds to ~4 KB nursery fill +#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) +#define BACKOFF_COUNT (10) #define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) { @@ -37,18 +37,18 @@ static inline double get_new_transaction_length(stm_thread_local_t *tl, bool aborts) { const int multiplier = 2; double previous = tl->relative_transaction_length; -double new = previous; +double new; if (aborts) { -if (previous > STM_MIN_RELATIVE_TRANSACTION_LENGTH) { -new = previous / multiplier; -} else { +new = previous / multiplier; +if (new < STM_MIN_RELATIVE_TRANSACTION_LENGTH) { new = STM_MIN_RELATIVE_TRANSACTION_LENGTH; } set_backoff(tl, new); } else if (tl->transaction_length_backoff == 0) { // backoff counter is zero, exponential increase up to 1 -if (previous < 1) { -new = previous * multiplier; +new = previous * multiplier; +if (new > 1) { +new = 1; } if (tl->linear_transaction_length_increment != 0) { // thread had to abort before: slow start @@ -56,8 +56,9 @@ } } else { // not abort and backoff != 0 // in backoff, linear increase up to 1 -if (previous < 1) { -new = previous + tl->linear_transaction_length_increment; +new = previous + tl->linear_transaction_length_increment; +if (new > 1) { +new = 1; } tl->transaction_length_backoff -= 1; } ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] stmgc c8-tcp-style-trx-length: Set exponential base to two, i.e., double trx length on commit
Author: Tobias WeberBranch: c8-tcp-style-trx-length Changeset: r2130:dba308a7d960 Date: 2017-07-17 16:53 +0200 http://bitbucket.org/pypy/stmgc/changeset/dba308a7d960/ Log:Set exponential base to two, i.e., double trx length on commit diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c --- a/c8/stm/nursery.c +++ b/c8/stm/nursery.c @@ -18,23 +18,24 @@ #define DEFAULT_FILL_MARK_NURSERY_BYTES (NURSERY_SIZE / 4) // #define LARGE_FILL_MARK_NURSERY_BYTES DEFAULT_FILL_MARK_NURSERY_BYTES -#define LARGE_FILL_MARK_NURSERY_BYTES 0x1000L +#define LARGE_FILL_MARK_NURSERY_BYTES 0x1L // #define LARGE_FILL_MARK_NURSERY_BYTES 0x1000L -// corresponds to ~270 bytes nursery fill -#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.01) -#define BACKOFF_MULTIPLIER (20 / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) +// corresponds to ~430 bytes nursery fill +#define STM_MIN_RELATIVE_TRANSACTION_LENGTH (0.001) +#define BACKOFF_COUNT (20) +#define BACKOFF_MULTIPLIER (BACKOFF_COUNT / -log10(STM_MIN_RELATIVE_TRANSACTION_LENGTH)) static inline void set_backoff(stm_thread_local_t *tl, double rel_trx_len) { // the shorter the trx, the more backoff: 100 at min trx length, proportional decrease to 5 at max trx length (think a/x + b = backoff) tl->transaction_length_backoff = (int)((BACKOFF_MULTIPLIER * -log10(rel_trx_len)) + 5); // printf("thread %d, backoff %d\n", tl->thread_local_counter, tl->transaction_length_backoff); -tl->linear_transaction_length_increment = rel_trx_len; +tl->linear_transaction_length_increment = rel_trx_len / BACKOFF_COUNT; } static inline double get_new_transaction_length(stm_thread_local_t *tl, bool aborts) { -const int multiplier = 100; +const int multiplier = 2; double previous = tl->relative_transaction_length; double new = previous; if (aborts) { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove leftover test_cint.py (and higher directories)
Author: Wim LavrijsenBranch: Changeset: r92006:edf12627beaf Date: 2017-07-31 15:52 -0700 http://bitbucket.org/pypy/pypy/changeset/edf12627beaf/ Log:remove leftover test_cint.py (and higher directories) diff --git a/pypy/module/cppyy/test/test_cint.py b/pypy/module/cppyy/test/test_cint.py deleted file mode 100644 --- a/pypy/module/cppyy/test/test_cint.py +++ /dev/null @@ -1,710 +0,0 @@ -import py, os, sys - -# These tests are for the CINT backend only (they exercise ROOT features -# and classes that are not loaded/available with the Reflex backend). At -# some point, these tests are likely covered by the CLang/LLVM backend. -from pypy.module.cppyy import capi -if capi.identify() != 'CINT': -py.test.skip("backend-specific: CINT-only tests") - -# load _cffi_backend early, or its global vars are counted as leaks in the -# test (note that the module is not otherwise used in the test itself) -from pypy.module._cffi_backend import newtype - -currpath = py.path.local(__file__).dirpath() -iotypes_dct = str(currpath.join("iotypesDict.so")) - -def setup_module(mod): -if sys.platform == 'win32': -py.test.skip("win32 not supported so far") -err = os.system("cd '%s' && make CINT=t iotypesDict.so" % currpath) -if err: -raise OSError("'make' failed (see stderr)") - -class AppTestCINT: -spaceconfig = dict(usemodules=['cppyy', '_rawffi', 'itertools']) - -def test01_globals(self): -"""Test the availability of ROOT globals""" - -import cppyy - -assert cppyy.gbl.gROOT -assert cppyy.gbl.gApplication -assert cppyy.gbl.gSystem -assert cppyy.gbl.TInterpreter.Instance() # compiled -assert cppyy.gbl.TInterpreter # interpreted -assert cppyy.gbl.TDirectory.CurrentDirectory() # compiled -assert cppyy.gbl.TDirectory# interpreted - -def test02_write_access_to_globals(self): -"""Test overwritability of ROOT globals""" - -import cppyy - -oldval = cppyy.gbl.gDebug -assert oldval != 3 - -proxy = cppyy.gbl.__class__.__dict__['gDebug'] -cppyy.gbl.gDebug = 3 -assert proxy.__get__(proxy, None) == 3 - -# this is where this test differs from test03_write_access_to_globals -# in test_pythonify.py -cppyy.gbl.gROOT.ProcessLine('int gDebugCopy = gDebug;') -assert cppyy.gbl.gDebugCopy == 3 - -cppyy.gbl.gDebug = oldval - -def test03_create_access_to_globals(self): -"""Test creation and access of new ROOT globals""" - -import cppyy - -cppyy.gbl.gROOT.ProcessLine('double gMyOwnGlobal = 3.1415') -assert cppyy.gbl.gMyOwnGlobal == 3.1415 - -proxy = cppyy.gbl.__class__.__dict__['gMyOwnGlobal'] -assert proxy.__get__(proxy, None) == 3.1415 - -def test04_auto_loading(self): -"""Test auto-loading by retrieving a non-preloaded class""" - -import cppyy - -l = cppyy.gbl.TLorentzVector() -assert isinstance(l, cppyy.gbl.TLorentzVector) - -def test05_macro_loading(self): -"""Test accessibility to macro classes""" - -import cppyy - -loadres = cppyy.gbl.gROOT.LoadMacro('simple_class.C') -assert loadres == 0 - -base = cppyy.gbl.MySimpleBase -simple = cppyy.gbl.MySimpleDerived -simple_t = cppyy.gbl.MySimpleDerived_t - -assert issubclass(simple, base) -assert simple is simple_t - -c = simple() -assert isinstance(c, simple) -assert c.m_data == c.get_data() - -c.set_data(13) -assert c.m_data == 13 -assert c.get_data() == 13 - - -class AppTestCINTPYTHONIZATIONS: -spaceconfig = dict(usemodules=['cppyy', '_rawffi', 'itertools']) - -def test01_strings(self): -"""Test TString/TObjString compatibility""" - -import cppyy - -pyteststr = "aap noot mies" -def test_string(s1, s2): -assert len(s1) == len(s2) -assert s1 == s1 -assert s1 == s2 -assert s1 == str(s1) -assert s1 == pyteststr -assert s1 != "aap" -assert s1 != "" -assert s1 < "noot" -assert repr(s1) == repr(s2) - -s1 = cppyy.gbl.TString(pyteststr) -test_string(s1, pyteststr) - -s3 = cppyy.gbl.TObjString(pyteststr) -test_string(s3, pyteststr) - -def test03_TVector(self): -"""Test TVector2/3/T behavior""" - -import cppyy, math - -N = 51 - -# TVectorF is a typedef of floats -v = cppyy.gbl.TVectorF(N) -for i in range(N): -v[i] = i*i - -assert len(v) == N -for j in v: -assert round(v[int(math.sqrt(j)+0.5)]-j, 5) == 0. - -def test04_TStringTObjString(self): -"""Test string/TString interchangebility""" - -import cppyy - -test = "aap
[pypy-commit] pypy cpyext-leakchecking: fix pseudo-leak in test_traceback.py
Author: Ronan LamyBranch: cpyext-leakchecking Changeset: r92005:5e01a8ace2de Date: 2017-07-31 21:56 +0100 http://bitbucket.org/pypy/pypy/changeset/5e01a8ace2de/ Log:fix pseudo-leak in test_traceback.py diff --git a/pypy/module/cpyext/test/test_traceback.py b/pypy/module/cpyext/test/test_traceback.py --- a/pypy/module/cpyext/test/test_traceback.py +++ b/pypy/module/cpyext/test/test_traceback.py @@ -3,17 +3,19 @@ from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref from pypy.module.cpyext.pytraceback import PyTracebackObject from pypy.interpreter.pytraceback import PyTraceback -from pypy.interpreter.pyframe import PyFrame +from pypy.interpreter.baseobjspace import AppExecCache class TestPyTracebackObject(BaseApiTest): def test_traceback(self, space, api): -w_traceback = space.appexec([], """(): +src = """(): import sys try: 1/0 except: return sys.exc_info()[2] -""") +""" +w_traceback = space.appexec([], src) + py_obj = make_ref(space, w_traceback) py_traceback = rffi.cast(PyTracebackObject, py_obj) assert (from_ref(space, rffi.cast(PyObject, py_traceback.c_ob_type)) is @@ -38,3 +40,5 @@ assert lltype.normalizeptr(py_traceback) is None api.Py_DecRef(py_obj) +# hack to allow the code object to be freed +del space.fromcache(AppExecCache).content[src] ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: Create builtin pyobjs early for interp-level tests as well
Author: Ronan LamyBranch: cpyext-leakchecking Changeset: r92004:ee6ee454da80 Date: 2017-07-31 21:50 +0100 http://bitbucket.org/pypy/pypy/changeset/ee6ee454da80/ Log:Create builtin pyobjs early for interp-level tests as well diff --git a/pypy/module/cpyext/test/test_api.py b/pypy/module/cpyext/test/test_api.py --- a/pypy/module/cpyext/test/test_api.py +++ b/pypy/module/cpyext/test/test_api.py @@ -6,7 +6,8 @@ from pypy.module.cpyext.api import ( slot_function, cpython_api, copy_header_files, INTERPLEVEL_API, Py_ssize_t, Py_ssize_tP, PyObject, cts) -from pypy.module.cpyext.test.test_cpyext import freeze_refcnts, LeakCheckingTest +from pypy.module.cpyext.test.test_cpyext import ( +freeze_refcnts, LeakCheckingTest) from pypy.interpreter.error import OperationError from rpython.rlib import rawrefcount import os @@ -32,6 +33,7 @@ space.call_function(space.getattr(space.sys.get("stdout"), space.wrap("write")), space.wrap("")) +cls.preload_builtins(space) class CAPI: def __getattr__(self, name): diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -76,6 +76,23 @@ def freeze_refcnts(self): rawrefcount._dont_free_any_more() +def preload(space, name): +from pypy.module.cpyext.pyobject import make_ref +if '.' not in name: +w_obj = space.builtin.getdictvalue(space, name) +else: +module, localname = name.rsplit('.', 1) +code = "(): import {module}; return {module}.{localname}" +code = code.format(**locals()) +w_obj = space.appexec([], code) +make_ref(space, w_obj) + +def preload_expr(space, expr): +from pypy.module.cpyext.pyobject import make_ref +code = "(): return {}".format(expr) +w_obj = space.appexec([], code) +make_ref(space, w_obj) + def is_interned_string(space, w_obj): try: s = space.str_w(w_obj) @@ -118,6 +135,24 @@ 'micronumpy', 'mmap' ]) +@classmethod +def preload_builtins(cls, space): +""" +Eagerly create pyobjs for various builtins so they don't look like +leaks. +""" +space.getbuiltinmodule("cpyext") +# 'import os' to warm up reference counts +w_import = space.builtin.getdictvalue(space, '__import__') +space.call_function(w_import, space.wrap("os")) +for name in [ +'buffer', 'mmap.mmap', +'types.FunctionType', 'types.CodeType', +'types.TracebackType', 'types.FrameType']: +preload(space, name) +for expr in ['type(str.join)']: +preload_expr(space, expr) + def cleanup(self): self.space.getexecutioncontext().cleanup_cpyext_state() rawrefcount._collect() @@ -178,23 +213,6 @@ def debug_collect(space): rawrefcount._collect() -def preload(space, name): -from pypy.module.cpyext.pyobject import make_ref -if '.' not in name: -w_obj = space.builtin.getdictvalue(space, name) -else: -module, localname = name.rsplit('.', 1) -code = "(): import {module}; return {module}.{localname}" -code = code.format(**locals()) -w_obj = space.appexec([], code) -make_ref(space, w_obj) - -def preload_expr(space, expr): -from pypy.module.cpyext.pyobject import make_ref -code = "(): return {}".format(expr) -w_obj = space.appexec([], code) -make_ref(space, w_obj) - class AppTestCpythonExtensionBase(LeakCheckingTest): @@ -205,20 +223,8 @@ cls.w_runappdirect = space.wrap(cls.runappdirect) if not cls.runappdirect: cls.sys_info = get_cpyext_info(space) -space.getbuiltinmodule("cpyext") -# 'import os' to warm up reference counts -w_import = space.builtin.getdictvalue(space, '__import__') -space.call_function(w_import, space.wrap("os")) -for name in [ -'buffer', 'mmap.mmap', -'types.FunctionType', 'types.CodeType', -'types.TracebackType', 'types.FrameType']: -preload(space, name) -for expr in ['type(str.join)']: -preload_expr(space, expr) -#state = cls.space.fromcache(RefcountState) ZZZ -#state.non_heaptypes_w[:] = [] cls.w_debug_collect = space.wrap(interp2app(debug_collect)) +cls.preload_builtins(space) else: def w_import_module(self, name, init=None, body='', filename=None, include_dirs=None, PY_SSIZE_T_CLEAN=False): ___ pypy-commit mailing list pypy-commit@python.org
[pypy-commit] pypy default: document merged branches
Author: Matti PicusBranch: Changeset: r92003:97134fb162c0 Date: 2017-07-31 22:57 +0300 http://bitbucket.org/pypy/pypy/changeset/97134fb162c0/ Log:document merged branches diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -38,3 +38,18 @@ Renaming of ``cppyy`` to ``_cppyy``. The former is now an external package installable with ``pip install cppyy``. + +.. branch: Enable_PGO_for_clang + +.. branch: nopax + +Deleted ``--nopax`` option + +.. branch: pypy_bytearray + +Improve ``bytearray`` performance (backported from py3.5) + +.. branch: gc-del-limit-growth + +Fix the bounds in the GC when allocating a lot of objects with finalizers, +fixes issue #2590 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: encode the type name to bytes for interpolation
Author: Jean-Paul CalderoneBranch: py3.5 Changeset: r92002:22c27ed7a494 Date: 2017-07-31 14:59 -0400 http://bitbucket.org/pypy/pypy/changeset/22c27ed7a494/ Log:encode the type name to bytes for interpolation fixes annotator error: string formatting mixing strings and unicode not supported diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py --- a/pypy/objspace/std/bytesobject.py +++ b/pypy/objspace/std/bytesobject.py @@ -752,7 +752,7 @@ def _get_printable_location(w_type): return ('bytearray_from_byte_sequence [w_type=%s]' % -w_type.getname(w_type.space)) +w_type.getname(w_type.space).encode('utf-8')) _byteseq_jitdriver = jit.JitDriver( name='bytearray_from_byte_sequence', ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: Preload a few more builtin types
Author: Ronan LamyBranch: cpyext-leakchecking Changeset: r92000:466144c090c7 Date: 2017-07-31 15:46 +0100 http://bitbucket.org/pypy/pypy/changeset/466144c090c7/ Log:Preload a few more builtin types diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -209,7 +209,10 @@ # 'import os' to warm up reference counts w_import = space.builtin.getdictvalue(space, '__import__') space.call_function(w_import, space.wrap("os")) -for name in ['buffer', 'mmap.mmap']: +for name in [ +'buffer', 'mmap.mmap', +'types.FunctionType', 'types.CodeType', +'types.TracebackType', 'types.FrameType']: preload(space, name) for expr in ['type(str.join)']: preload_expr(space, expr) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: fix refleaks in test_tupleobject
Author: Ronan LamyBranch: cpyext-leakchecking Changeset: r92001:d4f923fa8dfa Date: 2017-07-31 16:54 +0100 http://bitbucket.org/pypy/pypy/changeset/d4f923fa8dfa/ Log:fix refleaks in test_tupleobject diff --git a/pypy/module/cpyext/test/test_tupleobject.py b/pypy/module/cpyext/test/test_tupleobject.py --- a/pypy/module/cpyext/test/test_tupleobject.py +++ b/pypy/module/cpyext/test/test_tupleobject.py @@ -24,6 +24,7 @@ def test_tuple_realize_refuses_nulls(self, space, api): py_tuple = api.PyTuple_New(1) py.test.raises(FatalError, from_ref, space, py_tuple) +api.Py_DecRef(py_tuple) def test_tuple_resize(self, space, api): w_42 = space.wrap(42) @@ -70,6 +71,7 @@ w_tuple = from_ref(space, py_tuple) assert space.eq_w(w_tuple, space.newtuple([space.wrap(42), space.wrap(43)])) +api.Py_DecRef(py_tuple) def test_getslice(self, space, api): w_tuple = space.newtuple([space.wrap(i) for i in range(10)]) @@ -174,6 +176,7 @@ res = PyTuple_SetItem(tuple, 0, one); if (res != 0) { +Py_DECREF(one); Py_DECREF(tuple); return NULL; } @@ -187,14 +190,13 @@ /* Do something that uses the tuple, but does not incref */ t2 = PyTuple_GetSlice(tuple, 0, 1); Py_DECREF(t2); -Py_INCREF(one); res = PyTuple_SetItem(tuple, 0, one); -Py_DECREF(tuple); if (res != 0) { -Py_DECREF(one); +Py_DECREF(tuple); return NULL; } +Py_DECREF(tuple); Py_INCREF(Py_None); return Py_None; """), @@ -205,4 +207,3 @@ raises(SystemError, module.set_after_use, s) else: module.set_after_use(s) - diff --git a/pypy/module/cpyext/tupleobject.py b/pypy/module/cpyext/tupleobject.py --- a/pypy/module/cpyext/tupleobject.py +++ b/pypy/module/cpyext/tupleobject.py @@ -143,6 +143,7 @@ old_ref = tupleobj.c_ob_item[index] if pyobj_has_w_obj(ref): # similar but not quite equal to ref.c_ob_refcnt != 1 on CPython +decref(space, py_obj) raise oefmt(space.w_SystemError, "PyTuple_SetItem called on tuple after" " use of tuple") tupleobj.c_ob_item[index] = py_obj# consumes a reference ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: Add more information when the leakfinder finds an error
Author: Ronan LamyBranch: cpyext-leakchecking Changeset: r91999:e4f438ccf573 Date: 2017-07-31 14:19 +0100 http://bitbucket.org/pypy/pypy/changeset/e4f438ccf573/ Log:Add more information when the leakfinder finds an error diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -7,6 +7,8 @@ from pypy.interpreter.error import OperationError from rpython.rtyper.lltypesystem import lltype from pypy.module.cpyext import api +from pypy.module.cpyext.api import cts +from pypy.module.cpyext.pyobject import from_ref from pypy.module.cpyext.state import State from rpython.tool import leakfinder from rpython.rlib import rawrefcount @@ -82,8 +84,6 @@ return space.is_interned_str(s) def is_allowed_to_leak(space, obj): -from pypy.module.cpyext.pyobject import from_ref -from pypy.module.cpyext.api import cts from pypy.module.cpyext.methodobject import W_PyCFunctionObject try: w_obj = from_ref(space, cts.cast('PyObject*', obj._as_ptr())) @@ -95,6 +95,21 @@ # the test, but the w_obj is referred to from elsewhere. return is_interned_string(space, w_obj) +def _get_w_obj(space, c_obj): +return from_ref(space, cts.cast('PyObject*', c_obj._as_ptr())) + +class CpyextLeak(leakfinder.MallocMismatch): +def __str__(self): +lines = [leakfinder.MallocMismatch.__str__(self), ''] +lines.append( +"These objects are attached to the following W_Root objects:") +for c_obj in self.args[0]: +try: +lines.append(" %s" % (_get_w_obj(self.args[1], c_obj),)) +except: +pass +return '\n'.join(lines) + class LeakCheckingTest(object): """Base class for all cpyext tests.""" @@ -116,7 +131,7 @@ if not is_allowed_to_leak(self.space, obj): filtered_result[obj] = value if filtered_result: -raise leakfinder.MallocMismatch(filtered_result) +raise CpyextLeak(filtered_result, self.space) assert not self.space.finalizer_queue.next_dead() ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: hg merge default
Author: Armin RigoBranch: py3.5 Changeset: r91998:2ae11d0d2965 Date: 2017-07-31 14:13 +0200 http://bitbucket.org/pypy/pypy/changeset/2ae11d0d2965/ Log:hg merge default diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst --- a/pypy/doc/whatsnew-head.rst +++ b/pypy/doc/whatsnew-head.rst @@ -5,6 +5,14 @@ .. this is a revision shortly after release-pypy2.7-v5.8.0 .. startrev: 558bd00b3dd8 +In previous versions of PyPy, ``instance.method`` would return always +the same bound method object, when gotten out of the same instance (as +far as ``is`` and ``id()`` can tell). CPython doesn't do that. Now +PyPy, like CPython, returns a different bound method object every time. +For ``type.method``, PyPy2 still returns always the same *unbound* +method object; CPython does it for built-in types but not for +user-defined types. + .. branch: cffi-complex .. branch: cffi-char16-char32 diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py --- a/pypy/objspace/std/bytesobject.py +++ b/pypy/objspace/std/bytesobject.py @@ -2,8 +2,7 @@ from rpython.rlib import jit from rpython.rlib.objectmodel import ( -compute_hash, compute_unique_id, import_from_mixin, newlist_hint, -resizelist_hint) +compute_hash, compute_unique_id, import_from_mixin) from rpython.rlib.rstring import StringBuilder from pypy.interpreter.baseobjspace import W_Root @@ -751,14 +750,40 @@ return _from_byte_sequence(space, w_source) +def _get_printable_location(w_type): +return ('bytearray_from_byte_sequence [w_type=%s]' % +w_type.getname(w_type.space)) + +_byteseq_jitdriver = jit.JitDriver( +name='bytearray_from_byte_sequence', +greens=['w_type'], +reds=['w_iter', 'builder'], +get_printable_location=_get_printable_location) + def _from_byte_sequence(space, w_source): # Split off in a separate function for the JIT's benefit -w_result = space.appexec([w_source], """(seq): -result = bytearray() -for i in seq: -result.append(i) -return result""") -return ''.join(w_result.getdata()) +# and add a jitdriver with the type of w_iter as the green key +w_iter = space.iter(w_source) +length_hint = space.length_hint(w_source, 0) +builder = StringBuilder(length_hint) +# +_from_byte_sequence_loop(space, w_iter, builder) +# +return builder.build() + +def _from_byte_sequence_loop(space, w_iter, builder): +w_type = space.type(w_iter) +while True: +_byteseq_jitdriver.jit_merge_point(w_type=w_type, + w_iter=w_iter, + builder=builder) +try: +w_item = space.next(w_iter) +except OperationError as e: +if not e.match(space, space.w_StopIteration): +raise +break +builder.append(space.byte_w(w_item)) W_BytesObject.typedef = TypeDef( "bytes", None, None, "read", diff --git a/pypy/objspace/std/test/test_bytearrayobject.py b/pypy/objspace/std/test/test_bytearrayobject.py --- a/pypy/objspace/std/test/test_bytearrayobject.py +++ b/pypy/objspace/std/test/test_bytearrayobject.py @@ -466,6 +466,13 @@ raises(TypeError, b.extend, [object()]) raises(TypeError, b.extend, "unicode") +def test_extend_calls_len_or_lengthhint(self): +class BadLen(object): +def __iter__(self): return iter(range(10)) +def __len__(self): raise RuntimeError('hello') +b = bytearray() +raises(RuntimeError, b.extend, BadLen()) + def test_setitem_from_front(self): b = bytearray(b'abcdefghij') b[:2] = b'' diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -2308,6 +2308,7 @@ ll_assert(not (self.probably_young_objects_with_finalizers .non_empty()), "probably_young_objects_with_finalizers should be empty") +self.kept_alive_by_finalizer = r_uint(0) if self.old_objects_with_finalizers.non_empty(): self.deal_with_objects_with_finalizers() elif self.old_objects_with_weakrefs.non_empty(): @@ -2380,6 +2381,9 @@ # we currently have -- but no more than 'max_delta' more than # we currently have. total_memory_used = float(self.get_total_memory_used()) +total_memory_used -= float(self.kept_alive_by_finalizer) +if total_memory_used < 0: +total_memory_used = 0 bounded = self.set_major_threshold_from( min(total_memory_used * self.major_collection_threshold, total_memory_used + self.max_delta), @@ -2418,7 +2422,7 @@
[pypy-commit] pypy py3.5: Un-xfail a test; delete one that doesn't make sense on pypy3
Author: Ronan LamyBranch: py3.5 Changeset: r91997:46c9f0976aad Date: 2017-07-31 12:54 +0100 http://bitbucket.org/pypy/pypy/changeset/46c9f0976aad/ Log:Un-xfail a test; delete one that doesn't make sense on pypy3 diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -90,7 +90,6 @@ assert not self.space.finalizer_queue.next_dead() -@pytest.mark.xfail(reason="Skipped until other tests in this file are unskipped") class AppTestApi(LeakCheckingTest): def setup_class(cls): from rpython.rlib.clibffi import get_libc_name @@ -112,12 +111,6 @@ def test_only_import(self): import cpyext -@pytest.mark.skipif(only_pypy, reason='pypy only test') -def test_load_error(self): -import cpyext -raises(ImportError, cpyext.load_module, "missing.file", "foo") -raises(ImportError, cpyext.load_module, self.libc, "invalid.function") - def test_dllhandle(self): import sys if sys.platform != "win32" or sys.version_info < (2, 6): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: hg merge gc-del-limit-growth
Author: Armin RigoBranch: Changeset: r91995:44577e4653fa Date: 2017-07-30 18:58 +0200 http://bitbucket.org/pypy/pypy/changeset/44577e4653fa/ Log:hg merge gc-del-limit-growth Issue #2590: fix the bounds in the GC when allocating a lot of objects with finalizers diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -2308,6 +2308,7 @@ ll_assert(not (self.probably_young_objects_with_finalizers .non_empty()), "probably_young_objects_with_finalizers should be empty") +self.kept_alive_by_finalizer = r_uint(0) if self.old_objects_with_finalizers.non_empty(): self.deal_with_objects_with_finalizers() elif self.old_objects_with_weakrefs.non_empty(): @@ -2380,6 +2381,9 @@ # we currently have -- but no more than 'max_delta' more than # we currently have. total_memory_used = float(self.get_total_memory_used()) +total_memory_used -= float(self.kept_alive_by_finalizer) +if total_memory_used < 0: +total_memory_used = 0 bounded = self.set_major_threshold_from( min(total_memory_used * self.major_collection_threshold, total_memory_used + self.max_delta), @@ -2418,7 +2422,7 @@ self.execute_finalizers() #END FINALIZING else: -pass #XXX which exception to raise here. Should be unreachable. +ll_assert(False, "bogus gc_state") debug_print("stopping, now in gc state: ", GC_STATES[self.gc_state]) debug_stop("gc-collect-step") @@ -2784,8 +2788,17 @@ def _bump_finalization_state_from_0_to_1(self, obj): ll_assert(self._finalization_state(obj) == 0, "unexpected finalization state != 0") +size_gc_header = self.gcheaderbuilder.size_gc_header +totalsize = size_gc_header + self.get_size(obj) hdr = self.header(obj) hdr.tid |= GCFLAG_FINALIZATION_ORDERING +# A bit hackish, but we will not count these objects as "alive" +# for the purpose of computing when the next major GC should +# occur. This is done for issue #2590: without this, if we +# allocate mostly objects with finalizers, the +# next_major_collection_threshold grows forever and actual +# memory usage is not bounded. +self.kept_alive_by_finalizer += raw_malloc_usage(totalsize) def _recursively_bump_finalization_state_from_2_to_3(self, obj): ll_assert(self._finalization_state(obj) == 2, diff --git a/rpython/memory/gc/minimark.py b/rpython/memory/gc/minimark.py --- a/rpython/memory/gc/minimark.py +++ b/rpython/memory/gc/minimark.py @@ -1636,6 +1636,7 @@ # with a finalizer and all objects reachable from there (and also # moves some objects from 'objects_with_finalizers' to # 'run_finalizers'). +self.kept_alive_by_finalizer = r_uint(0) if self.old_objects_with_finalizers.non_empty(): self.deal_with_objects_with_finalizers() # @@ -1678,6 +1679,9 @@ # we currently have -- but no more than 'max_delta' more than # we currently have. total_memory_used = float(self.get_total_memory_used()) +total_memory_used -= float(self.kept_alive_by_finalizer) +if total_memory_used < 0: +total_memory_used = 0 bounded = self.set_major_threshold_from( min(total_memory_used * self.major_collection_threshold, total_memory_used + self.max_delta), @@ -1999,8 +2003,11 @@ def _bump_finalization_state_from_0_to_1(self, obj): ll_assert(self._finalization_state(obj) == 0, "unexpected finalization state != 0") +size_gc_header = self.gcheaderbuilder.size_gc_header +totalsize = size_gc_header + self.get_size(obj) hdr = self.header(obj) hdr.tid |= GCFLAG_FINALIZATION_ORDERING +self.kept_alive_by_finalizer += raw_malloc_usage(totalsize) def _recursively_bump_finalization_state_from_2_to_3(self, obj): ll_assert(self._finalization_state(obj) == 2, diff --git a/rpython/memory/test/test_minimark_gc.py b/rpython/memory/test/test_minimark_gc.py --- a/rpython/memory/test/test_minimark_gc.py +++ b/rpython/memory/test/test_minimark_gc.py @@ -1,3 +1,4 @@ +from rpython.rlib import rgc from rpython.rlib.rarithmetic import LONG_BIT from rpython.memory.test import test_semispace_gc @@ -9,3 +10,39 @@ GC_CAN_SHRINK_BIG_ARRAY = False GC_CAN_MALLOC_NONMOVABLE = True BUT_HOW_BIG_IS_A_BIG_STRING = 11*WORD + +def test_bounded_memory_when_allocating_with_finalizers(self): +# Issue #2590: when
[pypy-commit] pypy default: Fix for b43a6e2c0ea1: can't very reasonably use appexec() here,
Author: Armin RigoBranch: Changeset: r91996:abb9f6f4b003 Date: 2017-07-31 09:40 +0200 http://bitbucket.org/pypy/pypy/changeset/abb9f6f4b003/ Log:Fix for b43a6e2c0ea1: can't very reasonably use appexec() here, because it would create a single jit loop. If the logic is called with various types in the same program, we get a longer and longer jit loop keeping previous results alive. Fixed the same way than listobject.py's _do_extend_from_iterable. diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py --- a/pypy/objspace/std/bytearrayobject.py +++ b/pypy/objspace/std/bytearrayobject.py @@ -569,14 +569,43 @@ return list(buf.as_str()) return _from_byte_sequence(space, w_source) +def _get_printable_location(w_type): +return ('bytearray_from_byte_sequence [w_type=%s]' % +w_type.getname(w_type.space)) + +_byteseq_jitdriver = jit.JitDriver( +name='bytearray_from_byte_sequence', +greens=['w_type'], +reds=['w_iter', 'data'], +get_printable_location=_get_printable_location) + def _from_byte_sequence(space, w_source): # Split off in a separate function for the JIT's benefit -w_result = space.appexec([w_source], """(seq): -result = bytearray() -for i in seq: -result.append(i) -return result""") -return w_result.getdata() +# and add a jitdriver with the type of w_iter as the green key +w_iter = space.iter(w_source) +length_hint = space.length_hint(w_source, 0) +data = newlist_hint(length_hint) +# +_from_byte_sequence_loop(space, w_iter, data) +# +extended = len(data) +if extended < length_hint: +resizelist_hint(data, extended) +return data + +def _from_byte_sequence_loop(space, w_iter, data): +w_type = space.type(w_iter) +while True: +_byteseq_jitdriver.jit_merge_point(w_type=w_type, + w_iter=w_iter, + data=data) +try: +w_item = space.next(w_iter) +except OperationError as e: +if not e.match(space, space.w_StopIteration): +raise +break +data.append(space.byte_w(w_item)) def _hex_digit_to_int(d): diff --git a/pypy/objspace/std/test/test_bytearrayobject.py b/pypy/objspace/std/test/test_bytearrayobject.py --- a/pypy/objspace/std/test/test_bytearrayobject.py +++ b/pypy/objspace/std/test/test_bytearrayobject.py @@ -448,6 +448,13 @@ raises(TypeError, b.extend, [object()]) raises(TypeError, b.extend, u"unicode") +def test_extend_calls_len_or_lengthhint(self): +class BadLen(object): +def __iter__(self): return iter(range(10)) +def __len__(self): raise RuntimeError('hello') +b = bytearray() +raises(RuntimeError, b.extend, BadLen()) + def test_setitem_from_front(self): b = bytearray(b'abcdefghij') b[:2] = b'' ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy gc-del-limit-growth: Close branch, ready to merge
Author: Armin RigoBranch: gc-del-limit-growth Changeset: r91994:f0335bf5364e Date: 2017-07-30 18:56 +0200 http://bitbucket.org/pypy/pypy/changeset/f0335bf5364e/ Log:Close branch, ready to merge ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: Minor fix
Author: Armin RigoBranch: Changeset: r2997:5052e1026bbd Date: 2017-07-31 11:28 +0200 http://bitbucket.org/cffi/cffi/changeset/5052e1026bbd/ Log:Minor fix diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -4737,9 +4737,9 @@ /* update the total alignment requirement, but skip it if the field is an anonymous bitfield or if SF_PACKED */ falignorg = get_alignment(ftype); +if (falignorg < 0) +goto error; falign = (sflags & SF_PACKED) ? 1 : falignorg; -if (falign < 0) -goto error; do_align = 1; if (!(sflags & SF_GCC_ARM_BITFIELDS) && fbitsize >= 0) { ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit