Skip to content

Commit

Permalink
repo_write: add a small cache for putinowndirpool()
Browse files Browse the repository at this point in the history
This helps a lot with diskusage data or filelists.
  • Loading branch information
mlschroe committed Nov 8, 2023
1 parent 48c9853 commit 23cbed3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/repo_write.c
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 23cbed3

Please sign in to comment.