<div dir="ltr">Hey Scott,<div><br></div><div>Did this ever get reviewed? The change looks reasonable to me. Did you run lldb tests against it?</div><div><br></div><div>-Todd</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, May 5, 2014 at 1:27 PM, Scott Knight <span dir="ltr"><<a href="mailto:knightsc@gmail.com" target="_blank">knightsc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Based on conversations with Greg and Jim on lldb-dev, when lldb looks a a root object with many sub objects the ClusterManager can get slower and slower. This change switches the internal object list from a vector to the SmallPtrSet data type which speeds things up.<br>
<br>
<a href="http://reviews.llvm.org/D3616" target="_blank">http://reviews.llvm.org/D3616</a><br>
<br>
Files:<br>
include/lldb/Utility/SharedCluster.h<br>
<br>
Index: include/lldb/Utility/SharedCluster.h<br>
===================================================================<br>
--- include/lldb/Utility/SharedCluster.h<br>
+++ include/lldb/Utility/SharedCluster.h<br>
@@ -13,6 +13,8 @@<br>
#include "lldb/Utility/SharingPtr.h"<br>
#include "lldb/Host/Mutex.h"<br>
<br>
+#include "llvm/ADT/SmallPtrSet.h"<br>
+<br>
namespace lldb_private {<br>
<br>
namespace imp<br>
@@ -50,11 +52,12 @@<br>
<br>
~ClusterManager ()<br>
{<br>
- size_t n_items = m_objects.size();<br>
- for (size_t i = 0; i < n_items; i++)<br>
+ for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(), end = m_objects.end(); pos != end; ++pos)<br>
{<br>
- delete m_objects[i];<br>
+ T *object = *pos;<br>
+ delete object;<br>
}<br>
+<br>
// Decrement refcount should have been called on this ClusterManager,<br>
// and it should have locked the mutex, now we will unlock it before<br>
// we destroy it...<br>
@@ -64,8 +67,7 @@<br>
void ManageObject (T *new_object)<br>
{<br>
Mutex::Locker locker (m_mutex);<br>
- if (!ContainsObject(new_object))<br>
- m_objects.push_back (new_object);<br>
+ m_objects.insert (new_object);<br>
}<br>
<br>
typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object)<br>
@@ -73,20 +75,13 @@<br>
{<br>
Mutex::Locker locker (m_mutex);<br>
m_external_ref++;<br>
- assert (ContainsObject(desired_object));<br>
+ assert (m_objects.count(desired_object));<br>
}<br>
return typename lldb_private::SharingPtr<T> (desired_object, new imp::shared_ptr_refcount<ClusterManager> (this));<br>
}<br>
<br>
private:<br>
<br>
- bool ContainsObject (const T *desired_object)<br>
- {<br>
- typename std::vector<T *>::iterator pos, end = m_objects.end();<br>
- pos = std::find(m_objects.begin(), end, desired_object);<br>
- return pos != end;<br>
- }<br>
-<br>
void DecrementRefCount ()<br>
{<br>
m_mutex.Lock();<br>
@@ -99,7 +94,7 @@<br>
<br>
friend class imp::shared_ptr_refcount<ClusterManager>;<br>
<br>
- std::vector<T *> m_objects;<br>
+ llvm::SmallPtrSet<T *, 16> m_objects;<br>
int m_external_ref;<br>
Mutex m_mutex;<br>
};<br>
<br>_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><table cellspacing="0" cellpadding="0" style="color:rgb(136,136,136);font-family:'Times New Roman'"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small">
<td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Todd Fiala |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tfiala@google.com" style="color:rgb(17,85,204)" target="_blank"><span style="background-color:rgb(255,255,204);color:rgb(34,34,34);background-repeat:initial initial">tfiala@google.com</span></a> |</td>
<td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"><font color="#1155cc"> <a>650-943-3180</a></font></td></tr></tbody></table><br></div>
</div>