Debian Bug report logs - #695811
django_bash_completion slows down bash startup by calling /usr/bin/basename 44 times

version graph

Package: python-django; Maintainer for python-django is Debian Python Modules Team <python-modules-team@lists.alioth.debian.org>; Source for python-django is src:python-django.

Reported by: Anders Kaseorg <andersk@MIT.EDU>

Date: Wed, 12 Dec 2012 22:30:01 UTC

Severity: normal

Tags: patch

Found in version python-django/1.4.2-2

Forwarded to https://code.djangoproject.com/ticket/19806

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Chris Lamb <lamby@debian.org>:
Bug#695811; Package python-django. (Wed, 12 Dec 2012 22:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Anders Kaseorg <andersk@MIT.EDU>:
New Bug report received and forwarded. Copy sent to Chris Lamb <lamby@debian.org>. (Wed, 12 Dec 2012 22:30:04 GMT) Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Anders Kaseorg <andersk@MIT.EDU>
To: submit@bugs.debian.org
Subject: django_bash_completion slows down bash startup by calling /usr/bin/basename 44 times
Date: Wed, 12 Dec 2012 17:26:38 -0500 (EST)
Package: python-django
Version: 1.4.2-2
Tags: patch

/etc/bash_completion.d/django_bash_completion takes about 150ms to source, 
even on a warm cache, primarily because it forks+execs /usr/bin/basename 
44 times.  This significantly slows down interactive logins.

This patch makes it faster by a factor of 5 (and I imagine that a little 
more thought would reduce the time to effectively zero).

--- /etc/bash_completion.d/django_bash_completion
+++ /etc/bash_completion.d/django_bash_completion
@@ -42,10 +42,10 @@
 _python_django_completion()
 {
     if [[ ${COMP_CWORD} -ge 2 ]]; then
-        PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
+        PYTHON_EXE=${COMP_WORDS[0]##*/}
         echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
         if [[ $? == 0 ]]; then
-            PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
+            PYTHON_SCRIPT=${COMP_WORDS[1]##*/}
             echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
             if [[ $? == 0 ]]; then
                 COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
@@ -61,7 +61,7 @@
 if command -v whereis &>/dev/null; then
     python_interpreters=$(whereis python | cut -d " " -f 2-)
     for python in $python_interpreters; do
-        pythons="${pythons} $(basename -- $python)"
+        pythons="${pythons} ${python##*/}"
     done
     pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
 else

Anders



Information forwarded to debian-bugs-dist@lists.debian.org, Chris Lamb <lamby@debian.org>:
Bug#695811; Package python-django. (Fri, 21 Dec 2012 00:36:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Anders Kaseorg <andersk@MIT.EDU>:
Extra info received and forwarded to list. Copy sent to Chris Lamb <lamby@debian.org>. (Fri, 21 Dec 2012 00:36:03 GMT) Full text and rfc822 format available.

Message #10 received at 695811@bugs.debian.org (full text, mbox):

From: Anders Kaseorg <andersk@MIT.EDU>
To: 695811@bugs.debian.org
Subject: Re: django_bash_completion slows down bash startup by calling /usr/bin/basename 44 times
Date: Thu, 20 Dec 2012 19:33:12 -0500 (EST)
Actually, this script has another problem: it actually overrides and 
disables the completions provided for python by the bash-completion 
package at /usr/share/bash-completion/completions/python.  I think that’s 
a really unfriendly thing to do, so I would propose that the second half 
of the script starting at _python_django_completion should be deleted 
entirely.

If desired, the script could then be moved from /etc/bash_completion.d to 
/usr/share/bash-completion/completions/{django-admin.py,manage.py,django-admin} 
with something like Breaks: bash-completion (<< 1:1.90-1).  Then it won’t 
interfere with shell startup at all.

Anders



Information forwarded to debian-bugs-dist@lists.debian.org, Chris Lamb <lamby@debian.org>:
Bug#695811; Package python-django. (Wed, 26 Dec 2012 16:24:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Raphael Hertzog <hertzog@debian.org>:
Extra info received and forwarded to list. Copy sent to Chris Lamb <lamby@debian.org>. (Wed, 26 Dec 2012 16:24:08 GMT) Full text and rfc822 format available.

Message #15 received at 695811@bugs.debian.org (full text, mbox):

From: Raphael Hertzog <hertzog@debian.org>
To: Anders Kaseorg <andersk@MIT.EDU>, 695811@bugs.debian.org
Subject: Re: Bug#695811: django_bash_completion slows down bash startup by calling /usr/bin/basename 44 times
Date: Wed, 26 Dec 2012 17:15:23 +0100
Control: forwarded -1 https://code.djangoproject.com/ticket/19523

On Wed, 12 Dec 2012, Anders Kaseorg wrote:
> /etc/bash_completion.d/django_bash_completion takes about 150ms to source, 
> even on a warm cache, primarily because it forks+execs /usr/bin/basename 
> 44 times.  This significantly slows down interactive logins.

I forwarded your patch upstream and put you in CC of the ticket so that
you get further correspondance with upstream.

For the second issue that you brought up, I would suggest to file
it directly upstream because I'm not sure of what you mean.

Cheers,
-- 
Raphaël Hertzog ◈ Debian Developer

Get the Debian Administrator's Handbook:
→ http://debian-handbook.info/get/



Set Bug forwarded-to-address to 'https://code.djangoproject.com/ticket/19523'. Request was from Raphael Hertzog <hertzog@debian.org> to 695811-submit@bugs.debian.org. (Wed, 26 Dec 2012 16:24:08 GMT) Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, Chris Lamb <lamby@debian.org>:
Bug#695811; Package python-django. (Tue, 12 Feb 2013 04:48:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Anders Kaseorg <andersk@MIT.EDU>:
Extra info received and forwarded to list. Copy sent to Chris Lamb <lamby@debian.org>. (Tue, 12 Feb 2013 04:48:04 GMT) Full text and rfc822 format available.

Message #22 received at 695811@bugs.debian.org (full text, mbox):

From: Anders Kaseorg <andersk@MIT.EDU>
To: Raphaël Hertzog <hertzog@debian.org>
Cc: 695811@bugs.debian.org
Subject: Re: Bug#695811: django_bash_completion slows down bash startup by calling /usr/bin/basename 44 times
Date: Mon, 11 Feb 2013 23:46:05 -0500 (EST)
On Wed, 26 Dec 2012, Raphaël Hertzog wrote:
> For the second issue that you brought up, I would suggest to file
> it directly upstream because I'm not sure of what you mean.

Filed as https://code.djangoproject.com/ticket/19806.

Anders



Changed Bug forwarded-to-address to 'https://code.djangoproject.com/ticket/19806' from 'https://code.djangoproject.com/ticket/19523' Request was from Luke Faraone <lfaraone@debian.org> to control@bugs.debian.org. (Wed, 06 Nov 2013 15:42:15 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 16 19:35:56 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.