Author: mlandres
Date: Wed Feb 13 14:02:39 2008
New Revision: 8656
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8656&view=rev
Log:
speed up upgrade
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.cc
branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.h
branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.cc?rev=8656&r1=8655&r2=8656&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.cc Wed Feb 13 14:02:39 2008
@@ -72,20 +72,29 @@
// just find installed item with same kind/name as item
-PoolItem
-Helper::findInstalledByNameAndKind (const ResPool & pool, const string & name, const Resolvable::Kind & kind)
+template<class _Iter>
+static PoolItem findInstalledByNameAndKind ( _Iter begin, _Iter end, const string & name, const Resolvable::Kind & kind)
{
LookFor info;
- invokeOnEach( pool.byIdentBegin( kind, name ),
- pool.byIdentEnd( kind, name ),
+ invokeOnEach(begin, end,
resfilter::ByInstalled (), // ByInstalled
functor::functorRef (info) );
_XDEBUG("Helper::findInstalledByNameAndKind (" << name << ", " << kind << ") => " << info.item);
return info.item;
+
}
+PoolItem Helper::findInstalledByNameAndKind (const ResPool & pool, const string & name, const Resolvable::Kind & kind)
+{ return detail::findInstalledByNameAndKind( pool.byIdentBegin( kind, name ), pool.byIdentEnd( kind, name ), name, kind ); }
+
+PoolItem Helper::findInstalledItem (const ResPool & pool, PoolItem item)
+{ return findInstalledByNameAndKind(pool, item->name(), item->kind() ); }
+
+PoolItem Helper::findInstalledItem( const std::vector<PoolItem> & pool, PoolItem item )
+{ return detail::findInstalledByNameAndKind( pool.begin(), pool.end(), item->name(), item->kind() ); }
+
// just find uninstalled item with same kind/name as item
@@ -104,15 +113,6 @@
}
-// just find installed item with same kind/name as item
-// does *NOT* check edition
-
-PoolItem
-Helper::findInstalledItem (const ResPool & pool, PoolItem item)
-{
- return findInstalledByNameAndKind (pool, item->name(), item->kind() );
-}
-
//----------------------------------------------------------------------------
class LookForUpdate : public resfilter::PoolItemFilterFunctor
@@ -156,14 +156,13 @@
// just find best (according to edition) uninstalled item with same kind/name as item
// *DOES* check edition
-PoolItem
-Helper::findUpdateItem (const ResPool & pool, PoolItem item)
+template<class _Iter>
+static PoolItem findUpdateItem( _Iter begin, _Iter end, PoolItem item )
{
LookForUpdate info;
info.installed = item;
- invokeOnEach( pool.byIdentBegin( item ),
- pool.byIdentEnd( item ),
+ invokeOnEach( begin, end,
functor::chain (resfilter::ByUninstalled (), // ByUninstalled
resfilter::byEdition( item->edition() )), // only look at better editions
functor::functorRef (info) );
@@ -172,6 +171,12 @@
return info.uninstalled;
}
+PoolItem Helper::findUpdateItem (const ResPool & pool, PoolItem item)
+{ return detail::findUpdateItem( pool.byIdentBegin( item ), pool.byIdentEnd( item ), item ); }
+
+PoolItem Helper::findUpdateItem (const std::vector<PoolItem> & pool, PoolItem item)
+{ return detail::findUpdateItem( pool.begin(), pool.end(), item ); }
+
//----------------------------------------------------------------------------
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.h?rev=8656&r1=8655&r2=8656&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/Helper.h Wed Feb 13 14:02:39 2008
@@ -63,6 +63,8 @@
// FIXME: should probably take provides/obsoletes into account for
// renamed upgrades
static PoolItem findInstalledItem (const ResPool & pool, PoolItem item);
+ /** \overload Using ident cache entry. */
+ static PoolItem findInstalledItem (const std::vector<PoolItem> & pool, PoolItem item);
// for item, find uninstalled item which has same name and higher edition
static PoolItem findUninstalledItem (const ResPool & pool, PoolItem item);
@@ -71,6 +73,8 @@
static PoolItem findReinstallItem (const ResPool & pool, PoolItem item);
static PoolItem findUpdateItem (const ResPool & pool, PoolItem item);
+ /** \overload Using ident cache entry. */
+ static PoolItem findUpdateItem (const std::vector<PoolItem> & pool, PoolItem item);
// for item, check if this is the 'best' uninstalled (best arch, best version) item
static bool isBestUninstalledItem (const ResPool & pool, PoolItem item);
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc?rev=8656&r1=8655&r2=8656&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc Wed Feb 13 14:02:39 2008
@@ -36,7 +36,8 @@
/-*/
#include "zypp/Capabilities.h"
-#include "zypp/base/Logger.h"
+#include "zypp/base/Easy.h"
+#include "zypp/base/LogTools.h"
#include "zypp/base/String.h"
#include "zypp/base/Gettext.h"
#include "zypp/base/Exception.h"
@@ -69,6 +70,27 @@
using namespace std;
using namespace zypp;
+struct PoolIndex
+{
+ PoolIndex()
+ {
+ ResPool pool( ResPool::instance() );
+ for_( it, pool.begin(), pool.end() )
+ _cache[it->satSolvable().ident()].push_back( *it );
+ }
+
+ std::vector<PoolItem> & get( const PoolItem & pi )
+ { return get( pi.satSolvable().ident() ); }
+
+ std::vector<PoolItem> & get( sat::Solvable slv_r )
+ { return get( slv_r.ident() );}
+
+ std::vector<PoolItem> & get( IdString ident_r )
+ { return _cache[ident_r]; }
+
+ std::map _cache;
+};
+
/** Order on AvialableItemSet.
* \li best Arch
* \li best Edition
@@ -348,6 +370,8 @@
///////////////////////////////////////////////////////////////////
PoolItemOrderSet available; // candidates available for install (no matter if selected for install or not)
+ PoolIndex identIndex;
+
for ( ResPool::const_iterator it = _pool.begin(); it != _pool.end(); ++it ) {
PoolItem item = *it;
PoolItem candidate;
@@ -373,7 +397,7 @@
candidate = cand_it->second; // found candidate already
}
else {
- candidate = Helper::findUpdateItem( _pool, installed ); // find 'best' upgrade candidate
+ candidate = Helper::findUpdateItem( identIndex.get( installed ), installed ); // find 'best' upgrade candidate
}
if (!candidate) {
MIL << "doUpgrade available: SKIP no candidate for " << installed << endl;
@@ -394,7 +418,7 @@
}
candidate = item;
candidate.status().setSeen(true); // mark as seen
- installed = Helper::findInstalledItem( _pool, candidate );
+ installed = Helper::findInstalledItem( identIndex.get( candidate ), candidate );
if (installed) { // check if we already have an installed
if ( installed.status().isLocked() ) {
MIL << "doUpgrade available: SKIP candidate " << candidate << ", locked " << installed << endl;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org