Skip to content

Commit 3b95409

Browse files
committed
[GR-17651] GR-17653 Fix micro_native benchmarks for PyPy and CPython
PullRequest: graalpython/613
2 parents 692e0f1 + c481a72 commit 3b95409

File tree

10 files changed

+33
-30
lines changed

10 files changed

+33
-30
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local const = import 'ci_common/constants.libsonnet';
33
local builder = import 'ci_common/builder.libsonnet';
44

55
{
6-
overlay: "0b8c2c1bde9a5795991150b7de779467c752f7dc",
6+
overlay: "2c03a4e4ad99df9c60094b0b54b5555ceaaf7a19",
77

88
// ======================================================================================================
99
//

graalpython/benchmarks/src/micro/c-call-classmethod.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -45,7 +45,9 @@
4545
} NativeCustomObject;
4646
4747
PyObject* nc_classmethod(PyObject* class, PyObject* args) {
48-
return PyTuple_GET_ITEM(args, 0);
48+
PyObject* item = PyTuple_GET_ITEM(args, 0);
49+
Py_INCREF(item);
50+
return item;
4951
}
5052
5153
static struct PyMethodDef nc_methods[] = {
@@ -74,7 +76,7 @@
7476
0,
7577
0,
7678
Py_TPFLAGS_DEFAULT,
77-
"",
79+
0,
7880
0, /* tp_traverse */
7981
0, /* tp_clear */
8082
0, /* tp_richcompare */
@@ -140,4 +142,3 @@ def measure(num):
140142

141143
def __benchmark__(num=1000000):
142144
measure(num)
143-

graalpython/benchmarks/src/micro/c-instantiation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -71,7 +71,7 @@
7171
0,
7272
0,
7373
Py_TPFLAGS_DEFAULT,
74-
"",
74+
0,
7575
0, /* tp_traverse */
7676
0, /* tp_clear */
7777
0, /* tp_richcompare */
@@ -140,4 +140,3 @@ def measure(num):
140140

141141
def __benchmark__(num=1000000):
142142
measure(num)
143-

graalpython/benchmarks/src/micro/c-list-iterating-obj.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -129,7 +129,7 @@
129129
0,
130130
0,
131131
Py_TPFLAGS_DEFAULT,
132-
"",
132+
0,
133133
0, /* tp_traverse */
134134
0, /* tp_clear */
135135
0, /* tp_richcompare */
@@ -197,4 +197,3 @@ def measure(num):
197197

198198
def __benchmark__(num=1000000):
199199
measure(num)
200-

graalpython/benchmarks/src/micro/c-magic-bool.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -129,7 +129,7 @@
129129
0,
130130
0,
131131
Py_TPFLAGS_DEFAULT,
132-
"",
132+
0,
133133
0, /* tp_traverse */
134134
0, /* tp_clear */
135135
0, /* tp_richcompare */
@@ -202,4 +202,3 @@ def measure(num):
202202

203203
def __benchmark__(num=1000000):
204204
measure(num)
205-

graalpython/benchmarks/src/micro/c-magic-iter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -118,7 +118,7 @@
118118
0,
119119
0,
120120
Py_TPFLAGS_DEFAULT,
121-
"",
121+
0,
122122
0, /* tp_traverse */
123123
0, /* tp_clear */
124124
0, /* tp_richcompare */
@@ -160,7 +160,7 @@
160160
0,
161161
0,
162162
Py_TPFLAGS_DEFAULT,
163-
"",
163+
0,
164164
0, /* tp_traverse */
165165
0, /* tp_clear */
166166
0, /* tp_richcompare */
@@ -249,7 +249,7 @@ def count(num):
249249
val0 = next(it)
250250
val1 = next(it)
251251
val2 = next(it)
252-
252+
253253
return (val0, val1, val2)
254254

255255

@@ -260,4 +260,3 @@ def measure(num):
260260

261261
def __benchmark__(num=1000000):
262262
measure(num)
263-

graalpython/benchmarks/src/micro/c_arith-binop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -63,7 +63,7 @@
6363
0, /* tp_as_buffer */
6464
Py_TPFLAGS_DEFAULT |
6565
Py_TPFLAGS_BASETYPE, /* tp_flags */
66-
"", /* tp_doc */
66+
0, /* tp_doc */
6767
0, /* tp_traverse */
6868
0, /* tp_clear */
6969
0, /* tp_richcompare */

graalpython/benchmarks/src/micro/c_arith_binop_2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -153,7 +153,7 @@
153153
0, /* tp_as_buffer */
154154
Py_TPFLAGS_DEFAULT |
155155
Py_TPFLAGS_BASETYPE, /* tp_flags */
156-
"", /* tp_doc */
156+
0, /* tp_doc */
157157
0, /* tp_traverse */
158158
0, /* tp_clear */
159159
0, /* tp_richcompare */

graalpython/benchmarks/src/micro/c_member_access.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -88,7 +88,7 @@
8888
0, /* tp_as_buffer */
8989
Py_TPFLAGS_DEFAULT |
9090
Py_TPFLAGS_BASETYPE, /* tp_flags */
91-
"", /* tp_doc */
91+
0, /* tp_doc */
9292
0, /* tp_traverse */
9393
0, /* tp_clear */
9494
0, /* tp_richcompare */

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,23 @@ def __init__(self, config_name, options=None, env=None, iterations=None):
161161
except:
162162
self._iterations = None
163163

164+
def override_iterations(self, requested_iterations):
165+
return self._iterations if self._iterations is not None else requested_iterations
166+
164167
def _override_iterations_args(self, args):
165168
_args = []
166169
i = 0
167170
while i < len(args):
168171
arg = args[i]
169172
_args.append(arg)
170173
if arg == '-i':
171-
_args.append(str(self._iterations))
174+
_args.append(str(self.override_iterations(int(args[i + 1]))))
172175
i += 1
173176
i += 1
174177
return _args
175178

176179
def run(self, cwd, args):
177-
if self._iterations is not None:
178-
args = self._override_iterations_args(args)
180+
args = self._override_iterations_args(args)
179181
return super(AbstractPythonIterationsControlVm, self).run(cwd, args)
180182

181183

@@ -202,6 +204,10 @@ class PyPyVm(AbstractPythonIterationsControlVm):
202204
def __init__(self, config_name, options=None, env=None, iterations=None):
203205
super(PyPyVm, self).__init__(config_name, options=options, env=env, iterations=iterations)
204206

207+
def override_iterations(self, requested_iterations):
208+
# PyPy warms up much faster, half should be enough
209+
return int(requested_iterations / 2)
210+
205211
@property
206212
def interpreter(self):
207213
home = mx.get_env(ENV_PYPY_HOME)
@@ -313,7 +319,7 @@ def rules(self, output, benchmarks, bm_suite_args):
313319
return [
314320
# warmup curves
315321
StdOutRule(
316-
r"^### iteration=(?P<iteration>[0-9]+), name=(?P<benchmark>[a-zA-Z0-9.\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
322+
r"^### iteration=(?P<iteration>[0-9]+), name=(?P<benchmark>[a-zA-Z0-9._\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
317323
{
318324
"benchmark": '{}.{}'.format(self._name, bench_name),
319325
"metric.name": "warmup",
@@ -328,7 +334,7 @@ def rules(self, output, benchmarks, bm_suite_args):
328334
),
329335
# no warmups
330336
StdOutRule(
331-
r"^@@@ name=(?P<benchmark>[a-zA-Z0-9.\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
337+
r"^@@@ name=(?P<benchmark>[a-zA-Z0-9._\-]+), duration=(?P<time>[0-9]+(\.[0-9]+)?$)", # pylint: disable=line-too-long
332338
{
333339
"benchmark": '{}.{}'.format(self._name, bench_name),
334340
"metric.name": "time",

0 commit comments

Comments
 (0)