Skip to content

Commit

Permalink
db: remove assertion on validity of node_ids read from db.
Browse files Browse the repository at this point in the history
We've never hit this, we do check them on insert, and it's slowing
down some operations unnecessarily.

$ time lightning-cli -R --network=regtest --lightning-dir /tmp/ltests-k8jhvtty/test_pay_stress_1/lightning-1/ listpays > /dev/null

Before:
	real	0m1.781s
	user	0m0.127s
	sys	0m0.013s

After:
	real	0m1.545s
	user	0m0.124s
	sys	0m0.024s

Also, the raw listsendpays drops from 0.983s to 0.676s.

(With -O3 -flto, listsendpays is 0.416s, listpays 0.971s).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Aug 21, 2020
1 parent 2888486 commit f762f7e
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions wallet/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,6 @@ void db_column_node_id(struct db_stmt *stmt, int col, struct node_id *dest)
{
assert(db_column_bytes(stmt, col) == sizeof(dest->k));
memcpy(dest->k, db_column_blob(stmt, col), sizeof(dest->k));
assert(node_id_valid(dest));
}

struct node_id *db_column_node_id_arr(const tal_t *ctx, struct db_stmt *stmt,
Expand All @@ -1510,11 +1509,8 @@ struct node_id *db_column_node_id_arr(const tal_t *ctx, struct db_stmt *stmt,
assert(n * sizeof(ret->k) == (size_t)db_column_bytes(stmt, col));
ret = tal_arr(ctx, struct node_id, n);

for (size_t i = 0; i < n; i++) {
for (size_t i = 0; i < n; i++)
memcpy(ret[i].k, arr + i * sizeof(ret[i].k), sizeof(ret[i].k));
if (!node_id_valid(&ret[i]))
return tal_free(ret);
}

return ret;
}
Expand Down

0 comments on commit f762f7e

Please sign in to comment.