util/disk_cache: fix stored_keys index
It seems there is a bug because: - 20 bytes are compared, but only 1 byte stored_keys step is used - entries can overlap each other by 19 bytes - index_mmap is ~1.3M in size, but only first 64K is used With this fix for Deus Ex: - startup time (from launch to Feral logo): ~38s -> ~16s - disk_cache_has_key() hit rate: ~50% -> ~96% Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:

committed by
Timothy Arceri

parent
663e7c25f5
commit
bd93cea691
@@ -1033,7 +1033,7 @@ disk_cache_put_key(struct disk_cache *cache, const cache_key key)
|
|||||||
int i = *key_chunk & CACHE_INDEX_KEY_MASK;
|
int i = *key_chunk & CACHE_INDEX_KEY_MASK;
|
||||||
unsigned char *entry;
|
unsigned char *entry;
|
||||||
|
|
||||||
entry = &cache->stored_keys[i + CACHE_KEY_SIZE];
|
entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
|
||||||
|
|
||||||
memcpy(entry, key, CACHE_KEY_SIZE);
|
memcpy(entry, key, CACHE_KEY_SIZE);
|
||||||
}
|
}
|
||||||
@@ -1052,7 +1052,7 @@ disk_cache_has_key(struct disk_cache *cache, const cache_key key)
|
|||||||
int i = *key_chunk & CACHE_INDEX_KEY_MASK;
|
int i = *key_chunk & CACHE_INDEX_KEY_MASK;
|
||||||
unsigned char *entry;
|
unsigned char *entry;
|
||||||
|
|
||||||
entry = &cache->stored_keys[i + CACHE_KEY_SIZE];
|
entry = &cache->stored_keys[i * CACHE_KEY_SIZE];
|
||||||
|
|
||||||
return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
|
return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user