speedup error handling. Do not log ResolveInfo anymore. Set limit of 20
authorStefan Schubert <schubi@suse.de>
Thu, 2 Aug 2007 08:15:55 +0000 (08:15 +0000)
committerStefan Schubert <schubi@suse.de>
Thu, 2 Aug 2007 08:15:55 +0000 (08:15 +0000)
problems.

zypp/solver/detail/Resolver.cc
zypp/solver/detail/ResolverContext.cc
zypp/solver/detail/ResolverContext.h
zypp/solver/detail/Resolver_problems.cc

index 348a7d0..8a2964d 100644 (file)
@@ -1299,7 +1299,7 @@ Resolver::resolvePool( bool tryAllPossibilities )
            MIL << "-----------------------------------------------------------------" << endl;
            MIL << counter++ << ". failed queue:" << endl;
            ResolverQueue_Ptr invalid = *iter;    
-           invalid->context()->spewInfo ();
+//         invalid->context()->spewInfo (); No additional information needed here
            MIL << *invalid->context() << endl;
            MIL << "-----------------------------------------------------------------" << endl;         
        }
index 2cae959..8746bd8 100644 (file)
@@ -1355,7 +1355,7 @@ mark_important_info (const ResolverInfoList & il)
 
 void
 ResolverContext::foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn, void *data,
-                             const bool merge) const
+                             const bool merge, const bool findImportant) const
 {
     ResolverInfoList info_list;
 
@@ -1372,6 +1372,12 @@ ResolverContext::foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn
                && info->priority() >= priority)
            {
                info_list.push_back( info );
+
+               if (!merge
+                   && !findImportant) {
+                   // invoke our callback in order to avoid an additional run over the complete list
+                   fn( info, data );               
+               }
            }
        }
        context = context->_parent;
@@ -1396,13 +1402,16 @@ ResolverContext::foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn
        }
     }
 
-    mark_important_info( info_list );
+    if (findImportant) mark_important_info( info_list );
 
-    // Walk across the list of info objects and invoke our callback
+    if (merge
+       || findImportant) {    
+       // Walk across the list of info objects and invoke our callback
 
-    for (ResolverInfoList::iterator iter = info_list.begin(); iter != info_list.end(); ++iter) {
-       if (*iter != NULL) {
-           fn( *iter, data );
+       for (ResolverInfoList::iterator iter = info_list.begin(); iter != info_list.end(); ++iter) {
+           if (*iter != NULL) {
+               fn( *iter, data );
+           }
        }
     }
 }
@@ -1479,7 +1488,7 @@ void
 ResolverContext::spewInfo (void) const
 {
     _XDEBUG( "ResolverContext[" << this << "]::spewInfo" );
-    foreachInfo (PoolItem_Ref(), -1, spew_info_cb, NULL);
+    foreachInfo (PoolItem_Ref(), -1, spew_info_cb, NULL, false, false);
 }
 
 //---------------------------------------------------------------------------
index bc6834f..ed6ac9d 100644 (file)
@@ -304,7 +304,7 @@ class ResolverContext : public base::ReferenceCounted, private base::NonCopyable
     void addError (ResolverInfo_Ptr info, bool askUser = false);// error progress info
     
     // iterate over report log
-    void foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn, void *data, const bool merge=true) const;
+    void foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn, void *data, const bool merge=true, const bool findImportant = true) const;
     ResolverInfoList getInfo (void) const;
 
     // Context compare to identify equal branches
index 4a2e149..e457bb6 100644 (file)
@@ -67,7 +67,9 @@ using namespace std;
        
 typedef multimap<PoolItem_Ref, ResolverInfo_Ptr> ProblemMap;   
 typedef multimap<PoolItem_Ref, Capability> ItemCapabilityMap;
-typedef multimap<PoolItem_Ref, PoolItem_Ref> ConflictMap;      
+typedef multimap<PoolItem_Ref, PoolItem_Ref> ConflictMap;
+
+#define MAXPROBLEMS 20
 
 // match template over ItemCapabilityMap
 template <class K, class V>
@@ -220,7 +222,7 @@ struct AllRequires
 
     bool operator()( const CapAndItem & cai )
     {
-       DBG << cai.item << " requires " << cai.cap << endl;
+       _XDEBUG (cai.item << " requires " << cai.cap);
        requirers.push_back( cai.item );
 
        return true;
@@ -865,6 +867,11 @@ Resolver::problems (const bool ignoreValidSolution) const
            ResolverProblem_Ptr problem = new ResolverProblem (what, details);
            problems.push_back (problem);
        }
+
+       if (problems.size() >= MAXPROBLEMS) {
+           MIL << "Max problems reached: " << MAXPROBLEMS << ". Do not regarding the rest." << endl;
+           break;
+       }
     }
     if (problems.empty()) {
        context->spewInfo();