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

Disable [X refs, Y blocks] ouput in debug builds #61525

Closed
ezio-melotti opened this issue Mar 1, 2013 · 11 comments
Closed

Disable [X refs, Y blocks] ouput in debug builds #61525

ezio-melotti opened this issue Mar 1, 2013 · 11 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@ezio-melotti
Copy link
Member

BPO 17323
Nosy @loewis, @gpshead, @pitrou, @ezio-melotti, @briancurtin, @cjerdonek
Files
  • issue17323.diff: Proof of concept against default.
  • issue17323-2.diff
  • issue17323-3.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ezio-melotti'
    closed_at = <Date 2013-03-26.16:16:50.077>
    created_at = <Date 2013-03-01.08:16:08.988>
    labels = ['interpreter-core', 'type-feature']
    title = 'Disable [X refs, Y blocks] ouput in debug builds'
    updated_at = <Date 2013-03-26.16:16:50.076>
    user = 'https://github.com/ezio-melotti'

    bugs.python.org fields:

    activity = <Date 2013-03-26.16:16:50.076>
    actor = 'ezio.melotti'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2013-03-26.16:16:50.077>
    closer = 'ezio.melotti'
    components = ['Interpreter Core']
    creation = <Date 2013-03-01.08:16:08.988>
    creator = 'ezio.melotti'
    dependencies = []
    files = ['29331', '29503', '29562']
    hgrepos = []
    issue_num = 17323
    keywords = ['patch']
    message_count = 11.0
    messages = ['183244', '183253', '183548', '183608', '183650', '183687', '183882', '184005', '184750', '185134', '185252']
    nosy_count = 7.0
    nosy_names = ['loewis', 'gregory.p.smith', 'pitrou', 'ezio.melotti', 'brian.curtin', 'chris.jerdonek', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue17323'
    versions = ['Python 3.4']

    @ezio-melotti
    Copy link
    Member Author

    I suggest to disable the [X refs, Y blocks] ouput in debug builds by default, and provide an option to enable it if/when necessary.
    Most of the time these values are not necessary, and they end up getting in the way while copy/pasting code from the interpreter and/or running tests (we even have a function in test.support to get rid of them).
    They are sometimes useful while investigating refleaks, so there should still be an option to enable it. I'm not sure what would be the best way to do it (a new python flag?).

    @ezio-melotti ezio-melotti added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Mar 1, 2013
    @cjerdonek
    Copy link
    Member

    @briancurtin
    Copy link
    Member

    I don't know exactly what the option would be called, but +1 on the idea. Perhaps something under the interpreter's -X option since it's implementation-specific?

    This output gets in the way a fair bit when debugging interpreter sessions, and Chris brings up a good point about testability.

    @ezio-melotti
    Copy link
    Member Author

    Here's a proof of concept that defines a new _print_total_refs() function and calls it through the PRINT_TOTAL_REFS macro, disables printing the refs by default, and adds a "-X showrefcount" option to reenable it. This can also be achieved at runtime by adding/removing 'showrefcount' from the sys._xoptions dict.

    Things that should be done/decided before the final version:

    1. the function and/or prototype should probably be moved to a better place;
    2. the 'showrefcount' name sounds ok to me, but I'm open to suggestions if you can come up with something better;
    3. the function could do the equivalent of "if sys._xoptions.get('showrefcount', False):" instead of "if 'showrefcount' in sys._xoptions:";
    4. now that this can be enabled/disabled at runtime, we might make it available to non-debug builds too (unless there are other negative side-effects);

    @pitrou
    Copy link
    Member

    pitrou commented Mar 7, 2013

    _Py_GetRefTotal() wouldn't be available in non-debug builds IIRC.

    @ezio-melotti
    Copy link
    Member Author

    Yes -- I was proposing to make it available on non-debug builds too, unless it has a negative impact on the performance or other similar issues.

    @gpshead
    Copy link
    Member

    gpshead commented Mar 10, 2013

    If this is done, it should probably be on by default on all --with-pydebug buildbots. Otherwise I suspect nobody will _ever_ look at its output and we should just remove the feature all together.

    Being off in the main process on the build bots would still make test_subprocess.py happier though as that test's own child processes wouldn't pass the command line flag to enable it so they wouldn't see it in child process stderr.

    @ezio-melotti
    Copy link
    Member Author

    If this is done, it should probably be on by default on all
    --with-pydebug buildbots.

    With "on by default" you mean that the output should be disabled or enabled?

    Otherwise I suspect nobody will _ever_ look at its output and we
    should just remove the feature all together.

    IME the refcount is only useful while trying things in the interactive interpreter manually, e.g. try to repeat the same operation and see if the refcount increases or not. In this case the feature would still be useful, so it should be kept.

    @ezio-melotti
    Copy link
    Member Author

    Attached updated patch with docs and tests.
    I changed the function to do the equivalent of "if sys._xoptions.get('showrefcount', False):" as proposed in msg183608.
    Adding -X showrefcount to non-debug builds could be covered in a separate issue.
    Cleaning up the test suite to avoid checking for the refcounts in stderr can also be done in a separate commit if necessary.

    @ezio-melotti
    Copy link
    Member Author

    Attached a new patch that addresses a couple of minor things pointed out in the reviews.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 26, 2013

    New changeset 367167f93c30 by Ezio Melotti in branch 'default':
    bpo-17323: The "[X refs, Y blocks]" printed by debug builds has been disabled by default. It can be re-enabled with the -X showrefcount option.
    http://hg.python.org/cpython/rev/367167f93c30

    @ezio-melotti ezio-melotti self-assigned this Mar 26, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants