Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Hey gentoo hat sich gespaltet!
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
haceye
Apprentice
Apprentice


Joined: 22 May 2003
Posts: 187
Location: Stuttgart, Germany

PostPosted: Tue Jul 08, 2003 9:05 pm    Post subject: Reply with quote

Hi,
Pietschy wrote:
Ich denke aber das es im Portage einiges an geschwindigkeit zu verbessern gibt, zB das Script 5 Posts oben drüber. Hey man ich liebe es. :)


Danke für das Lob. Ich werde das Script noch ein wenig weiterentwickeln:
* "emerge -s" - kompatibilität
* Suche auch in Description (wie emerge -S)
* Index schneller erstellen?
* 2 Bugs entfernen ;-)

werde es dann irgendwann hier posten.

David
_________________
faster 'emerge -s'? emerge esearch
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9507
Location: beyond the rim

PostPosted: Wed Jul 09, 2003 2:24 am    Post subject: Reply with quote

Ok, wie der Zufall so will hab ich gestern auch grade an einem Suchskript gebastelt. Die Ausgabe ist zwar primitiv (enthält u.a. keine Versionsnummern, da nur die letzte Version indiziert wird), versteht keine eclasses, das Updaten der Indexdatei dauert zu lange und es könnte noch Probleme mit bestimmten Zeichen in DESCRIPTION geben, die dann meine grep Expressions verwirren, dafür ist es extrem schnell (die meiste Zeit geht für die Ausgabe drauf :lol:), reiner Bash Code, fehlertolerant (ich benutz z.B. RSYNC_EXCLUDE), per Patch integriert in emerge und IMO benutzerfreundlich.

Der integriert die --fastsearch Option in emerge um das Skript zu benutzen und das feastsearch Feature in make.conf um den Index bei jedem emerge sync upzudaten (nicht zu empfehlen wenn man emerge sync immer manuell macht). Um den Patch zu benutzen muss das Skript als /usr/lib/portage/bin/fastsearch abgespeichert sein (oder man ändert den Patch um), die Option taucht aber nicht bei emerge --help auf, dafür müsste man noch emergehelp.py ändern.

Skript und Patch gibts unter http://gentoo.devel-net.org/download/, ich poste die auch mal hier (s.u.), der Patch könnte aber bei copy+paste Probleme mit den Tabs machen.

Was die Performanceprobleme von portage angeht, ein grosses Problem ist die Startzeit. Ich hab mal Messungen angestellt mit meinem Skript in emerge und der normalen Suche von portage, der Unterschied ist ca. 2 Sekunden. allerdings macht es ca. 5 Sekunden Unterschied zwischen meinem Skript standalone und in emerge integriert (alle Messungen auf meinem P2 233 Server). Bei einer Suche in DESCRIPTION macht sich das Fehlen eines Indexes stärker bemerkbar, da braucht portage 1-2 Minuten, mein Skript ca. 1 Sekunde. Diese Probleme sind bekannt und carpaski (der portage Maintainer) arbeitet auch dadran, der Metadaten Cache wird z.B. bald in einer DB abgelegt (nix SQL, Berkley DB oder so). Es gibt IIRC auf http://breakmygentoo.net ein Projekt um PostgreSQL als portage backend zu benutzen, könnte interessant sein das mal mit dem aktuellen Portage zu vergleichen (Performance mässig).

Langfristig denke ich wird man nicht um um ein Rewrite von portage herumkommen (ob jetzt in Python oder sonst irgendeiner Sparche), da der
aktuelle Ansatz IMO zu monolitisch ist um in Zukunft wartbar zu sein (das verursacht u.a. auch die langen Startzeiten von emerge). Meine Idee ist ein Kern, der verschiedene Front- und Backends als Module realisiert, so dass der User sich aussuchen kann, ob er eine schnelle SQL Datenbank oder z.B. das jetzige (langsame) System als Backend haben will. Wenn man noch weiter geht könnte man sogar verschiedene Backends für Unterschiedliche Daten benutzen, z.B. Ebuilds im Dateisystem und Metadaten (Name, Description, Maintainer, ...) in einer DB, aber bis dahin muss noch sehr viel Code geschrieben werden.

Ok, hier jetzt das Suchskript:

fastsearch:
Code:
#!/bin/bash
# a lightning fast search script for the portage tree
# (C) 2003 Marius Mauch

source /etc/make.conf         # to get PORTDIR and PORTDIR_OVERLAY

SEARCH_DB=/var/cache/edb/fastsearch_db   # the name of the database file
PROG_NAME=$(basename $0)      # the name of this script for use in help messages



# print a usage message

print_help()
{
   echo "Usage:"
   echo "${PROG_NAME} -h | --help | -u | --update | <mode-option> <pattern> <grep-options>"
   echo -e "\t-h | --help:         print this usage message"
   echo -e "\t-u | --update:       (re-)create the search database"
   echo "mode-option is one of:"
   echo -e "\t-d | --description:  search in descriptions"
   echo -e "\t-n | --name:         search in package names"
   echo -e "\t-l | --long-desc:    search in long descriptions"
   echo -e "\t-a | --all:       search in all fields"
   echo 'pattern is a grep regular expression to search for (^ and $ might not work as expected)'
   echo "grep-option is one or more options for grep to manipulate the search"
}

# imports the names and descriptions of all packages in the given directory
# into the database.
#
# $1: directory to import

import_category()
{
   if [ -d "${1}" ]; then
      echo "    reading category ${1} ..."
      for P in "${1}"/*; do
         EBUILD=$(ls -v ${P}/*.ebuild 2> /dev/null | tail -1)
         if [ ${EBUILD} ]; then
            # get only the variable assignment and strip the quotes,
            # might cause problems if the description itself contains quotes
            DESCRIPTION=$(grep DESCRIPTION\= ${EBUILD} | cut -d\= -f 2 | cut -d\" -f 2)
            printf "%-30s%s\n" "${P}::" "${DESCRIPTION}" >> "${SEARCH_DB}.new"
         else
            echo "        No ebuilds for package ${P}, skipping"
         fi
      done
   else
      # some categories might have entries in the categories file
      # but no corresponding directory caused by RSYNC_EXCLUDE or other
      # user modifications
      echo "    No directory for category ${1}, skipping"
   fi
}

# the main script starts here

case "$1" in
   -h | --help)
      print_help
      exit 0
      ;;
   -n | --name)
      MODE=SEARCH
      FIELD=NAME
      ;;
   -d | --description)
      MODE=SEARCH
      FIELD=DESC
      ;;
   -s | --search)
      MODE=SEARCH
      FIELD=ALL
      ;;
   -l | --long)
      # reserved for future versions
      echo "not implemented yet"
      exit 3
      ;;
   -u | --update)
      MODE=UPDATE
      ;;
   -*)
      echo "I don't know this option: $1"
      print_help
      exit 1
      ;;
   *)
      if [ -z "${1}" ]; then
         echo "I need at least one option"
         print_help
         exit 1
      else
         echo "No mode option given, assuming name search"
         MODE=SEARCH
         FIELD=NAME
         set - "${1}" "${1}"   # set $2=$1
      fi
      ;;
esac

if [ "$MODE" == "SEARCH" -a -z "$2" ]; then
   echo "I need a pattern to search for"
   print_help
   exit 1
fi

if [ "${MODE}" == "UPDATE" ]; then
   [ -d $(dirname "${SEARCH_DB}") ] || mkdir -p $(dirname "${SEARCH_DB}")
   echo "Updating database ..."
   rm -f "${SEARCH_DB}.new"
   
   echo "importing packages from ${PORTDIR} ..."
   cd "${PORTDIR}"
   for C in $(grep -v packages profiles/categories); do
      import_category "${C}"
   done
   
   echo "importing packages from ${PORTDIR_OVERLAY} ..."
   cd "${PORTDIR_OVERLAY}"
   for C in *; do
      import_category "${C}"
   done

   mv -f "${SEARCH_DB}.new" "${SEARCH_DB}"
   echo "Finished updating"
   exit
fi

if [ ! -f "${SEARCH_DB}" ]; then
   echo "no search database found, you should create it with \"${PROG_NAME} --update\""
   echo "see \"${PROG_NAME} --help\" for a description of all options"
   exit 2
fi

PATTERN=$2
shift
shift

GREP_OPTIONS="${GREP_OPTIONS} $*"

case "${FIELD}" in
   NAME)
      grep ${GREP_OPTIONS} "${PATTERN/^//}.*::" "${SEARCH_DB}"
      ;;
   DESC)
      grep ${GREP_OPTIONS} "::.*${PATTERN}" "${SEARCH_DB}"
      ;;
   ALL)
      grep ${GREP_OPTIONS} "${PATTERN}" "${SEARCH_DB}"
      ;;
esac

[ "$?" != "0" ] && echo "no matching entries found"


emerge Patch für portage 2.0.48-r1:
Code:
--- emerge.old   2003-06-08 13:20:46.000000000 +0200
+++ emerge.new   2003-07-08 23:24:32.000000000 +0200
@@ -40,6 +40,7 @@
 "--onlydeps",     "--pretend",
 "--quiet",        "--resume",
 "--searchdesc",   "--selective",
+"--fastsearch",
 "--skipfirst",
 "--update",       "--upgradeonly",
 "--usepkg",       "--usepkgonly",
@@ -156,6 +157,9 @@
 # Also allow -S to invoke search action (-sS)
 if ("--searchdesc" in myopts) and (not myaction):
    myaction = "search"
+# --fastsearch also implies search
+if ("--searchdesc" in myopts) and (not myaction):
+   myaction = "search"
 
 # Also allow -K to apply --usepkg/-k
 if ("--usepkgonly" in myopts) and not ("--usepkg" in myopts):
@@ -1683,6 +1687,9 @@
       portage.spawn("chmod -R g+rw "+portage.dbcachedir, free=1)
       sys.stdout.write("\b\b  ...done!\n\n")
       sys.stdout.flush()
+   if "fastsearch" in portage.features:
+      print "\n>>> Building fastsearch database ..."
+      portage.spawn("/usr/lib/portage/bin/fastsearch -u", free=1)
 
    portage.portageexit()
    reload(portage)
@@ -1739,15 +1746,22 @@
    if not myfiles:
       print "emerge: no search terms provided."
    else:
-      
-      searchinstance = search()
-      for mysearch in myfiles:
-         try:
-            searchinstance.execute(mysearch)
-         except re.error, comment:
-            print "\n!!! Regular expression error in \"%s\": %s" % ( mysearch, comment )
-            sys.exit(1)
-         searchinstance.output()
+      if "--fastsearch" in myopts or "fastsearch" in portage.features:
+         for mysearch in myfiles:
+            if "--searchdesc" in myopts:
+               mymode = "-d "
+            else:
+               mymode = "-n "
+            portage.spawn("/usr/lib/portage/bin/fastsearch " + mymode + mysearch + " -i")
+      else:
+         searchinstance = search()
+         for mysearch in myfiles:
+            try:
+               searchinstance.execute(mysearch)
+            except re.error, comment:
+               print "\n!!! Regular expression error in \"%s\": %s" % ( mysearch, comment )
+               sys.exit(1)
+            searchinstance.output()
 elif "inject"==myaction:
    if not myfiles:
       print "emerge: please specify at least one cat/pkg-ver to inject."


So, auch das längste Posting muss mal zu Ende sein.
Back to top
View user's profile Send private message
aias
n00b
n00b


Joined: 02 Apr 2003
Posts: 41

PostPosted: Thu Jul 10, 2003 7:47 am    Post subject: Reply with quote

kennt einer das programm kdeportage?

funktioniert das vom ansatz her genauso wie die obigen suchscripte?
Back to top
View user's profile Send private message
dertobi123
Retired Dev
Retired Dev


Joined: 19 Nov 2002
Posts: 2679
Location: Oberhausen, Germany

PostPosted: Thu Jul 10, 2003 8:30 am    Post subject: Reply with quote

Nö, ist "nur" nen grafischer Aufsatz für's Portage, aber wer braucht sowas schon ....

Gruß Tobias
Back to top
View user's profile Send private message
CHerzog
Tux's lil' helper
Tux's lil' helper


Joined: 13 Jul 2002
Posts: 108
Location: Germany

PostPosted: Thu Jul 10, 2003 9:02 am    Post subject: Reply with quote

dertobi123 wrote:
Nö, ist "nur" nen grafischer Aufsatz für's Portage, aber wer braucht sowas schon ....


Ich nutze das um einfach mal den Portagetree zu durchstöbern.

Vorteile:
KDEPortage ist nett, da es den Baum anzeigt und mir sofort alle wichtigen Informationen zum Paket anzeigt.
Ein Klick und ich kann mir gleich die Homepage ansehen.
Ich sehe die Histori, das Changelog, etc - wie gesagt: Alles auf einen Blick.

Um Programme zu installieren nutze ich dann aber wieder die Shell. Ist mir einfach sicherer.

Christian
Back to top
View user's profile Send private message
dertobi123
Retired Dev
Retired Dev


Joined: 19 Nov 2002
Posts: 2679
Location: Oberhausen, Germany

PostPosted: Thu Jul 10, 2003 9:42 am    Post subject: Reply with quote

Quote:
Um Programme zu installieren nutze ich dann aber wieder die Shell. Ist mir einfach sicherer.


Genau das ist das Problem; zumindest bei meinen bisherigen Versuchen gewesen (Sind schon ne Weile her) ... Das Ding läuft einfach nicht stabil.

Gruß Tobias
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum