Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

[TIP] Using psyco to speed up emerge

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
64 posts
  • 1
  • 2
  • 3
  • Next
Author
Message
alec
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Fri Apr 19, 2002 3:02 am
Location: Here
Contact:
Contact alec
Website

[TIP] Using psyco to speed up emerge

  • Quote

Post by alec » Fri Mar 26, 2004 9:43 pm

This tip was on the gentoo-user list a day or so ago; credit goes to "Gregory P. Smith".
I was recently playing with psyco (the x86 jit-like compiler for python)
i figured i'd try out emerge with it to see what effect it had.

emerge is largely IO bound so for a first run to load the buffer cache
the effect isn't likely to be noticed either way.

however on later runs once the buffer cache was primed i found that the
use of psyco in emerge sped up "emerge search xfs" by >20% and sped up
"emerge -pU world" by ~35%. I tested using psyco 1.2 on a celery333.

I recommend adding the following to emerge:

Code: Select all

try:
    import psyco
    psyco.full()
except ImportError:
    pass

Anyone who has installed psyco (its an ebuild) will benefit from a faster
searching and dependancy calculations.

I also watched the memory usage during the runs as well. emerge without
psyco consumed 7.5-10mb of ram. emerge with psync consumed 9-13mb.
Emerge 'feels' faster for me; one or two others posted similar results on the list. No one has posted difficulties.

Edit: Please see the post two or three down about where to put this in '/usr/bin/emerge'. This will only speed up the program 'emerge' itself, not compiles. You'll need to do this again if you ever upgrade portage. Additionally, it isn't quite clear in his message, but you need to 'emerge psyco' to use this.
Last edited by alec on Fri Mar 26, 2004 10:02 pm, edited 1 time in total.
Top
neenee
Veteran
Veteran
User avatar
Posts: 1786
Joined: Sun Jul 20, 2003 12:15 pm

  • Quote

Post by neenee » Fri Mar 26, 2004 9:54 pm

perhaps a silly question - but where would i add that bit?

to the end of /usr/bin/emerge?
Top
ed0n
l33t
l33t
User avatar
Posts: 638
Joined: Wed Apr 23, 2003 12:08 pm
Location: Prishtine/Kosove
Contact:
Contact ed0n
Website

  • Quote

Post by ed0n » Fri Mar 26, 2004 9:57 pm

neenee wrote:perhaps a silly question - but where would i add that bit?

to the end of /usr/bin/emerge?
I wanted to ask that too.
Top
alec
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Fri Apr 19, 2002 3:02 am
Location: Here
Contact:
Contact alec
Website

  • Quote

Post by alec » Fri Mar 26, 2004 9:57 pm

I don't know the first thing about python, but I added it right after the initial import, so my /usr/bin/emerge looks like this (from the top):

Code: Select all

#!/usr/bin/python -O
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/portage/bin/emerge,v 1.264 2004/02/08 21:24:15 nakano Exp $
                                                                                                                               
import os,sys
os.environ["PORTAGE_CALLER"]="emerge"
sys.path = ["/usr/lib/portage/pym"]+sys.path
                                                                                                                               
try:
        import psyco
        psyco.full()
except ImportError:
        pass
                                                                                                                               
import emergehelp,xpak,string,re,commands,time,shutil,traceback,atexit,signal,socket,types
from stat import *
from output import *
Top
neenee
Veteran
Veteran
User avatar
Posts: 1786
Joined: Sun Jul 20, 2003 12:15 pm

  • Quote

Post by neenee » Fri Mar 26, 2004 10:10 pm

thanks for the prompt reply :wink:
Top
cbr
Apprentice
Apprentice
Posts: 285
Joined: Mon Jan 05, 2004 8:18 pm
Location: Tallinn/Rakvere, Estonia

  • Quote

Post by cbr » Sat Mar 27, 2004 12:04 am

OMG 8O
This speeds up searching A LOT!
Thanks for the tip :wink:
Top
discomfitor
l33t
l33t
User avatar
Posts: 927
Joined: Fri Feb 21, 2003 11:51 pm
Location: None

  • Quote

Post by discomfitor » Sat Mar 27, 2004 12:20 am

WOW. That's amazing! It fails horribly. Segfaults everywhere.
There is no substitute for experience.
Imperfection indicates a lack of effort.
Top
alec
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Fri Apr 19, 2002 3:02 am
Location: Here
Contact:
Contact alec
Website

  • Quote

Post by alec » Sat Mar 27, 2004 2:14 am

Well, I suppose YMMV :)

I've been using it for a day on an ~x86 and a x86 system, and have had no problems.
Top
snakattak3
Guru
Guru
User avatar
Posts: 468
Joined: Wed Dec 11, 2002 5:13 am
Location: Seattle

  • Quote

Post by snakattak3 » Sat Mar 27, 2004 4:58 am

WOW. Searching is almost instantaneous! Even "emerge -p depclean" is much faster. It used to take almost a full minute sometimes. That was one thing that always bugged me about portage, slow on searching.
We should have a USE="psyco" flag, that way it can patch portage (/usr/bin/emerge) everytime you upgrade or install it. That wouldn't be too hard would it?
Ban Reality TV!
Adopt an Unanswered Post
Top
LAsk
n00b
n00b
Posts: 32
Joined: Tue Dec 02, 2003 9:22 am
Location: Avesta, Sweden
Contact:
Contact LAsk
Website

  • Quote

Post by LAsk » Sat Mar 27, 2004 10:16 am

It fails for me too :(

These are the errors when I do a emerge world -p

Code: Select all

/usr/lib/portage/pym/portage.py:2952: warning: eval()/execfile() cannot see the locals in functions bound by Psyco; consider using eval() in its two- or three-arguments form
  def match2(self,mydep,mykey,mylist):
Traceback (most recent call last):
  File "/usr/bin/emerge", line 2176, in ?
    if not mydepgraph.xcreate(myaction):
  File "/usr/bin/emerge", line 1042, in xcreate
    if not self.create(myk):
  File "/usr/bin/emerge", line 755, in create
    if not self.select_dep("/",mydep["/"],myparent=mp,myuse=myuse):
  File "/usr/bin/emerge", line 945, in select_dep
    if not self.create(myk,myparent,myuse=binpkguseflags):
  File "/usr/bin/emerge", line 755, in create
    if not self.select_dep("/",mydep["/"],myparent=mp,myuse=myuse):
  File "/usr/bin/emerge", line 877, in select_dep
    myeb=portage.portdb.xmatch("bestmatch-visible",x)
  File "/usr/lib/portage/pym/portage.py", line 4065, in xmatch
    myval=best(self.xmatch("match-visible",None,mydep,mykey))
  File "/usr/lib/portage/pym/portage.py", line 4076, in xmatch
    myval=self.match2(mydep,mykey,self.xmatch("list-visible",None,mydep,mykey))
  File "/usr/lib/portage/pym/portage.py", line 3017, in match2
    if eval("pkgcmp(cp_x[1:],cp_key[1:])"+cmpstr+"0"):
  File "<string>", line 0, in ?
NameError: name 'cp_x' is not defined
Anyone who knows what it is that might be wrong?
Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement.
- Tolkien
Top
AlterEgo
Veteran
Veteran
User avatar
Posts: 1619
Joined: Thu Apr 25, 2002 2:51 pm

  • Quote

Post by AlterEgo » Sat Mar 27, 2004 10:40 am

Tried:
emerge -pu world: 1 min 20 sec.
With psyco: 1 min 18 seconds.

Not that amazing :roll:
Top
ed0n
l33t
l33t
User avatar
Posts: 638
Joined: Wed Apr 23, 2003 12:08 pm
Location: Prishtine/Kosove
Contact:
Contact ed0n
Website

  • Quote

Post by ed0n » Sat Mar 27, 2004 1:19 pm

AlterEgo wrote:Tried:
emerge -pu world: 1 min 20 sec.
With psyco: 1 min 18 seconds.

Not that amazing :roll:
I got that result too.
Top
Vagabond
Apprentice
Apprentice
Posts: 192
Joined: Sun Jan 19, 2003 2:42 pm

  • Quote

Post by Vagabond » Sat Mar 27, 2004 2:25 pm

you guys must have slow computers, I get 10 seconds for vanilla emerge -pu world and 8 seconds with psyco. And my portage tree is even mounted over NFS :P

Vag
Top
øxygen
Apprentice
Apprentice
Posts: 236
Joined: Tue Mar 09, 2004 3:14 pm
Location: Bergheim, Germany
Contact:
Contact øxygen
Website

  • Quote

Post by øxygen » Sat Mar 27, 2004 2:50 pm

or you have a small world file... btw: works
Top
kronon
Apprentice
Apprentice
User avatar
Posts: 212
Joined: Mon Aug 11, 2003 5:46 pm
Location: NL

  • Quote

Post by kronon » Sat Mar 27, 2004 4:19 pm

some notes to get it working.

1).you have to emerge psyco first.
2).python is to damn sensetive

this code will work


try:
import psyco
psyco.full()
except ImportError:
pass

NOTE: only difference is the space before except, this dit the trick for me.
Top
neenee
Veteran
Veteran
User avatar
Posts: 1786
Joined: Sun Jul 20, 2003 12:15 pm

  • Quote

Post by neenee » Sat Mar 27, 2004 10:14 pm

consider posting that bit between code tags.

unless it's meant to have no space before any
of the lines.
Top
LAsk
n00b
n00b
Posts: 32
Joined: Tue Dec 02, 2003 9:22 am
Location: Avesta, Sweden
Contact:
Contact LAsk
Website

  • Quote

Post by LAsk » Sat Mar 27, 2004 10:15 pm

kronon wrote:some notes to get it working.

1).you have to emerge psyco first.
2).python is to damn sensetive

this code will work


try:
import psyco
psyco.full()
except ImportError:
pass

NOTE: only difference is the space before except, this dit the trick for me.
Still the same problem here :(
Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement.
- Tolkien
Top
mastergoon
Apprentice
Apprentice
User avatar
Posts: 161
Joined: Sun Jul 27, 2003 11:49 pm
Location: Portland, OR
Contact:
Contact mastergoon
Website

  • Quote

Post by mastergoon » Sun Mar 28, 2004 12:45 am

make sure you use real tabs to indent in emerge
Top
PovMan
Guru
Guru
User avatar
Posts: 375
Joined: Mon Sep 30, 2002 12:26 pm
Location: Australia

  • Quote

Post by PovMan » Sun Mar 28, 2004 3:14 am

For anyone who's having segfaults, make sure you do an 'emerge psyco' before modifying emerge
It works great for me! Why isn't this part of emerge already? (like as a use flag)
I am SPAM, hear me roar.
Before posting your own topic, try to answer at least one unanswered one.
Top
verbatim
Apprentice
Apprentice
Posts: 223
Joined: Thu Mar 13, 2003 6:16 am

  • Quote

Post by verbatim » Sun Mar 28, 2004 3:42 am

Hey, works for me... getting a measureable speedup.

user time for emerge -epv world without: 33 seconds
with: 22 seconds

Cool. :)
Top
schism39401
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 130
Joined: Thu Mar 13, 2003 11:08 pm

  • Quote

Post by schism39401 » Sun Mar 28, 2004 5:12 am

Searching does seem a little faster...I use esearch usually and it's a lot faster :-)
Top
djkork
n00b
n00b
User avatar
Posts: 45
Joined: Tue May 25, 2004 12:38 am
Location: Madrid

  • Quote

Post by djkork » Tue May 25, 2004 1:40 am

this does not speed up too much....

emerge -puD world

20 sec with psico
18 sec with psico
Top
gbu
n00b
n00b
Posts: 25
Joined: Tue May 18, 2004 4:52 am
Location: Between UCI and UCLA

  • Quote

Post by gbu » Tue May 25, 2004 10:14 pm

Of course you can do the same thing to esearch and eupdatedb.
Top
equilibrium
Apprentice
Apprentice
User avatar
Posts: 213
Joined: Sun Jun 29, 2003 10:31 am
Location: UK
Contact:
Contact equilibrium
Website

  • Quote

Post by equilibrium » Wed May 26, 2004 11:48 am

omg nice :)

searching seems faster :D will see how fast it is to emerge some stuff in future. Am thinking of upgrading KDE 8)
kernel 4.15.17-1-equk | i3wm | github
Top
neenee
Veteran
Veteran
User avatar
Posts: 1786
Joined: Sun Jul 20, 2003 12:15 pm

  • Quote

Post by neenee » Wed May 26, 2004 12:09 pm

emerge -uDpv world,

without psyco:

Code: Select all

real    0m7.071s
user    0m5.472s
sys     0m0.631s
with psyco:

Code: Select all

real    0m4.572s
user    0m3.420s
sys     0m0.648s
ps. i only timed the second and third time, to be sure the difference
in time was not because of the files/process being cached.
Top
Post Reply

64 posts
  • 1
  • 2
  • 3
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic