Skip to content

Commit ce28f50

Browse files
committed
gh-139103: Address review comments
1 parent 202504c commit ce28f50

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

‎Lib/test/test_opcache.py‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import threading
66
import types
77
import unittest
8-
import weakref
98
from test.support import (threading_helper, check_impl_detail,
109
requires_specialization, Py_GIL_DISABLED,
11-
cpython_only, requires_jit_disabled, reset_code,
12-
gc_collect)
10+
cpython_only, requires_jit_disabled, reset_code)
1311
from test.support.import_helper import import_module
1412

1513
# Skip this module on other interpreters, it is cpython specific:
@@ -2258,22 +2256,16 @@ class Holder:
22582256
attr = Value()
22592257

22602258
value = Holder.attr
2261-
wr = weakref.ref(value)
22622259

22632260
def load_class_attr():
22642261
for _ in range(_testinternalcapi.SPECIALIZATION_THRESHOLD):
22652262
x = Holder.attr
2266-
assert x is value
22672263

22682264
# Ensure we specialise from a non owning thread
22692265
threading_helper.run_concurrently(load_class_attr, nthreads=1)
22702266
self.assert_no_opcode(load_class_attr, "LOAD_ATTR_CLASS")
22712267
self.assertTrue(_testinternalcapi.has_deferred_refcount(value))
22722268

2273-
del load_class_attr, Holder, value
2274-
gc_collect()
2275-
self.assertIsNone(wr())
2276-
22772269

22782270
if __name__ == "__main__":
22792271
unittest.main()

‎Tools/ftscalingbench/ftscalingbench.py‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,9 @@ def enum_attr():
326326
MyEnum.Z
327327

328328

329-
class _SharedAttrValue:
330-
pass
331-
332329
class MyClassWithSharedAttr:
333-
# A class attribute whose value is an instance of a *different* class.
334-
# Reading it from multiple threads did not scale because LOAD_ATTR_CLASS
335-
# cannot specialize this case (the value's type is not the owner class),
336-
# leaving the shared value's reference count contended on every read.
337-
attr = _SharedAttrValue()
330+
# instance of another heap type: LOAD_ATTR_CLASS can't specialize this
331+
attr = MyObject()
338332

339333
@register_benchmark
340334
def class_attribute():

0 commit comments

Comments
 (0)