Keystore 2.0: Reduce sqlite cache to 0.5M
The default sqlite cache size of 2M is excessive for keystore use cases.
Reduce it to avoid memory pressure on low memory devices.
Bug: 186436093
Test: atest CtsKeystoreTestCases, saw heap usage drop ~1M
Change-Id: I52e7d78ee15fe863857866848ede84e0f3e4f216
diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs
index e1185f3..28ff02d 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -1045,6 +1045,12 @@
break;
}
+ // Drop the cache size from default (2M) to 0.5M
+ conn.execute("PRAGMA persistent.cache_size = -500;", params![])
+ .context("Failed to decrease cache size for persistent db")?;
+ conn.execute("PRAGMA perboot.cache_size = -500;", params![])
+ .context("Failed to decrease cache size for perboot db")?;
+
Ok(conn)
}