forked from cory/tildefriends
core: Remove hitch tracking. Hasn't been an active problem, and the traces are sufficient to diagnose.
This commit is contained in:
60
src/ssb.c
60
src/ssb.c
@ -34,9 +34,6 @@
|
||||
#define CYAN "\e[1;36m"
|
||||
#define RESET "\e[0m"
|
||||
|
||||
#define PRE_CALLBACK(ssb, cb) uint64_t pre_callback_hrtime_ns = _tf_ssb_callback_pre(ssb)
|
||||
#define POST_CALLBACK(ssb, cb) _tf_ssb_callback_post(ssb, cb, pre_callback_hrtime_ns)
|
||||
|
||||
const int k_read_back_pressure_threshold = 256;
|
||||
|
||||
static_assert(k_id_base64_len == sodium_base64_ENCODED_LEN(9 + crypto_box_PUBLICKEYBYTES, sodium_base64_VARIANT_ORIGINAL), "k_id_base64_len");
|
||||
@ -238,9 +235,6 @@ typedef struct _tf_ssb_t
|
||||
int32_t thread_busy_count;
|
||||
int32_t thread_busy_max;
|
||||
|
||||
void (*hitch_callback)(const char* name, uint64_t duration, void* user_data);
|
||||
void* hitch_user_data;
|
||||
|
||||
tf_ssb_store_queue_t store_queue;
|
||||
int ref_count;
|
||||
|
||||
@ -369,8 +363,6 @@ static int s_connection_index;
|
||||
static int s_tunnel_index;
|
||||
|
||||
static void _tf_ssb_add_broadcast(tf_ssb_t* ssb, const tf_ssb_broadcast_t* broadcast, int expires_seconds);
|
||||
static uint64_t _tf_ssb_callback_pre(tf_ssb_t* ssb);
|
||||
static void _tf_ssb_callback_post(tf_ssb_t* ssb, void* callback, uint64_t pre);
|
||||
static void _tf_ssb_connection_client_send_hello(tf_ssb_connection_t* connection);
|
||||
static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const char* reason);
|
||||
static void _tf_ssb_connection_finalizer(JSRuntime* runtime, JSValue value);
|
||||
@ -646,9 +638,7 @@ static void _tf_ssb_connection_dispatch_scheduled(tf_ssb_connection_t* connectio
|
||||
connection->scheduled_count--;
|
||||
|
||||
tf_trace_begin(connection->ssb->trace, "scheduled callback");
|
||||
PRE_CALLBACK(connection->ssb, scheduled.callback);
|
||||
scheduled.callback(connection, false, scheduled.user_data);
|
||||
POST_CALLBACK(connection->ssb, scheduled.callback);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
}
|
||||
}
|
||||
@ -667,9 +657,7 @@ void tf_ssb_connection_schedule_idle(tf_ssb_connection_t* connection, const char
|
||||
{
|
||||
/* Skip the new request. */
|
||||
tf_trace_begin(connection->ssb->trace, "scheduled callback (skip)");
|
||||
PRE_CALLBACK(connection->ssb, callback);
|
||||
callback(connection, true, user_data);
|
||||
POST_CALLBACK(connection->ssb, callback);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
}
|
||||
else
|
||||
@ -1250,22 +1238,6 @@ bool tf_ssb_id_str_to_bin(uint8_t* bin, const char* str)
|
||||
return author_id && type ? tf_base64_decode(author_id, type - author_id, bin, crypto_box_PUBLICKEYBYTES) != 0 : false;
|
||||
}
|
||||
|
||||
static uint64_t _tf_ssb_callback_pre(tf_ssb_t* ssb)
|
||||
{
|
||||
return uv_hrtime();
|
||||
}
|
||||
|
||||
static void _tf_ssb_callback_post(tf_ssb_t* ssb, void* callback, uint64_t pre)
|
||||
{
|
||||
if (ssb->hitch_callback)
|
||||
{
|
||||
uint64_t post = uv_hrtime();
|
||||
const char* name = tf_util_function_to_string(callback);
|
||||
ssb->hitch_callback(name, post - pre, ssb->hitch_user_data);
|
||||
tf_free((void*)name);
|
||||
}
|
||||
}
|
||||
|
||||
static void _tf_ssb_notify_connections_changed(tf_ssb_t* ssb, tf_ssb_change_t change, tf_ssb_connection_t* connection)
|
||||
{
|
||||
tf_ssb_connections_changed_callback_node_t* next = NULL;
|
||||
@ -1273,9 +1245,7 @@ static void _tf_ssb_notify_connections_changed(tf_ssb_t* ssb, tf_ssb_change_t ch
|
||||
{
|
||||
next = node->next;
|
||||
tf_trace_begin(ssb->trace, "connections_changed");
|
||||
PRE_CALLBACK(ssb, node->callback);
|
||||
node->callback(ssb, change, connection, node->user_data);
|
||||
POST_CALLBACK(ssb, node->callback);
|
||||
tf_trace_end(ssb->trace);
|
||||
}
|
||||
}
|
||||
@ -1384,9 +1354,7 @@ static void _tf_ssb_connection_verify_identity(tf_ssb_connection_t* connection,
|
||||
connection->state = k_tf_ssb_state_verified;
|
||||
if (connection->connect_callback)
|
||||
{
|
||||
PRE_CALLBACK(connection->ssb, connection->connect_callback);
|
||||
connection->connect_callback(connection, NULL, connection->connect_callback_user_data);
|
||||
POST_CALLBACK(connection->ssb, connection->connect_callback);
|
||||
connection->connect_callback = NULL;
|
||||
connection->connect_callback_user_data = NULL;
|
||||
}
|
||||
@ -1778,9 +1746,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), "request %s:%d", request_name, request_number);
|
||||
tf_trace_begin(connection->ssb->trace, buffer);
|
||||
PRE_CALLBACK(connection->ssb, callback);
|
||||
callback(connection, flags, request_number, val, message, size, user_data);
|
||||
POST_CALLBACK(connection->ssb, callback);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
if (!(flags & k_ssb_rpc_flag_stream))
|
||||
{
|
||||
@ -1799,9 +1765,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
||||
{
|
||||
tf_ssb_connection_add_request(connection, -request_number, name, NULL, NULL, NULL, NULL);
|
||||
tf_trace_begin(connection->ssb->trace, it->name);
|
||||
PRE_CALLBACK(connection->ssb, it->callback);
|
||||
it->callback(connection, flags, request_number, val, message, size, it->user_data);
|
||||
POST_CALLBACK(connection->ssb, it->callback);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
found = true;
|
||||
break;
|
||||
@ -1841,9 +1805,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), "request %s:%d", request_name, request_number);
|
||||
tf_trace_begin(connection->ssb->trace, buffer);
|
||||
PRE_CALLBACK(connection->ssb, callback);
|
||||
callback(connection, flags, request_number, JS_UNDEFINED, message, size, user_data);
|
||||
POST_CALLBACK(connection->ssb, callback);
|
||||
tf_trace_end(connection->ssb->trace);
|
||||
}
|
||||
}
|
||||
@ -2030,9 +1992,7 @@ static void _tf_ssb_connection_destroy(tf_ssb_connection_t* connection, const ch
|
||||
}
|
||||
if (connection->connect_callback)
|
||||
{
|
||||
PRE_CALLBACK(connection->ssb, connection->connect_callback);
|
||||
connection->connect_callback(NULL, reason, connection->connect_callback_user_data);
|
||||
POST_CALLBACK(connection->ssb, connection->connect_callback);
|
||||
connection->connect_callback = NULL;
|
||||
connection->connect_callback_user_data = NULL;
|
||||
}
|
||||
@ -3560,9 +3520,7 @@ static void _tf_ssb_notify_broadcasts_changed(tf_ssb_t* ssb)
|
||||
if (node->callback)
|
||||
{
|
||||
tf_trace_begin(ssb->trace, "broadcasts changed");
|
||||
PRE_CALLBACK(ssb, node->callback);
|
||||
node->callback(ssb, node->user_data);
|
||||
POST_CALLBACK(ssb, node->callback);
|
||||
tf_trace_end(ssb->trace);
|
||||
}
|
||||
}
|
||||
@ -3666,9 +3624,7 @@ void tf_ssb_visit_broadcasts(tf_ssb_t* ssb,
|
||||
if (node->mtime - now < 60)
|
||||
{
|
||||
tf_trace_begin(ssb->trace, "broadcast");
|
||||
PRE_CALLBACK(ssb, callback);
|
||||
callback(node->host, &node->addr, node->origin, node->tunnel_connection, node->pub, user_data);
|
||||
POST_CALLBACK(ssb, callback);
|
||||
tf_trace_end(ssb->trace);
|
||||
}
|
||||
}
|
||||
@ -3975,9 +3931,7 @@ void tf_ssb_notify_message_added(tf_ssb_t* ssb, const char* author, int64_t sequ
|
||||
{
|
||||
next = node->next;
|
||||
tf_trace_begin(ssb->trace, "message added callback");
|
||||
PRE_CALLBACK(ssb, node->callback);
|
||||
node->callback(ssb, author, sequence, id, node->user_data);
|
||||
POST_CALLBACK(ssb, node->callback);
|
||||
tf_trace_end(ssb->trace);
|
||||
}
|
||||
|
||||
@ -4053,9 +4007,7 @@ void tf_ssb_notify_blob_want_added(tf_ssb_t* ssb, const char* id)
|
||||
{
|
||||
next = node->next;
|
||||
tf_trace_begin(ssb->trace, "blob want added callback");
|
||||
PRE_CALLBACK(ssb, node->callback);
|
||||
node->callback(ssb, id, node->user_data);
|
||||
POST_CALLBACK(ssb, node->callback);
|
||||
tf_trace_end(ssb->trace);
|
||||
}
|
||||
}
|
||||
@ -4240,12 +4192,6 @@ float tf_ssb_get_average_thread_percent(tf_ssb_t* ssb)
|
||||
return 100.0f * ssb->thread_busy_count / ssb->thread_busy_max;
|
||||
}
|
||||
|
||||
void tf_ssb_set_hitch_callback(tf_ssb_t* ssb, void (*callback)(const char* name, uint64_t duration_ns, void* user_data), void* user_data)
|
||||
{
|
||||
ssb->hitch_callback = callback;
|
||||
ssb->hitch_user_data = user_data;
|
||||
}
|
||||
|
||||
tf_ssb_store_queue_t* tf_ssb_get_store_queue(tf_ssb_t* ssb)
|
||||
{
|
||||
return &ssb->store_queue;
|
||||
@ -4301,9 +4247,7 @@ static void _tf_ssb_connection_after_work_callback(uv_work_t* work, int status)
|
||||
if (data->after_work_callback)
|
||||
{
|
||||
tf_trace_begin(data->connection->ssb->trace, data->after_name);
|
||||
PRE_CALLBACK(data->connection->ssb, data->after_work_callback);
|
||||
data->after_work_callback(data->connection, status, data->user_data);
|
||||
POST_CALLBACK(data->connection->ssb, data->after_work_callback);
|
||||
tf_trace_end(data->connection->ssb->trace);
|
||||
}
|
||||
data->connection->ref_count--;
|
||||
@ -4370,9 +4314,7 @@ static void _tf_ssb_after_work_callback(uv_work_t* work, int status)
|
||||
if (data->after_work_callback)
|
||||
{
|
||||
tf_trace_begin(data->ssb->trace, data->after_name);
|
||||
PRE_CALLBACK(data->ssb, data->after_work_callback);
|
||||
data->after_work_callback(data->ssb, status, data->user_data);
|
||||
POST_CALLBACK(data->ssb, data->after_work_callback);
|
||||
tf_trace_end(data->ssb->trace);
|
||||
}
|
||||
tf_ssb_unref(data->ssb);
|
||||
@ -4535,9 +4477,7 @@ void tf_ssb_set_quiet(tf_ssb_t* ssb, bool quiet)
|
||||
static void _tf_ssb_scheduled_timer(uv_timer_t* handle)
|
||||
{
|
||||
tf_ssb_timer_t* timer = handle->data;
|
||||
PRE_CALLBACK(timer->ssb, timer->callback);
|
||||
timer->callback(timer->ssb, timer->user_data);
|
||||
POST_CALLBACK(timer->ssb, timer->callback);
|
||||
uv_close((uv_handle_t*)handle, _tf_ssb_on_timer_close);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user