Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix line invalidation speed #891

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

sternj
Copy link
Collaborator

@sternj sternj commented Nov 24, 2024

WIP: Fixes #889

  • A user noticed a major slowdown when trying to import Pytorch. We tracked this down to overly eager calling of the PyEval_SetTrace callback in
    callee frames of "relevant" code. In pre-3.12, there's an easy short-circuiting process. Still a WIP because I'm still hunting down a better solution for 3.12.
  • Fixed issue where PyEval_SetTrace was invoked on the wrong frame.
  • Added smoketests for counting n_mallocs in light of previous issues

TODO:

  • Disable instrumentation in child frames in Python 3.12




print(len(accum))

asdf = bytes(2 * 10485767)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable asdf is not used.
print(len(accum))

asdf = bytes(2 * 10485767)
some_dead_line = None

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable some_dead_line is not used.

print(len(accum))

asdf = bytes(2 * 10485767)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable asdf is not used.
accum = bytes()
for i in range(31):
accum += bytes(2 * 10485767) # 2x the allocation sampling window
bogus = None

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable bogus is not used.
bogus = None
print(len(accum))

asdf = bytes(2 * 10485767)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable asdf is not used.

print(len(accum))

asdf = bytes(2 * 10485767)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable asdf is not used.

print(len(accum))

asdf = bytes(2 * 10485767)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable asdf is not used.
test/test_line_invalidation.py Fixed Show fixed Hide fixed
test/test_line_invalidation.py Fixed Show fixed Hide fixed
Comment on lines +153 to +155
// int lineno;
// int bytei;
// decltype(whereInPython)* where = p_whereInPython;

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
import subprocess
import tempfile
import sys
from typing import List

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'List' is not used.


def get_profile(test_stem, outdir_p, test_dir):
proc = subprocess.run(

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable proc is not used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extra slow pytorch imports (~30s)
1 participant