Revert "wallet: Remove in-memory utxoset filter"

This reverts commit c239a7161b.

The goal of c239a716 was to reduce the memory footprint of our
internal UTXO set tracking, and testing against the sqlite3 backend
showed no performance impact. We have since found that the added
roundtrips to the DB server with postgres was having a considerable
performance impact, and backups would also bloat due to the increased
number of queries.

Undoing this change skips the noop updates that were causing this
regression.

Changelog-Fixed: db: Fixed a performance regression during block sync, resulting in many more queries against the DB than necessary.
This commit is contained in:
Christian Decker
2021-01-07 14:27:54 +01:00
committed by Rusty Russell
parent 3b7d0e7a62
commit 8e908ff652
6 changed files with 205 additions and 129 deletions

View File

@@ -1052,6 +1052,12 @@ struct db_query db_sqlite3_queries[] = {
.placeholders = 1,
.readonly = true,
},
{
.name = "SELECT txid, outnum FROM utxoset WHERE spendheight is NULL",
.query = "SELECT txid, outnum FROM utxoset WHERE spendheight is NULL",
.placeholders = 0,
.readonly = true,
},
{
.name = "SELECT * from outputs WHERE prev_out_tx=? AND prev_out_index=?",
.query = "SELECT * from outputs WHERE prev_out_tx=? AND prev_out_index=?",
@@ -1502,6 +1508,12 @@ struct db_query db_sqlite3_queries[] = {
.placeholders = 1,
.readonly = false,
},
{
.name = "SELECT txid, outnum FROM utxoset WHERE spendheight < ?",
.query = "SELECT txid, outnum FROM utxoset WHERE spendheight < ?",
.placeholders = 1,
.readonly = true,
},
{
.name = "DELETE FROM utxoset WHERE spendheight < ?",
.query = "DELETE FROM utxoset WHERE spendheight < ?",
@@ -1756,10 +1768,10 @@ struct db_query db_sqlite3_queries[] = {
},
};
#define DB_SQLITE3_QUERY_COUNT 291
#define DB_SQLITE3_QUERY_COUNT 293
#endif /* HAVE_SQLITE3 */
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:26bbd985dc45de765f06b8c2644ecd76c098532ff71a33c8f71608890631d726
// SHA256STAMP:62ee429e3f1823a6f5db9358e3bd25b0b48f1dc7cf78bd22b921f601cde15950