ssb: Squeeze some blood from the following_perf stone.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
This commit is contained in:
20
src/ssb.db.c
20
src/ssb.db.c
@ -1552,6 +1552,7 @@ typedef struct _following_t following_t;
|
||||
typedef struct _following_t
|
||||
{
|
||||
char id[k_id_base64_len];
|
||||
bool populated;
|
||||
following_t** following;
|
||||
following_t** blocking;
|
||||
int following_count;
|
||||
@ -1559,7 +1560,6 @@ typedef struct _following_t
|
||||
int depth;
|
||||
int ref_count;
|
||||
int block_ref_count;
|
||||
bool populated;
|
||||
} following_t;
|
||||
|
||||
static int _following_compare(const void* a, const void* b)
|
||||
@ -1745,7 +1745,7 @@ static sqlite3_stmt* _make_following_statement(sqlite3* db)
|
||||
"SELECT content ->> '$.contact' AS contact, content ->> '$.following', content ->> '$.blocking' "
|
||||
"FROM messages "
|
||||
"WHERE author = ? AND content ->> '$.type' = 'contact' AND contact IS NOT NULL "
|
||||
"ORDER BY content ->> '$.contact', sequence",
|
||||
"ORDER BY sequence",
|
||||
-1, &statement, NULL) != SQLITE_OK)
|
||||
{
|
||||
tf_printf("prepare failed: %s", sqlite3_errmsg(db));
|
||||
@ -1778,22 +1778,24 @@ tf_ssb_following_t* tf_ssb_db_following_deep(tf_ssb_t* ssb, const char** ids, in
|
||||
}
|
||||
|
||||
tf_ssb_following_t* result = tf_malloc(sizeof(tf_ssb_following_t) * (actual_following_count + 1));
|
||||
memset(result, 0, sizeof(tf_ssb_following_t) * (actual_following_count + 1));
|
||||
|
||||
int write_index = 0;
|
||||
for (int i = 0; i < following_count; i++)
|
||||
{
|
||||
if (following[i]->ref_count > 0 || include_blocks)
|
||||
{
|
||||
result[write_index] = (tf_ssb_following_t)
|
||||
{
|
||||
.following_count = following[i]->following_count,
|
||||
.blocking_count = following[i]->blocking_count,
|
||||
.followed_by_count = following[i]->ref_count,
|
||||
.blocked_by_count = following[i]->block_ref_count,
|
||||
.depth = following[i]->depth,
|
||||
};
|
||||
tf_string_set(result[write_index].id, sizeof(result[write_index].id), following[i]->id);
|
||||
result[write_index].following_count = following[i]->following_count;
|
||||
result[write_index].blocking_count = following[i]->blocking_count;
|
||||
result[write_index].followed_by_count = following[i]->ref_count;
|
||||
result[write_index].blocked_by_count = following[i]->block_ref_count;
|
||||
result[write_index].depth = following[i]->depth;
|
||||
write_index++;
|
||||
}
|
||||
}
|
||||
result[write_index] = (tf_ssb_following_t) { 0 };
|
||||
|
||||
for (int i = 0; i < following_count; i++)
|
||||
{
|
||||
|
@ -1621,7 +1621,7 @@ void tf_ssb_test_following_perf(const tf_test_options_t* options)
|
||||
|
||||
uint64_t start = uv_hrtime();
|
||||
int count = 0;
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
const char** ids = tf_ssb_db_get_all_visible_identities(ssb, 2);
|
||||
while (ids[count])
|
||||
|
Reference in New Issue
Block a user