Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[postponed] Set f_trace_lines = 0/False on ignored frames#791

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
blueyed wants to merge2 commits intocoveragepy:masterfromblueyed:f_trace_lines

Conversation

@blueyed
Copy link
Contributor

@blueyedblueyed commentedMar 31, 2019
edited
Loading

This is meant for optimization, so that the trace handler is not called
for lines in blocks that are not traced.

TODO:

This is meant for optimization, so that the trace handler is not calledfor lines in blocks that are not traced.
@blueyed
Copy link
ContributorAuthor

blueyed commentedMar 31, 2019
edited
Loading

This is not much of a gain for the CTracer, but for PyTracer.

With this patchtox -e py37-coverage -- testing/test_asser* in pytest's repo takes 50.5s, without it 116.7s (usingtimid = 1 to use the PyTracer).

CTracer: 20.5s without this patch, 20.0s with it (but just run once, it is likely due to a function call being less of an overhead in C).

@blueyed
Copy link
ContributorAuthor

This appears to be py37+ only.

And pdb/bdb would need to be fixed to set it to True explicitly (https://bugs.python.org/issue36494).

@blueyed
Copy link
ContributorAuthor

Added to cpython inpython/cpython@5a85167 (bpo-31344).

There alsof_trace_opcodes was added (which must be enabled explicitly).

@codecov-io
Copy link

codecov-io commentedMar 31, 2019
edited
Loading

Codecov Report

Merging#791 intomaster willdecrease coverage by0.01%.
The diff coverage is33.33%.

Impacted file tree graph

@@            Coverage Diff             @@##           master     #791      +/-   ##==========================================- Coverage   90.24%   90.22%   -0.02%==========================================  Files          78       78                Lines       10884    10887       +3       Branches     1127     1128       +1     ==========================================+ Hits         9822     9823       +1- Misses        939      941       +2  Partials      123      123
Impacted FilesCoverage Δ
coverage/pytracer.py21.15% <33.33%> (+0.36%)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update820b255...6682675. Read thecomment docs.

@nedbat
Copy link
Member

We should be returning None for the trace function if we don't want to trace the frame, and that should be enough. But I don't see where we're returning None. Or is this the decade-old bug?

Yep, it is:https://bugs.python.org/issue11992sigh

@blueyed
Copy link
ContributorAuthor

I've tried returning None also before, but stopped when noticing that several tests were failing due to it, and assumed coverage.py needs to trace everything still internally. (I've also tried (quickly) to not add todata_stack etc, to match the behavior of "return" not being called anymore).

@blueyed
Copy link
ContributorAuthor

pypy2 failure (https://travis-ci.com/nedbat/coveragepy/jobs/189126179) might be unrelated?!

@nedbat
Copy link
Member

I tried restarting the pypy2 failure:https://travis-ci.com/nedbat/coveragepy/jobs/189126179 (oops, same URL...)



HAS_F_TRACE_LINES=sys.version_info>= (3,7)

Copy link
Member

@nedbatnedbatApr 2, 2019
edited
Loading

Choose a reason for hiding this comment

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

I'd rather add a constant to PYBEHAVIOR in env.py, perhaps usinghasattr

blueyed reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Would it require to get a frame object first? (i.e.sys._getframe()) to inspect it?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, though that should be easy. Though come to think of it, why not just do the hasattr where you try to set the attribute?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

My idea was to have as less overhead as possible in the tracing function itself.

@nedbat
Copy link
Member

The bug about pdb: it affects people trying to stop in the debugger when using coverage? I guess that could happen if you are running a test suite, and want to break on failures?

@blueyed
Copy link
ContributorAuthor

The problem/bug with pdb is "just" that coverage.py relies on its trace function being called, which is not the case anymore afterpbd.set_trace, yes.
It affects coverage when a debugger is used during test runs interactively, but is also an issue when you're testing with pdb itself (as withpdb++).

@nedbat
Copy link
Member

@blueyed Are you saying we shouldn't merge this until pdb is changed? Or just that they will want to eventually change?

@blueyed
Copy link
ContributorAuthor

The discussion above is not related to this PR really, which should just improve performance. I was replying to the "bug about pdb" - which is more a conceptual problem due to only having a single trace function only. pdb could restore any previous one (i.e. coverage.py's), instead of setting it toNone in the end.

@blueyed
Copy link
ContributorAuthor

Oh, sorry - I forgot about#791 (comment) /python/cpython#12640.
Yes, it should not get merged yet.

@blueyedblueyed changed the title[RFC] Set f_trace_lines = 0/False on ignored frames[postponed] Set f_trace_lines = 0/False on ignored framesApr 7, 2019
@cfbolz
Copy link
Contributor

I haven't dug super deep into this PR, but maybe it's easier to restart this now that coverage only supports 3.7 upwards?

@nedbat
Copy link
Member

This same change was made in#1381

@nedbatnedbat closed thisJun 3, 2022
@blueyedblueyed deleted the f_trace_lines branchJuly 14, 2022 18:37
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nedbatnedbatnedbat left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@blueyed@codecov-io@nedbat@cfbolz

[8]ページ先頭

©2009-2025 Movatter.jp