reduce memory footprint of index by trimming IntLists
Reduced the memory usage of the IntLists in the index by 4.1MB (19.9MB to 15.8MB) for 683,390 files and 4,046,250 values in the IntLists.
This commit is contained in:
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DataStore {
|
||||
private static final Logger EXECUTE_QUERY_LOGGER = LoggerFactory.getLogger("org.lucares.metrics.dataStore.executeQuery");
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DataStore.class);
|
||||
|
||||
private static final String SUBDIR_STORAGE = "storage";
|
||||
private static final String PDB_EXTENSION = ".pdb";
|
||||
@@ -68,6 +69,7 @@ public class DataStore {
|
||||
cacheTagToFileMapping(tags, path);
|
||||
|
||||
});
|
||||
trimIntLists();
|
||||
}
|
||||
|
||||
private void cacheTagToFileMapping(final Tags tags, final Path path) {
|
||||
@@ -85,6 +87,30 @@ public class DataStore {
|
||||
}
|
||||
}
|
||||
|
||||
private void trimIntLists() {
|
||||
final long start = System.nanoTime();
|
||||
int totalBeforeTrim = 0;
|
||||
int totalAfterTrim = 0;
|
||||
int totalValues = 0;
|
||||
for (Map<String, IntList> valueToDocIds : keyToValueToDocId.values()) {
|
||||
|
||||
for (IntList intList : valueToDocIds.values()) {
|
||||
totalBeforeTrim += intList.getCapacity();
|
||||
intList.trim();
|
||||
totalAfterTrim += intList.getCapacity();
|
||||
totalValues += intList.size();
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info(
|
||||
"trimming IntLists of index: values {}, {} kB before, {} kB after, difference {} kB, total size: {} kB, took: {} ms",
|
||||
totalValues,
|
||||
(totalBeforeTrim * 4) / 1024, (totalAfterTrim * 4) / 1024,
|
||||
((totalBeforeTrim - totalAfterTrim) * 4) / 1024,
|
||||
(totalValues * 4) / 1024,
|
||||
(System.nanoTime() - start) / 1_000_000.0);
|
||||
}
|
||||
|
||||
private Path keyCompressionFile(final Path dataDirectory) throws IOException {
|
||||
return dataDirectory.resolve("keys.csv");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user