-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wallet/db.c: Speed up deletion of single peers. #4337
Conversation
b175b6d
to
acafc0f
Compare
Aww crike. Looks like the database system of C-Lightning has gotten a whole lot more complicated since I last poked at it. Sigh. |
What issues are you fighting with? Maybe I can be of assistance? |
Let me quote your excellent research leading to this PR here:
|
It seems I need to somehow generate a bunch of files, most of which are generated by some kind of python script. Unfortunately I had to reinstall OS last December and now the Python on my system is complaining about stuff I don't understand because Python, and I cannot remember how I got it working the last time, have to go dig through it again first. The core diff is this: diff --git a/wallet/db.c b/wallet/db.c
index d1316ede4..efc9bc7b2 100644
--- a/wallet/db.c
+++ b/wallet/db.c
@@ -669,6 +669,11 @@ static struct migration dbmigrations[] = {
/* A reference into our own offers table, if it was made from one */
{SQL("ALTER TABLE payments ADD COLUMN local_offer_id BLOB DEFAULT NULL REFERENCES offers(offer_id);"), NULL},
{SQL("ALTER TABLE channels ADD funding_tx_remote_sigs_received INTEGER DEFAULT 0;"), NULL},
+
+ /* Speeds up deletion of one peer from the database, measurements suggest
+ * it cuts down the time by 80%. */
+ {SQL("CREATE INDEX forwarded_payments_out_htlc_id"
+ " ON forwarded_payments (out_htlc_id);"), NULL},
};
/* Leak tracking. */ This triggers some code that generates the other files but the If you can generate the other files on my behalf that would be great.... |
Yep, we started adding these generated files to cut down on dependencies a while ago, which now causes conflicts and errors if the files aren't being regenerated. I can fixup the PR with a newly generated |
Yes please, thanks. |
Turns out it was just annoyed at the SHA256SUM in the footer not matching the generated po-file. |
Seems like you're not permitting maintainers to push onto your fork, so here's the diff: diff --git a/wallet/db_postgres_sqlgen.c b/wallet/db_postgres_sqlgen.c
index c2df8238d..72ce72a2a 100644
--- a/wallet/db_postgres_sqlgen.c
+++ b/wallet/db_postgres_sqlgen.c
@@ -1780,10 +1780,10 @@ struct db_query db_postgres_queries[] = {
},
};
-#define DB_POSTGRES_QUERY_COUNT 294
+#define DB_POSTGRES_QUERY_COUNT 295
#endif /* HAVE_POSTGRES */
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
-// SHA256STAMP:ca47a99b5c64139f4556f3bf77a6d984cb9ab6b38bcd2851bc551c75c5cc240a
+// SHA256STAMP:910328b3c942486b746f7f5d2a91fad65ae9eb54032a5828705132bfa1b86eaf
diff --git a/wallet/db_sqlite3_sqlgen.c b/wallet/db_sqlite3_sqlgen.c
index 58be3c146..47d563a40 100644
--- a/wallet/db_sqlite3_sqlgen.c
+++ b/wallet/db_sqlite3_sqlgen.c
@@ -1780,10 +1780,10 @@ struct db_query db_sqlite3_queries[] = {
},
};
-#define DB_SQLITE3_QUERY_COUNT 294
+#define DB_SQLITE3_QUERY_COUNT 295
#endif /* HAVE_SQLITE3 */
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
-// SHA256STAMP:ca47a99b5c64139f4556f3bf77a6d984cb9ab6b38bcd2851bc551c75c5cc240a
+// SHA256STAMP:910328b3c942486b746f7f5d2a91fad65ae9eb54032a5828705132bfa1b86eaf Applying this should make the non-pythonic build happy as well :-) |
acafc0f
to
330ecdf
Compare
Thanks! |
wallet/db_sqlite3_sqlgen.c
Outdated
@@ -1774,10 +1780,10 @@ struct db_query db_sqlite3_queries[] = { | |||
}, | |||
}; | |||
|
|||
#define DB_SQLITE3_QUERY_COUNT 294 | |||
#define DB_SQLITE4_QUERY_COUNT 294 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
#define DB_SQLITE4_QUERY_COUNT 294 | |
#define DB_SQLITE3_QUERY_COUNT 294 |
By the way, if you allow maintainers to push I can fix these tiny things up myself, rather than having to take a roundtrip to you 😉 |
ChangeLog-Fixed: Database: Speed up deletion of peer especially when there is a long history with that peer.
330ecdf
to
3ecca0c
Compare
My bad, must've failed on my side. Sorry for the lecture :-) |
ACK 3ecca0c |
Fixes #4325
I petition adding this to the 0.9.3 release candidate, as, it gives a massive speedup on peer deletion, does not change semantics of the database, just pure speedup, and the change is very small.