Skip to content

Use "Low-fragmentation Heap" memory allocator on Windows #70439

Closed

Description

@vstinner
BPO 26251
Nosy @pfmoore, @vstinner, @tjguk, @zware, @zooba

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 = None
closed_at = <Date 2018-05-29.22:11:35.960>
created_at = <Date 2016-01-31.17:55:40.898>
labels = ['OS-windows', 'performance']
title = 'Use "Low-fragmentation Heap" memory allocator on Windows'
updated_at = <Date 2018-05-29.22:11:35.960>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2018-05-29.22:11:35.960>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2018-05-29.22:11:35.960>
closer = 'vstinner'
components = ['Windows']
creation = <Date 2016-01-31.17:55:40.898>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 26251
keywords = []
message_count = 8.0
messages = ['259293', '259294', '259296', '297106', '297209', '297594', '297610', '318122']
nosy_count = 5.0
nosy_names = ['paul.moore', 'vstinner', 'tim.golden', 'zach.ware', 'steve.dower']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue26251'
versions = ['Python 3.6']

Activity

  1. vstinner commented on Jan 31, 2016

    @vstinner
    MemberAuthor

    Python has a memory allocator optimized for allocations <= 512 bytes: PyObject_Malloc(). It was discussed to replace it by the native "Low-fragmentation Heap" memory allocator on Windows.

    I'm not aware of anyone who tried that. I would nice to try, especially to run benchmarks.

    See also the issue bpo-26249: "Change PyMem_Malloc to use PyObject_Malloc allocator?".

  2. vstinner commented on Jan 31, 2016

    @vstinner
    MemberAuthor
  3. vstinner commented on Jan 31, 2016

    @vstinner
    MemberAuthor

    The issue bpo-19246 "high fragmentation of the memory heap on Windows" was rejected but discussed the Windows Low Fragmented Heap.

  4. vstinner commented on Jun 28, 2017

    @vstinner
    MemberAuthor

    Is there anyway interested to experiment to write such change and run benchmarks with it?

  5. zooba commented on Jun 28, 2017

    @zooba
    Member

    We tried it at one point, but it made very little difference because we don't use the Windows heap for most allocations. IIRC, replacing Python's optimised allocator with the LFH was a slight performance regression, but I'm not sure the benchmarks were reliable enough back then to be trusted. I'm also not sure what optimisations have been performed in Windows 8/10.

    Since the LFH is the default though, it really should just be a case of replacing Py_Malloc with a simple HeapAlloc shim and testing it. The APIs are nearly the same (the result of GetProcessHeap() will be stable for the lifetime of the process, and there's little value in creating specific heaps unless you intend to destroy it rather than free each allocation individually).

  6. vstinner commented on Jul 3, 2017

    @vstinner
    MemberAuthor

    Steve: "We tried it at one point, but it made very little difference (...)"

    Ok. Can I close the issue?

  7. zooba commented on Jul 3, 2017

    @zooba
    Member

    I wouldn't be opposed to seeing it tried again, but I have no strong opinion. I don't think this is a major performance bottleneck right now.

  8. vstinner commented on May 29, 2018

    @vstinner
    MemberAuthor

    I failed to find the bandwidth to work on this issue since 2 years, so I just abandon this idea. However the performance benefit is non obvious.

  9. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions