2 Commits

Author SHA1 Message Date
cbf1273a55 ssb: Squeeze some blood from the following_perf stone.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
2025-06-11 19:12:59 -04:00
8143a23ced format 2025-06-11 18:52:56 -04:00
4 changed files with 14 additions and 13 deletions

View File

@ -11,7 +11,7 @@
** @{
*/
#include "quickjs.h"
typedef struct JSContext JSContext;
/**
** An HTTP server instance.

View File

@ -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++)
{

View File

@ -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])

View File

@ -500,8 +500,7 @@ void tf_util_document_settings(const char* line_prefix)
JSValue tf_util_new_uint8_array(JSContext* context, const uint8_t* data, size_t size)
{
JSValue array_buffer = JS_NewArrayBufferCopy(context, data, size);
JSValue args[] =
{
JSValue args[] = {
array_buffer,
JS_NewInt64(context, 0),
JS_NewInt64(context, size),