Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > strace of python shows nonsense

Reply
Thread Tools

strace of python shows nonsense

 
 
Joep van Delft
Guest
Posts: n/a
 
      01-14-2013
Hi there,


I am puzzled at how I borked my installation. Python loads slow on my
machine, and I decided to use strace and /usr/bin/time to see what is
actually happening.

# sync && echo 3 > /proc/sys/vm/drop_caches
$ /usr/bin/time python2 -c ""
0.19user 0.04system 0:01.22elapsed 19%CPU (0avgtext+0avgdata
4200maxresident)k
7312inputs+0outputs (4major+1145minor)pagefaults 0swaps

And when all is in memory:
$ /usr/bin/time python2 -c ""
0.19user 0.01system 0:00.21elapsed 98%CPU
(0avgtext+0avgdata 4216maxresident)k 0inputs+0outputs
(0major+1153minor)pagefaults 0swaps

$ /usr/bin/time python2 -c "import argparse"
0.36user 0.02system 0:00.39elapsed 98%CPU
(0avgtext+0avgdata 5752maxresident)k 0inputs+0outputs
(0major+1699minor)pagefaults 0swaps

..2 and .4 seconds to not even get started when all disk I/O is
cached. So what is happening here?

$ strace -c python2 -c ""
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
93.26 0.001910 8 230 168 open
3.66 0.000075 9 8 mprotect
3.08 0.000063 1 97 fstat64
0.00 0.000000 0 172 read
0.00 0.000000 0 63 close
<...>

$ strace -c python2 -c "import argparse"
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
51.89 0.003732 13 290 read
47.29 0.003401 18 192 155 stat64
0.82 0.000059 0 129 mmap2
0.00 0.000000 0 549 443 open
0.00 0.000000 0 107 close
<...>

What puzzles me, is the amount of errors for open and stat64. There
are references to stuff I don't know (~/GNUStep directory? Stuff
under site-packages that does not exist? Subdirs of site-packages
that are not included in sys.path?) What is python doing there, and
why? And, more importantly, how can this be corrected?

Probably irrelevant, but Python2 version 2.7.3, Archlinux (current as
of previous weekend).


Thanks,

Joep



 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      01-15-2013
On Tue, 15 Jan 2013 00:50:01 +0100, Joep van Delft wrote:

> Hi there,
>
>
> I am puzzled at how I borked my installation. Python loads slow on my
> machine, and I decided to use strace and /usr/bin/time to see what is
> actually happening.


Before dropping down to such a low level, I suggest you start at a
higher, Python level.

Run `python -E` to disable any environment variables and startup file.
Does that help?

Compare sys.path when running with and without the -E switch. Any
important differences? Anything unusual in sys.path, such as directories
that don't exist?

Run `python -v` to print modules as they are loaded. (Warning: there are
a lot of them.) Can you see any obvious delays?


[...]
> What puzzles me, is the amount of errors for open and stat64. There are
> references to stuff I don't know (~/GNUStep directory? Stuff under
> site-packages that does not exist? Subdirs of site-packages that are not
> included in sys.path?) What is python doing there, and why? And, more
> importantly, how can this be corrected?


What's the value of the environment variable PYTHONPATH?

Do you have a PYTHONSTARTUP set? What is in that file?



--
Steven
 
Reply With Quote
 
 
 
 
Dieter Maurer
Guest
Posts: n/a
 
      01-15-2013
Joep van Delft <(E-Mail Removed)> writes:

> ...
> What puzzles me, is the amount of errors for open and stat64.


The high number of errors comes from Python's import logic:
when Python should import a module/package (not yet imported),
it looks into each member on "sys.path" for about 6 different potential
filename spellings corresponding to the module -- until it succeeds
or has tried all members. Most such filesystem lookups will fail -
giving a high number of "stat" errors.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strace of fwrite Guru C++ 0 07-01-2010 09:42 AM
IE shows false and Firefox shows true Gianni Javascript 3 07-10-2009 09:18 PM
httplib hangs in read / strace says recvfrom() Michael Bacarella Python 0 09-13-2007 11:57 PM
Session var in page_load shows old value, buttonclick shows new . Whats wrong gce ASP .Net 0 05-07-2005 06:50 AM
Strace? Michael Sgier C++ 1 09-13-2004 01:48 PM



Advertisments