-
Notifications
You must be signed in to change notification settings - Fork 118
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
Patch for duplicate functions #233
Conversation
@Theelx @notEvil One of the new tests related to duplicate functions is not passing on OSX, and I'm not sure why. It works on locally for me on Linux. The invocation for the test in question is: pytest -sv tests/test_explicit_profile.py -k test_explicit_profile_with_duplicate_functions If either of you has an OSX device to test on, or can offer insights that would be helpful. Could it be the case that the patch should only be applied to 3.11? (The 3.6 test is failining here and I'm not sure if other versions would pass). |
I don't, sry. As for the fix, maybe use |
I do not have an OSX device, sorry. I think it is reasonable to only apply the patch to 3.11. |
I don't think that's a good idea, as it'll just apply padding bytes with a value of 0 to the front of the bytecode, rather than padding with values of 9. See the docs for the length option here. |
Its not just padding, |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #233 +/- ##
==========================================
+ Coverage 51.77% 53.36% +1.59%
==========================================
Files 11 11
Lines 817 832 +15
Branches 164 168 +4
==========================================
+ Hits 423 444 +21
+ Misses 335 329 -6
Partials 59 59
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
The version condition didn't work. Disabling OSX shows that everything else is passing. Going to check if it OSX with other versions also fails. EDIT: it does. It seems like it's just an OSX issue. No clue what it is. |
The failing test in question is running the following code: from line_profiler import profile
@profile
def func1(a):
return a + 1
@profile
def func2(a):
return a + 1
@profile
def func3(a):
return a + 1
@profile
def func4(a):
return a + 1
print(func1.__code__.co_code)
print(func2.__code__.co_code)
print(func3.__code__.co_code)
print(func4.__code__.co_code)
print(func1.__wrapped__.__code__.co_code)
print(func2.__wrapped__.__code__.co_code)
print(func3.__wrapped__.__code__.co_code)
print(func4.__wrapped__.__code__.co_code)
import ubelt as ub
print('profile._profile.code_map = {}'.format(ub.urepr(profile._profile.code_map, nl=1)))
for k, v in profile._profile.code_map.items():
print(k.co_code)
func1(1)
func2(1)
func3(1)
func4(1) The check is just that each of the 4 functions appear in the profile output: assert 'Function: func1' in raw_output
assert 'Function: func2' in raw_output
assert 'Function: func3' in raw_output
assert 'Function: func4' in raw_output The issue is on OSX The test includes debuggine lines to show the modified code binary. On OSX the dashboards show:
But when I run on my linux machine the binary I get for the 4 functions is:
Does anything about these outputs give any hints? |
b63ab15
to
ebb1110
Compare
I think I figured it out. It was an unrelated issue. For some reason on OSX the measured time was zero, which meant it was filtered out by the stripzero condition. I change stripzero to look for zero hits instead of zero time, which is probably the correct behavior anyway. That seems to resolve the issue. |
Attempts to fix: #232
Adds in tests and also contains other code cleanup.