]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
repo_write: add a small cache for putinowndirpool()
authorMichael Schroeder <mls@suse.de>
Wed, 8 Nov 2023 12:53:11 +0000 (13:53 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 8 Nov 2023 12:53:11 +0000 (13:53 +0100)
This helps a lot with diskusage data or filelists.

src/repo_write.c

index 73755b45e2b89c6a4dab2b850c2f6b7f0a4e623d..c5e38dec7e05d70a6df7fa0dd5e8ea2270748061 100644 (file)
@@ -300,6 +300,8 @@ struct cbdata {
 
   Id lastdirid;                /* last dir id seen in this repodata */
   Id lastdirid_own;    /* last dir id put in own pool */
+
+  Id diridcache[3 * 256];
 };
 
 #define NEEDID_BLOCK 1023
@@ -578,10 +580,17 @@ putinowndirpool_slow(struct cbdata *cbdata, Repodata *data, Dirpool *dp, Id dir)
 static inline Id
 putinowndirpool(struct cbdata *cbdata, Repodata *data, Id dir)
 {
+  Id *cacheent;
   if (dir && dir == cbdata->lastdirid)
     return cbdata->lastdirid_own;
+  cacheent = cbdata->diridcache + (dir & 255);
+  if (dir && cacheent[0] == dir && cacheent[256] == data->repodataid)
+    return cacheent[512];
   cbdata->lastdirid = dir;
   cbdata->lastdirid_own = putinowndirpool_slow(cbdata, data, &data->dirpool, dir);
+  cacheent[0] = dir;
+  cacheent[256] = data->repodataid;
+  cacheent[512] = cbdata->lastdirid_own;
   return cbdata->lastdirid_own;
 }