GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46841: Use inline caching for attribute accesses by brandtbucher · Pull Request #31640 · python/cpython

Conversation

@brandtbucher

@brandtbucher brandtbucher commented Mar 2, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

CC @markshannon. These three share a lot of code, so it makes sense to convert them together.

Marking as DO-NOT-MERGE since LOAD_ATTR_MODULE is somehow causing assertion failures and unclosed resources in test_asyncio:

Details
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=8 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=10 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=8 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/base_events.py:684: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=9 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=10 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=9 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed <socket.socket fd=6, family=1, type=1, proto=0>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=7 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=7 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=7 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=7 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=12 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=14 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=11 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=11 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/base_events.py:684: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=13 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=12 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed <socket.socket fd=11, family=1, type=1, proto=0>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=12 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=12 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=13 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=13 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=18 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=20 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=17 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=17 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/base_events.py:684: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=19 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=18 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed <socket.socket fd=17, family=1, type=1, proto=0>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=18 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=18 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/test_asyncio/test_streams.py:40: ResourceWarning: unclosed file <_io.FileIO name=19 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=19 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=21 idle bufsize=0>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=22 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=24 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=22 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=24 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=21 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=21 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=25 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=27 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=23 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=23 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=26 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=26 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=29 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=29 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=31 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=30 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=30 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=23 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=21 mode='wb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=21 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=24 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=26 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=22 mode='wb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=22 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=27 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=25 mode='wb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=25 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=19 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=19 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=28 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=27 idle bufsize=0>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=30 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=21 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=23 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=25 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=22 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=26 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=24 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=24 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=30 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=27 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=27 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=31 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=35 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=29 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=29 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=36 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=33 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=33 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
python: Python/ceval.c:5334: _PyEval_EvalFrameDefault: Assertion `frame->frame_obj == NULL' failed.
Fatal Python error: Aborted

Current thread 0x00007f0d476a3280 (most recent call first):
  File "/home/brandtbucher/cpython/Lib/textwrap.py", line 482 in prefixed_lines
  File "/home/brandtbucher/cpython/Lib/textwrap.py", line 485 in indent
  File "/home/brandtbucher/cpython/Lib/traceback.py", line 629 in emit
  File "/home/brandtbucher/cpython/Lib/traceback.py", line 907 in format
  File "/home/brandtbucher/cpython/Lib/traceback.py", line 140 in format_exception
  File "/home/brandtbucher/cpython/Lib/test/support/testresult.py", line 92 in __makeErrorDict
  File "/home/brandtbucher/cpython/Lib/test/support/testresult.py", line 102 in addError
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 99 in _addError
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 74 in testPartExecutor
  File "/home/brandtbucher/cpython/Lib/contextlib.py", line 155 in __exit__
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 590 in run
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 646 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/test/support/testresult.py", line 140 in run
  File "/home/brandtbucher/cpython/Lib/test/support/__init__.py", line 1064 in _run_suite
  File "/home/brandtbucher/cpython/Lib/test/support/__init__.py", line 1190 in run_unittest
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 273 in _test_module
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 309 in _runtest_inner2
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 352 in _runtest_inner
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 227 in _runtest
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 257 in runtest
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest_mp.py", line 84 in run_tests_worker
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/main.py", line 678 in _main
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/main.py", line 658 in main
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/main.py", line 736 in main
  File "/home/brandtbucher/cpython/Lib/test/regrtest.py", line 43 in _main
  File "/home/brandtbucher/cpython/Lib/test/regrtest.py", line 47 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main

Any ideas on why that might be are definitely appreciated... I've been staring at this for a while and am completely at a loss. The rest of the PR is ready for review, though.

https://bugs.python.org/issue46841

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
brandtbucher added 5 commits March 1, 2022 17:33
@brandtbucher
Use inline caching for attribute accesses
c2b0713
@brandtbucher
Bump magic number
2d5e15a
@brandtbucher
blurb add
5b06d97
@brandtbucher
Clean things up a bit
828540a
@brandtbucher
Catch up with main
4a6632c
@brandtbucher brandtbucher added the DO-NOT-MERGE label Mar 2, 2022
@brandtbucher
brandtbucher requested a review from markshannon as a code owner March 2, 2022 02:10
@bedevere-bot bedevere-bot added the awaiting core review label Mar 2, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 2, 2022
brandtbucher
brandtbucher commented Mar 2, 2022
View reviewed changes
Comment thread Python/ceval.c Outdated
Comment on lines +1462 to +1463
/* XXX: Remove this next line to make test_asyncio very angry! */ \
DEOPT_IF(LOAD_##attr_or_method == LOAD_ATTR, LOAD_##attr_or_method); \

@brandtbucher brandtbucher Mar 2, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests pass if we deopt every LOAD_ATTR_MODULE right here. Removing this line activates some very strange failures!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@markshannon markshannon Mar 2, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting a _PyLoadMethodCache to a _PyAttrCache may not be valid.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brandtbucher

brandtbucher commented Mar 2, 2022

Copy link
Copy Markdown
Member Author

(We're also going to want to hit this with the buildbots once it's working.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

markshannon
markshannon requested changes Mar 2, 2022
View reviewed changes

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change to use arrays in the structs. It's much clearer that my _m1 field.

But, be careful of casting one struct to another, and be aware that the C compiler treats arrays as simple pointers.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Include/internal/pycore_code.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Include/internal/pycore_code.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Include/internal/pycore_code.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/opcode.py
def_op('BUILD_SET', 104) # Number of set items
def_op('BUILD_MAP', 105) # Number of dict entries
name_op('LOAD_ATTR', 106) # Index in name list
name_op('LOAD_ATTR', 106, 4) # Index in name list

@markshannon markshannon Mar 2, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existence of the LOAD_MODULE_ATTR_OR_METHOD macro implies that the LOAD_ATTR and LOAD_METHOD caches should have the same layout. Yet, this has size 4 and LOAD_METHOD has size 10.

This may be the source of your problem.
Are you using the two version numbers consistently?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Include/internal/pycore_code.h
_Py_CODEUNIT dict_offset;
_Py_CODEUNIT keys_version[2];
_Py_CODEUNIT descr[4];
} _PyLoadMethodCache;

@markshannon markshannon Mar 2, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that LOAD_METHOD_MODULE and LOAD_ATTR_MODULE share code, maybe change this to:

typedef struct {
     _PyAttrCache attr;
    _Py_CODEUNIT keys_version[2];
    _Py_CODEUNIT descr[4];
} _PyLoadMethodCache;

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brandtbucher brandtbucher Mar 3, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather leave it as-is. Otherwise, accessing the attr methods, including the counter, is a bit awkward.

In response to your other comments: I don't think we're doing anything illegal here, since we only use one consistent cache layout for each specialized form (meaning, _PyLoadMethodCache and _AttrCache members never alias each other). The exception is the counter member for all instructions, but C guarantees that it the first member of a struct will always be at offset 0. So no issues there.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Python/ceval.c Outdated
Comment on lines +1462 to +1463
/* XXX: Remove this next line to make test_asyncio very angry! */ \
DEOPT_IF(LOAD_##attr_or_method == LOAD_ATTR, LOAD_##attr_or_method); \

@markshannon markshannon Mar 2, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting a _PyLoadMethodCache to a _PyAttrCache may not be valid.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting changes and removed awaiting core review labels Mar 2, 2022
@bedevere-bot

bedevere-bot commented Mar 2, 2022

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brandtbucher brandtbucher mentioned this pull request Mar 2, 2022
Inline caching faster-cpython/ideas#310
Closed
21 of 26 tasks
@brandtbucher

brandtbucher commented Mar 2, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Marking as DO-NOT-MERGE since LOAD_ATTR_MODULE is somehow causing assertion failures and unclosed resources in test_asyncio:

Details
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=8 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=10 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=8 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/base_events.py:684: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=9 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=10 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=9 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed <socket.socket fd=6, family=1, type=1, proto=0>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=7 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=7 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=7 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=7 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=12 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=14 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=11 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=11 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/base_events.py:684: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=13 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=12 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed <socket.socket fd=11, family=1, type=1, proto=0>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=12 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=12 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=13 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=13 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=18 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=20 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=17 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=17 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/base_events.py:684: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=19 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=18 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed <socket.socket fd=17, family=1, type=1, proto=0>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/support/__init__.py:705: ResourceWarning: unclosed file <_io.FileIO name=18 mode='wb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=18 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/test/test_asyncio/test_streams.py:40: ResourceWarning: unclosed file <_io.FileIO name=19 mode='rb' closefd=True>
  gc.collect()
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=19 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=21 idle bufsize=0>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=22 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=24 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=22 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=24 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=21 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=21 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=25 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=27 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=23 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=23 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=26 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=26 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=29 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=29 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=31 mode='rb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/traceback.py:900: ResourceWarning: unclosed file <_io.FileIO name=30 mode='wb' closefd=True>
  for msg, exc in reversed(output):
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=30 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=23 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=21 mode='wb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=21 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=24 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=26 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=22 mode='wb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=22 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=27 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=25 mode='wb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=25 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=19 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=19 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:1151: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  with self._lock:
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:561: ResourceWarning: unclosed transport <_UnixReadPipeTransport fd=28 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=27 idle bufsize=0>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/events.py:80: ResourceWarning: unclosed file <_io.FileIO name=30 mode='rb' closefd=True>
  self._context.run(self._callback, *self._args)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=21 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=23 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=25 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=22 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=26 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=24 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=24 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=28 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=30 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=27 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=27 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=31 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=35 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=29 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=29 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=36 mode='rb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/textwrap.py:482: ResourceWarning: unclosed file <_io.FileIO name=33 mode='wb' closefd=True>
  def prefixed_lines():
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/home/brandtbucher/cpython/Lib/asyncio/unix_events.py:760: ResourceWarning: unclosed transport <_UnixWritePipeTransport fd=33 open>
  _warn(f"unclosed transport {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
python: Python/ceval.c:5334: _PyEval_EvalFrameDefault: Assertion `frame->frame_obj == NULL' failed.
Fatal Python error: Aborted

Current thread 0x00007f0d476a3280 (most recent call first):
  File "/home/brandtbucher/cpython/Lib/textwrap.py", line 482 in prefixed_lines
  File "/home/brandtbucher/cpython/Lib/textwrap.py", line 485 in indent
  File "/home/brandtbucher/cpython/Lib/traceback.py", line 629 in emit
  File "/home/brandtbucher/cpython/Lib/traceback.py", line 907 in format
  File "/home/brandtbucher/cpython/Lib/traceback.py", line 140 in format_exception
  File "/home/brandtbucher/cpython/Lib/test/support/testresult.py", line 92 in __makeErrorDict
  File "/home/brandtbucher/cpython/Lib/test/support/testresult.py", line 102 in addError
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 99 in _addError
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 74 in testPartExecutor
  File "/home/brandtbucher/cpython/Lib/contextlib.py", line 155 in __exit__
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 590 in run
  File "/home/brandtbucher/cpython/Lib/unittest/case.py", line 646 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 122 in run
  File "/home/brandtbucher/cpython/Lib/unittest/suite.py", line 84 in __call__
  File "/home/brandtbucher/cpython/Lib/test/support/testresult.py", line 140 in run
  File "/home/brandtbucher/cpython/Lib/test/support/__init__.py", line 1064 in _run_suite
  File "/home/brandtbucher/cpython/Lib/test/support/__init__.py", line 1190 in run_unittest
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 273 in _test_module
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 309 in _runtest_inner2
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 352 in _runtest_inner
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 227 in _runtest
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest.py", line 257 in runtest
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/runtest_mp.py", line 84 in run_tests_worker
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/main.py", line 678 in _main
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/main.py", line 658 in main
  File "/home/brandtbucher/cpython/Lib/test/libregrtest/main.py", line 736 in main
  File "/home/brandtbucher/cpython/Lib/test/regrtest.py", line 43 in _main
  File "/home/brandtbucher/cpython/Lib/test/regrtest.py", line 47 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 198 in _run_module_as_main

Okay, that was officially the wildest bug I've ever dealt with.

The problematic bytecode sequence (buried deep in asyncio) was:

LOAD_ATTR
[CACHE]
[CACHE]
[CACHE]
[CACHE]
LOAD_FAST
LOAD_ATTR

Quickened:

LOAD_ATTR_ADAPTIVE
[CACHE]
[CACHE]
[CACHE]
[CACHE]
LOAD_FAST
LOAD_ATTR_ADAPTIVE

After specializating the first LOAD_ATTR_ADAPTIVE:

LOAD_ATTR_MODULE
[<counter>]
[<version[0]>]
[<version[1]>]
[<index>]
LOAD_FAST
LOAD_ATTR_ADAPTIVE

Finally, after specializing the second LOAD_ATTR_ADAPTIVE:

LOAD_ATTR_MODULE
[<counter>]
[<version[0]>]
[<version[1]>]
[LOAD_FAST]
LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE
LOAD_ATTR_INSTANCE_VALUE

Did you catch that? The cached index was turned into a LOAD_FAST!

The code that did that is here. Basically, the low byte of the cached index just happened to be LOAD_FAST__LOAD_FAST, so the LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE specialization code changed it "back" into a LOAD_FAST.

What it really did, though, was change the module attribute cached index from 169 to 124. This also just happened to be a valid index into the os module's __dict__, and on subsequent runs the code ended up calling os.mknod(self._fileno, False) instead of os.set_blocking(self._fileno, False). This silently "works", and causes the code to leak tons of resources and break later in more subtle ways.

Phew.

sweeneyde and arhadthedev reacted with eyes emoji
All reactions
  • 👀 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brandtbucher

brandtbucher commented Mar 2, 2022

Copy link
Copy Markdown
Member Author

This whole incident highlights one limitation with the new inline caching approach: it's no longer safe to peek backwards at previous instructions, since you might actually be looking into a cache entry instead. I don't see how we can keep LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE without making LOAD_FAST adaptive (and even then, it will interact poorly with a previous LOAD_FAST__LOAD_FAST), so it probably just makes the most sense to just remove it for now.

I'll also go over the existing specialization code and see if we're doing this anywhere else.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brandtbucher

brandtbucher commented Mar 2, 2022

Copy link
Copy Markdown
Member Author

It also highlights the need for a quickened=True option in dis that we talked about before. This was a huge pain to debug by hand... _co_quickened helped a lot, though!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brandtbucher

brandtbucher commented Mar 2, 2022

Copy link
Copy Markdown
Member Author

Looping in @sweeneyde, since I might need to get rid of LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE as part of this PR (see my comments above).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brandtbucher
Fix typo
2b876f1
@sweeneyde

sweeneyde commented Mar 3, 2022

Copy link
Copy Markdown
Member

Looping in @sweeneyde, since I might need to get rid of LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE as part of this PR (see my comments above).

I didn't see the macro benchmark needle move too much when it was added, so if it's architecturally necessary to, I have no problem with it being scrapped for now.

brandtbucher reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brandtbucher added 3 commits March 2, 2022 16:44
@brandtbucher
Apply feedback from code review
097fdaf
@brandtbucher
Get rid of LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE
4c71c12
@brandtbucher
Remove workaround
09fbac5
@brandtbucher brandtbucher added awaiting change review and removed DO-NOT-MERGE awaiting changes labels Mar 3, 2022
brandtbucher added 2 commits March 2, 2022 17:37
@brandtbucher
Fix typo
e5229ce
@brandtbucher
SIZEOF_UINTPTR_T isn't defined on Windows
452c78c
@brandtbucher brandtbucher added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 3, 2022
@bedevere-bot

bedevere-bot commented Mar 3, 2022

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @brandtbucher for commit 452c78c 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Mar 3, 2022
@brandtbucher

brandtbucher commented Mar 3, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Buildbot failures look unrelated. x86 Gentoo Installed with X PR was just an SSL timeout, and AMD64 Arch Linux Usan PR is failing with the same errors in other PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

markshannon
markshannon reviewed Mar 3, 2022
View reviewed changes
Comment thread Python/specialize.c
return -1;
}
if (err) {
if (_Py_OPCODE(instr[0]) == LOAD_ATTR_INSTANCE_VALUE) {

@markshannon markshannon Mar 3, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a common pair and it saves a POP/PUSH pair and an incref/decref pair, so I'd like to revisit this in the future.
Do we have an issue for that?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brandtbucher brandtbucher Mar 3, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion: faster-cpython/ideas#291
Issue: https://bugs.python.org/issue46823

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brandtbucher
Fix version number
948a206
@brandtbucher
brandtbucher merged commit 05a8bc1 into python:main Mar 3, 2022
@bedevere-bot bedevere-bot removed the awaiting change review label Mar 3, 2022
@hukkin hukkin mentioned this pull request Mar 4, 2022
bpo-40059: tomllib #31498
Merged
@brandtbucher brandtbucher mentioned this pull request Mar 4, 2022
bpo-46841: Fix BINARY_OP's handling of inline caches #31671
Merged
@brandtbucher brandtbucher mentioned this pull request Apr 10, 2022
Inline bytecode caches #90997
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon markshannon requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@brandtbucher @bedevere-bot @sweeneyde @markshannon @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.