PATCH/RFC Pool allocations of QStringData objects..

Waldo Bastian kde-optimize@mail.kde.org
Sat, 18 Jan 2003 14:37:51 +0100


--Boundary-00=_viVK+ZmwOC+qomu
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Saturday 18 January 2003 11:31, David Faure wrote:
> On Saturday 18 January 2003 06:20, Maks Orlovich wrote:
> > The vast majority of the used memory seems to be the history, which I
> > guess is OK, considering that it's information we actually do need.
> > However, the protocols reappear an awful lot -- logging the strings
> > getting freed (yeah, that misses non-freed ones, I know), I can do:
> >
> > cat ../log|grep http$ |wc -l
> >    3127
> >
> > cat ../log|grep file$ |wc -l
> >     805
> >
> > cat ../log|grep https$ |wc -l
> >     167
> >
> >
> > i.e. nearly 4000 strings are just copies of "http", "https" and "file"
> > protocol names. I wonder whether there is a way to get rid of that
> > efficiently.. (Some sort of a global protocol name dictionary?)
>
> Using more of KGlobal::staticQString() would get rid of the "checking for a
> particular protocol" ones.
>
> But since KURL stores urls as separate QStrings, a lot of the protocols you
> see above are actually part of the history KURLs.

Does the following patch to kurl help? What is it's impact on performance?

Does the patch to kglobal.cpp make things better?

Cheers,
Waldo
-- 
bastian@kde.org -=|[ SuSE, The Linux Desktop Experts ]|=- bastian@suse.com


--Boundary-00=_viVK+ZmwOC+qomu
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kglobal1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kglobal1.diff"

Index: kglobal.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kglobal.cpp,v
retrieving revision 1.66
diff -u -r1.66 kglobal.cpp
--- kglobal.cpp	26 Jan 2002 12:14:35 -0000	1.66
+++ kglobal.cpp	18 Jan 2003 13:35:17 -0000
@@ -123,7 +123,7 @@
 class KStringDict : public QDict<QString>
 {
 public:
-   KStringDict() : QDict<QString>() { };
+   KStringDict() : QDict<QString>(83) { };
 };
 
 /**

--Boundary-00=_viVK+ZmwOC+qomu
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="kurl1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="kurl1.diff"

Index: kurl.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kurl.cpp,v
retrieving revision 1.229
diff -u -r1.229 kurl.cpp
--- kurl.cpp	13 Jan 2003 15:47:40 -0000	1.229
+++ kurl.cpp	18 Jan 2003 13:35:08 -0000
@@ -428,6 +428,12 @@
     s >> a.m_strProtocol >> a.m_strUser >> a.m_strPass >> a.m_strHost
       >> a.m_strPath >> a.m_strPath_encoded >> QueryFromWire >> a.m_strRef_encoded
       >> malf >> a.m_iPort;
+
+    if (a.m_strProtocol == fileProt)
+       a.m_strProtocol = fileProt;
+    else
+       a.m_strProtocol = KGlobal::staticQString(a.m_strProtocol);
+
     a.m_bIsMalformed = (malf != 0);
 
     if ( QueryFromWire.isEmpty() )
@@ -816,6 +822,10 @@
         m_strHost = QString::null;
       }
     }
+  }
+  else
+  {
+    m_strProtocol = KGlobal::staticQString(m_strProtocol);
   }
   return;
 

--Boundary-00=_viVK+ZmwOC+qomu--