From d21d7e4add37899c1563bb9ba09b8ebf4b956336 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 27 Jul 2023 03:04:49 +0000 Subject: [PATCH] Delete more aggressively. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4370 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- src/ssb.rpc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index 2de45502..690d4449 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -1152,12 +1152,13 @@ static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work) { return; } + int64_t start_ns = uv_hrtime(); sqlite3* db = tf_ssb_acquire_db_writer(ssb); sqlite3_stmt* statement; int64_t now = (int64_t)time(NULL) * 1000ULL; int64_t timestamp = now - age * 1000ULL; const int k_limit = 256; - bool deleted = false; + int deleted = 0; if (sqlite3_prepare(db, "DELETE FROM blobs WHERE blobs.id IN (" " SELECT blobs.id FROM blobs " @@ -1177,7 +1178,7 @@ static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work) { tf_printf("_tf_ssb_rpc_delete_blobs_work: %d rows\n", sqlite3_changes(db)); } - deleted = sqlite3_changes(db) != 0; + deleted = sqlite3_changes(db); } } else @@ -1185,10 +1186,11 @@ static void _tf_ssb_rpc_delete_blobs_work(uv_work_t* work) tf_printf("prepare failed: %s\n", sqlite3_errmsg(db)); } tf_ssb_release_db_writer(ssb, db); - + int64_t duration_ms = (uv_hrtime() - start_ns) / 1000000LL; + tf_printf("Deleted %d blobs in %d ms.\n", deleted, (int)duration_ms); if (deleted) { - _tf_ssb_rpc_start_delete_blobs(ssb, 60 * 1000); + _tf_ssb_rpc_start_delete_blobs(ssb, (int)duration_ms); } }