[systemd-devel] [PATCH 07/26] journal: make JournalFile::chain_cache a LinkedHashmap
Michal Schmidt
mschmidt at redhat.com
Thu Oct 16 00:50:45 PDT 2014
The order of entries may matter here. Oldest entries are evicted first
when the cache is full.
(Though I don't see anything to rejuvenate entries on cache hits.)
---
src/journal/journal-file.c | 16 ++++++++--------
src/journal/journal-file.h | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 038b437..e99483d 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -136,7 +136,7 @@ void journal_file_close(JournalFile *f) {
if (f->mmap)
mmap_cache_unref(f->mmap);
- hashmap_free_free(f->chain_cache);
+ linked_hashmap_free_free(f->chain_cache);
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
free(f->compress_buffer);
@@ -1366,7 +1366,7 @@ typedef struct ChainCacheItem {
} ChainCacheItem;
static void chain_cache_put(
- Hashmap *h,
+ LinkedHashmap *h,
ChainCacheItem *ci,
uint64_t first,
uint64_t array,
@@ -1380,8 +1380,8 @@ static void chain_cache_put(
if (array == first)
return;
- if (hashmap_size(h) >= CHAIN_CACHE_MAX)
- ci = hashmap_steal_first(h);
+ if (linked_hashmap_size(h) >= CHAIN_CACHE_MAX)
+ ci = linked_hashmap_steal_first(h);
else {
ci = new(ChainCacheItem, 1);
if (!ci)
@@ -1390,7 +1390,7 @@ static void chain_cache_put(
ci->first = first;
- if (hashmap_put(h, &ci->first, ci) < 0) {
+ if (linked_hashmap_put(h, &ci->first, ci) < 0) {
free(ci);
return;
}
@@ -1419,7 +1419,7 @@ static int generic_array_get(
a = first;
/* Try the chain cache first */
- ci = hashmap_get(f->chain_cache, &first);
+ ci = linked_hashmap_get(f->chain_cache, &first);
if (ci && i > ci->total) {
a = ci->array;
i -= ci->total;
@@ -1522,7 +1522,7 @@ static int generic_array_bisect(
/* Start with the first array in the chain */
a = first;
- ci = hashmap_get(f->chain_cache, &first);
+ ci = linked_hashmap_get(f->chain_cache, &first);
if (ci && n > ci->total) {
/* Ah, we have iterated this bisection array chain
* previously! Let's see if we can skip ahead in the
@@ -2498,7 +2498,7 @@ int journal_file_open(
goto fail;
}
- f->chain_cache = hashmap_new(&uint64_hash_ops);
+ f->chain_cache = linked_hashmap_new(&uint64_hash_ops);
if (!f->chain_cache) {
r = -ENOMEM;
goto fail;
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index fa5b943..a9300e5 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -76,7 +76,7 @@ typedef struct JournalFile {
JournalMetrics metrics;
MMapCache *mmap;
- Hashmap *chain_cache;
+ LinkedHashmap *chain_cache;
#if defined(HAVE_XZ) || defined(HAVE_LZ4)
void *compress_buffer;
--
2.1.0
More information about the systemd-devel
mailing list