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

Limiting data copy in xmlrpclib #45148

Closed
kilobug mannequin opened this issue Jul 4, 2007 · 13 comments
Closed

Limiting data copy in xmlrpclib #45148

kilobug mannequin opened this issue Jul 4, 2007 · 13 comments
Labels
pending The issue will be closed if no feedback is provided performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@kilobug
Copy link
Mannequin

kilobug mannequin commented Jul 4, 2007

BPO 1747670
Nosy @loewis, @pitrou, @serhiy-storchaka
Files
  • xmlrpclib.patch
  • xmlrpc_less_copy.diff
  • xmlrpc_less_copy-1.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 = None
    closed_at = None
    created_at = <Date 2007-07-04.09:54:37.000>
    labels = ['library', 'performance']
    title = 'Limiting data copy in xmlrpclib'
    updated_at = <Date 2016-01-20.09:57:29.986>
    user = 'https://bugs.python.org/kilobug'

    bugs.python.org fields:

    activity = <Date 2016-01-20.09:57:29.986>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2007-07-04.09:54:37.000>
    creator = 'kilobug'
    dependencies = []
    files = ['8070', '29519', '29579']
    hgrepos = []
    issue_num = 1747670
    keywords = ['patch']
    message_count = 12.0
    messages = ['52808', '110892', '110900', '110920', '184825', '184949', '184950', '184961', '185264', '189963', '190134', '190136']
    nosy_count = 5.0
    nosy_names = ['loewis', 'pitrou', 'kilobug', 'serhiy.storchaka', 'Thomas Fenzl']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'pending'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue1747670'
    versions = ['Python 3.4']

    @kilobug
    Copy link
    Mannequin Author

    kilobug mannequin commented Jul 4, 2007

    Data going through the xmlrpclib are copied many times in Python. This creates problem when submitting blob of data in XML-RPC (I know the protocol is not aimed for that, but sometimes it's useful).

    This little patch try to limit memory usage of xmlrpclib by adding a few optimizations.

    I did the patch on Python 2.4 because it's what our customer is using, but it should work on Python 2.5 or more recent too.

    @kilobug kilobug mannequin added stdlib Python modules in the Lib dir labels Jul 4, 2007
    @devdanzin devdanzin mannequin added performance Performance or resource usage labels Apr 6, 2009
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 20, 2010

    The code in the patch has been removed from py3k. This can only go forward if a unit test is provided. Change assigned to as per maintainers list.

    @BreamoreBoy BreamoreBoy mannequin assigned loewis Jul 20, 2010
    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Jul 20, 2010

    Martin has recently removed his name from py3k/Misc/maintainers.rst.
    Also, he has stated that assigning bugs to him might mean that they
    get less attention (due to the large number of issues that he's involved
    in).

    @loewis loewis mannequin unassigned loewis Jul 20, 2010
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 20, 2010

    @ThomasFenzl
    Copy link
    Mannequin

    ThomasFenzl mannequin commented Mar 21, 2013

    Adapted the patch to python3.3
    It may be useful with large amounts of transfered data avoiding a copy and freeing memory earlier.
    The functionality is tested with the existing unit tests.

    @pitrou
    Copy link
    Member

    pitrou commented Mar 22, 2013

    Well, str.join() already optimizes this case to avoid copies:

    >>> s = "x" * 50
    >>> id(s)
    139712615414000
    >>> id(''.join([s]))
    139712615414000

    @pitrou
    Copy link
    Member

    pitrou commented Mar 22, 2013

    I would close this as out of date, unless you have other suggestions to improve memory consumption.

    @kilobug
    Copy link
    Mannequin Author

    kilobug mannequin commented Mar 22, 2013

    Great that join does the optimisation by itself now, but the last issue of the patch (cleaning the _data array before calling f() so the memory of _data can be collected earlier) still seems meaningful today.

    @ThomasFenzl
    Copy link
    Mannequin

    ThomasFenzl mannequin commented Mar 26, 2013

    I removed the unnecessary check on single-element arrays.
    No strong opinion on usefulness, as I don't use xmlrpc a lot...

    @serhiy-storchaka
    Copy link
    Member

    Do you have any benchmarks?

    @kilobug
    Copy link
    Mannequin Author

    kilobug mannequin commented May 27, 2013

    It's not something that can be easily benched because it depends a lot of the use case. If some conditions are present (big amount of data sent to XML-RPC, the XML-RPC server taking a long time to answer, end either Python giving back the memory to the OS or another thread reusing the garbage collected memory) the gain in memory can be very significant, in most other cases, it won't change anything.

    Do you me to craft a simple example where the difference can be seen ?

    @serhiy-storchaka
    Copy link
    Member

    Yes, it would be nice if you provided an example.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel
    Copy link
    Member

    Apart from this being abandoned for 9 years, the change proposed here is only valid if end() is only called once. Is this guaranteed? I can't find anything about this in the doc.

    I suggest we close the issue.

    @iritkatriel iritkatriel added the pending The issue will be closed if no feedback is provided label Aug 4, 2022
    @iritkatriel iritkatriel closed this as not planned Won't fix, can't repro, duplicate, stale Aug 11, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    pending The issue will be closed if no feedback is provided performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants