Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40261

Re: Speeding up Python's exit

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.04; 'subject:Python': 0.05; '(except': 0.05; 'python': 0.09; '[1,': 0.09; 'dict': 0.09; 'handlers': 0.09; 'linux.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'snippet': 0.09; 'terminates': 0.09; 'assume': 0.11; '2.7': 0.13; '3],': 0.16; ';-)).': 0.16; '[2,': 0.16; 'atexit': 0.16; 'buggy': 0.16; 'called,': 0.16; 'entries,': 0.16; 'from:addr:pitrou.net': 0.16; 'from:addr:solipsis': 0.16; 'from:name:antoine pitrou': 0.16; 'message-id:@post.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reproduce': 0.16; 'slow,': 0.16; 'still,': 0.16; 'terribly': 0.16; 'basically': 0.17; 'memory': 0.18; 'load': 0.19; 'header:User-Agent:1': 0.26; 'guess': 0.27; 'header:X-Complaints-To:1': 0.28; 'this?': 0.28; 'buffers': 0.29; "d'aprano": 0.29; 'giant': 0.29; 'steven': 0.29; 'writes:': 0.29; 'function': 0.30; 'asking': 0.32; 'system,': 0.32; 'file': 0.32; 'minutes,': 0.33; 'problem': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'list': 0.35; 'doing': 0.35; 'there': 0.35; 'received:org': 0.36; 'explain': 0.36; 'but': 0.36; 'be.': 0.36; 'charset:us-ascii': 0.36; 'operating': 0.36; 'resources': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'containing': 0.61; 'first': 0.61; 'dead': 0.62; 'maximum': 0.63; 'consequences': 0.71; 'million': 0.72; 'antoine.': 0.84; 'received:88.163': 0.84; 'twelve': 0.84; 'transactions': 0.91; 'average': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Antoine Pitrou <solipsis@pitrou.net>
Subject Re: Speeding up Python's exit
Date Fri, 1 Mar 2013 14:59:29 +0000 (UTC)
References <512f8aa9$0$30001$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host sea.gmane.org
User-Agent Loom/3.14 (http://gmane.org/)
X-Loom-IP 88.163.232.20 (Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2734.1362149984.2939.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362149984 news.xs4all.nl 6982 [2001:888:2000:d::a6]:37840
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40261

Show key headers only | View raw


Steven D'Aprano <steve+comp.lang.python <at> pearwood.info> writes:
> 
> I just quit an interactive session using Python 2.7 on Linux. It took in 
> excess of twelve minutes to exit, with the load average going well past 9 
> for much of that time.
> 
> I think the reason it took so long was that Python was garbage-collecting 
> a giant dict with 10 million entries, each one containing a list of the 
> form [1, [2, 3], 4]. But still, that's terribly slow -- ironically, it 
> took longer to dispose of the dict (12+ minutes) than it took to create 
> it in the first place (approx 3 minutes, with a maximum load of 4). 
> 
> Can anyone explain why this was so painfully slow, and what (if anything) 
> I can do to avoid it in the future?

You are basically asking people to guess where your performance problem
comes from, without even providing a snippet so that people can reproduce ;)

> I know there is a function os._exit which effectively kills the Python 
> interpreter dead immediately, without doing any cleanup. What are the 
> consequences of doing this? I assume that the memory used by the Python 
> process will be reclaimed by the operating system, but other resources 
> such as opened files may not be.

The OS always disposes of per-process resources when the process terminates
(except if the OS is buggy ;-)). However, file buffers will not be flushed,
atexit handlers and other destructors will not be called, database
transactions will be abandoned (rolled back), etc.

Regards

Antoine.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Speeding up Python's exit Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-28 16:49 +0000
  Re: Speeding up Python's exit Neil Cerutti <neilc@norwich.edu> - 2013-02-28 17:02 +0000
  Re: Speeding up Python's exit Chris Angelico <rosuav@gmail.com> - 2013-03-01 04:06 +1100
  Re: Speeding up Python's exit Chris Angelico <rosuav@gmail.com> - 2013-03-01 04:33 +1100
  Re: Speeding up Python's exit Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-02-28 12:33 -0500
  Re: Speeding up Python's exit Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-02-28 12:31 -0500
  Re: Speeding up Python's exit Grant Edwards <invalid@invalid.invalid> - 2013-03-01 01:17 +0000
    Re: Speeding up Python's exit Antoine Pitrou <solipsis@pitrou.net> - 2013-03-01 19:10 +0000
    Re: Speeding up Python's exit Dave Angel <davea@davea.name> - 2013-03-01 14:17 -0500
    Re: Speeding up Python's exit Antoine Pitrou <solipsis@pitrou.net> - 2013-03-01 22:51 +0000
      Re: Speeding up Python's exit Ross Ridge <rridge@csclub.uwaterloo.ca> - 2013-03-03 18:27 -0500
    Re: Speeding up Python's exit Jason Swails <jason.swails@gmail.com> - 2013-03-01 21:51 -0500
  Re: Speeding up Python's exit Antoine Pitrou <solipsis@pitrou.net> - 2013-03-01 14:59 +0000

csiph-web