Skip to content

[regression] reading from a urllib2 file descriptor happens byte-at-a-time #46853

Closed

Description

@doko42
BPO 2601
Nosy @mhammond, @akuchling, @doko42, @gpshead, @pitrou
Superseder
  • bpo-2632: performance problem in socket._fileobject.read
  • 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/akuchling'
    closed_at = <Date 2008-04-30.05:56:14.812>
    created_at = <Date 2008-04-08.21:15:29.632>
    labels = ['release-blocker', 'library', 'performance']
    title = '[regression] reading from a urllib2 file descriptor happens byte-at-a-time'
    updated_at = <Date 2008-04-30.05:59:01.255>
    user = 'https://github.com/doko42'

    bugs.python.org fields:

    activity = <Date 2008-04-30.05:59:01.255>
    actor = 'mhammond'
    assignee = 'akuchling'
    closed = True
    closed_date = <Date 2008-04-30.05:56:14.812>
    closer = 'mhammond'
    components = ['Library (Lib)']
    creation = <Date 2008-04-08.21:15:29.632>
    creator = 'doko'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 2601
    keywords = []
    message_count = 10.0
    messages = ['65219', '65488', '65503', '65504', '65517', '65538', '65539', '65540', '65545', '65990']
    nosy_count = 7.0
    nosy_names = ['mhammond', 'akuchling', 'nnorwitz', 'doko', 'gregory.p.smith', 'pitrou', 'schmir']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '2632'
    type = 'performance'
    url = 'https://bugs.python.org/issue2601'
    versions = ['Python 2.6', 'Python 2.5']

    Activity

    1. doko42 commented on Apr 8, 2008

      @doko42
      MemberAuthor

      r61009 on the 2.5 branch

      • Bug bpo-1389051, 1092502: fix excessively large memory allocations when
        calling .read() on a socket object wrapped with makefile().

      causes a regression compared to 2.4.5 and 2.5.2:

      When reading from urllib2 file descriptor, python will read the data a
      byte at a time regardless of how much you ask for. python versions up to
      2.5.2 will read the data in 8K chunks.

      This has enough of a performance impact that it increases download time
      for a large file over a gigabit LAN from 10 seconds to 34 minutes. (!)

      Trivial/obvious example code:

        f =
      urllib2.urlopen("http://launchpadlibrarian.net/13214672/nexuiz-data_2.4.orig.tar.gz")
        while 1:
          chunk = f.read()

      ... and then strace it to see the recv()'s chugging along, one byte at a
      time.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      performancePerformance or resource usage
      on Apr 8, 2008
    3. pitrou commented on Apr 14, 2008

      @pitrou
      Member

      See bpo-2632 for more discussion of what is probably the same issue.

    4. nnorwitz commented on Apr 15, 2008

      nnorwitzmannequin
      Mannequin

      Bumping the priority. I'd like to see this fixed before the next
      release. What version(s) does this problem apply to: 2.5, 2.6, 3.0?

    5. schmir commented on Apr 15, 2008

      schmirmannequin
      Mannequin

      quoting http://bugs.python.org/issue1389051: "Applied to 2.6 trunk in
      rev. 61008 and to 2.5-maint in rev. 61009."

      I don't know about py3k...

    6. akuchling commented on Apr 15, 2008

      @akuchling
      Contributor

      It was applied to 2.5-maint after 2.5.2 was released, BTW, so the change
      isn't in any stable released version, only the 2.6 alphas.

    7. nnorwitz commented on Apr 16, 2008

      nnorwitzmannequin
      Mannequin

      So if the fix was applied to 2.5 branch and 2.6 (3.0 should have
      picked up from 2.6 automatically), can we close this bug?

    8. gpshead commented on Apr 16, 2008

      @gpshead
      Member

      I don't think the fix was acceptable. Now python spins consuming all
      cpu trying to read trivial amounts of data one byte at a time...

      See the discusson at the end of http://bugs.python.org/issue1092502 as
      well as a recent python-dev thread:

      http://mail.python.org/pipermail/python-dev/2008-April/078613.html

    9. gpshead commented on Apr 16, 2008

      @gpshead
      Member

      or else i'm missing something here in the maze of three bugs talking
      about the same issue..

      which revisions fixed the introduced performance issue?

    10. schmir commented on Apr 16, 2008

      schmirmannequin
      Mannequin

      me and amk are talking about the commit that introduced this bug (which
      was meant as a fix for another bug).
      neal seems to think that this commit is the fix to this bug itself.
      and gregory, you are now confused :)

      hope it's clear now.

    11. mhammond commented on Apr 30, 2008

      @mhammond
      Contributor

      For those trying to follow along at home: best I can tell we have 3
      other issues on this: bpo-1092502 and bpo-1389051 are dupes of an initial bug,
      but the fix for those bugs caused regressions reported in this bug and
      in bpo-2632. To try and reduce confusion I'm closing this as a dupe of
      bpo-2632 which has a patch for review.

    12. 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

    Labels

    performancePerformance or resource usagerelease-blockerstdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions