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

Allow to build Python without freelists #89685

Closed
tiran opened this issue Oct 19, 2021 · 7 comments
Closed

Allow to build Python without freelists #89685

tiran opened this issue Oct 19, 2021 · 7 comments
Assignees
Labels
3.11 only security fixes topic-C-API type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented Oct 19, 2021

BPO 45522
Nosy @vstinner, @tiran, @markshannon, @miss-islington
PRs
  • bpo-45522: Allow to disable freelists on build time #29056
  • bpo-45522: Allow to disable freelists on build time #29086
  • 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/tiran'
    closed_at = None
    created_at = <Date 2021-10-19.11:06:04.660>
    labels = ['expert-C-API', 'type-feature', '3.11']
    title = 'Allow to build Python without freelists'
    updated_at = <Date 2022-01-17.13:14:15.976>
    user = 'https://github.com/tiran'

    bugs.python.org fields:

    activity = <Date 2022-01-17.13:14:15.976>
    actor = 'vstinner'
    assignee = 'christian.heimes'
    closed = False
    closed_date = None
    closer = None
    components = ['C API']
    creation = <Date 2021-10-19.11:06:04.660>
    creator = 'christian.heimes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45522
    keywords = ['patch']
    message_count = 6.0
    messages = ['404289', '404599', '405207', '405293', '410614', '410778']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'christian.heimes', 'Mark.Shannon', 'miss-islington']
    pr_nums = ['29056', '29086']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue45522'
    versions = ['Python 3.11']

    @tiran
    Copy link
    Member Author

    tiran commented Oct 19, 2021

    Freelists are an optimization trick to avoid allocation and deallocation of commonly used structures. Currently Python has freelists for frame, tuple, float, list, dict, async generators, and context objects. Small ints are also cached.

    For experimentation with alternative memory allocators such as mimalloc, I would like to introduce a way to disable freelists. Tuples's _Py_tuple_state struct has a conditional check on #if PyTuple_MAXSAVESIZE > 0. I propose to add same logic to all other structs.

    @tiran tiran added the 3.11 only security fixes label Oct 19, 2021
    @tiran tiran self-assigned this Oct 19, 2021
    @tiran tiran added topic-C-API type-feature A feature request or enhancement 3.11 only security fixes labels Oct 19, 2021
    @tiran tiran self-assigned this Oct 19, 2021
    @tiran tiran added topic-C-API type-feature A feature request or enhancement labels Oct 19, 2021
    @miss-islington
    Copy link
    Contributor

    New changeset 9942f42 by Christian Heimes in branch 'main':
    bpo-45522: Allow to disable freelists on build time (GH-29056)
    9942f42

    @tiran tiran closed this as completed Oct 21, 2021
    @tiran tiran closed this as completed Oct 21, 2021
    @markshannon
    Copy link
    Member

    I think we should revert this. It just makes working with freelists more cumbersome. Having more configure options just makes it more likely that we will fail to test some configuration.

    If you want to disable freelists in your experiments, feel free to do so, but it doesn't need to be in main, IMO.

    @tiran
    Copy link
    Member Author

    tiran commented Oct 29, 2021

    Which part of the patch is causing you extra work? Would you be fine if I only remove the configure option and leave the fixes for zero-length freelists (#define PyList_MAXFREELIST 0) in?

    @vstinner
    Copy link
    Member

    Freelists for object structs can now be disabled. A new configure option --without-freelists can be used to disable all freelists except empty tuple singleton. (Contributed by Christian Heimes in bpo-45522)

    Can you please document the new configuration option in https://docs.python.org/dev/using/configure.html ?

    When you write :option:`--without-freelists` in what's new in Python 3.11 to get a link ;-)

    @vstinner
    Copy link
    Member

    I reopen the issue to not forget to complete the doc.

    @vstinner vstinner reopened this Jan 17, 2022
    @vstinner vstinner reopened this Jan 17, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @erlend-aasland
    Copy link
    Contributor

    I reopen the issue to not forget to complete the doc.

    I checked the docs, and this option is now documented; marking the issue as resolved.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes topic-C-API type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants