core: Remove hitch tracking. Hasn't been an active problem, and the traces are sufficient to diagnose.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m36s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 32m36s
This commit is contained in:
@ -305,18 +305,10 @@ class TfElement extends LitElement {
|
|||||||
const k_chunk_size = 512;
|
const k_chunk_size = 512;
|
||||||
if (cache.range.length) {
|
if (cache.range.length) {
|
||||||
for (let i = cache.range[1]; i < latest; i += k_chunk_size) {
|
for (let i = cache.range[1]; i < latest; i += k_chunk_size) {
|
||||||
ranges.push([
|
ranges.push([i, Math.min(i + k_chunk_size, latest), true]);
|
||||||
i,
|
|
||||||
Math.min(i + k_chunk_size, latest),
|
|
||||||
true,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
for (let i = cache.range[0]; i >= 0; i -= k_chunk_size) {
|
for (let i = cache.range[0]; i >= 0; i -= k_chunk_size) {
|
||||||
ranges.push([
|
ranges.push([Math.max(i - k_chunk_size, 0), i, false]);
|
||||||
Math.max(i - k_chunk_size, 0),
|
|
||||||
i,
|
|
||||||
false,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < latest; i += k_chunk_size) {
|
for (let i = 0; i < latest; i += k_chunk_size) {
|
||||||
|
@ -640,25 +640,6 @@ static void _httpd_endpoint_mem(tf_http_request_t* request)
|
|||||||
tf_free(response);
|
tf_free(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _httpd_endpoint_hitches(tf_http_request_t* request)
|
|
||||||
{
|
|
||||||
if (_httpd_redirect(request))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tf_task_t* task = request->user_data;
|
|
||||||
char* response = tf_task_get_hitches(task);
|
|
||||||
const char* headers[] = {
|
|
||||||
"Content-Type",
|
|
||||||
"application/json; charset=utf-8",
|
|
||||||
"Access-Control-Allow-Origin",
|
|
||||||
"*",
|
|
||||||
};
|
|
||||||
tf_http_respond(request, 200, headers, tf_countof(headers) / 2, response, response ? strlen(response) : 0);
|
|
||||||
tf_free(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* _after(const char* text, const char* prefix)
|
static const char* _after(const char* text, const char* prefix)
|
||||||
{
|
{
|
||||||
if (!text || !prefix)
|
if (!text || !prefix)
|
||||||
@ -2437,7 +2418,6 @@ tf_http_t* tf_httpd_create(JSContext* context)
|
|||||||
|
|
||||||
tf_http_add_handler(http, "/robots.txt", _httpd_endpoint_robots_txt, NULL, NULL);
|
tf_http_add_handler(http, "/robots.txt", _httpd_endpoint_robots_txt, NULL, NULL);
|
||||||
tf_http_add_handler(http, "/debug", _httpd_endpoint_debug, NULL, task);
|
tf_http_add_handler(http, "/debug", _httpd_endpoint_debug, NULL, task);
|
||||||
tf_http_add_handler(http, "/hitches", _httpd_endpoint_hitches, NULL, task);
|
|
||||||
tf_http_add_handler(http, "/mem", _httpd_endpoint_mem, NULL, task);
|
tf_http_add_handler(http, "/mem", _httpd_endpoint_mem, NULL, task);
|
||||||
tf_http_add_handler(http, "/trace", _httpd_endpoint_trace, NULL, task);
|
tf_http_add_handler(http, "/trace", _httpd_endpoint_trace, NULL, task);
|
||||||
tf_http_add_handler(http, "/ebt", _httpd_endpoint_ebt, NULL, task);
|
tf_http_add_handler(http, "/ebt", _httpd_endpoint_ebt, NULL, task);
|
||||||
|
60
src/ssb.c
60
src/ssb.c
@ -34,9 +34,6 @@
|
|||||||
#define CYAN "\e[1;36m"
|
#define CYAN "\e[1;36m"
|
||||||
#define RESET "\e[0m"
|
#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;
|
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");
|
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_count;
|
||||||
int32_t thread_busy_max;
|
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;
|
tf_ssb_store_queue_t store_queue;
|
||||||
int ref_count;
|
int ref_count;
|
||||||
|
|
||||||
@ -369,8 +363,6 @@ static int s_connection_index;
|
|||||||
static int s_tunnel_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 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_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_destroy(tf_ssb_connection_t* connection, const char* reason);
|
||||||
static void _tf_ssb_connection_finalizer(JSRuntime* runtime, JSValue value);
|
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--;
|
connection->scheduled_count--;
|
||||||
|
|
||||||
tf_trace_begin(connection->ssb->trace, "scheduled callback");
|
tf_trace_begin(connection->ssb->trace, "scheduled callback");
|
||||||
PRE_CALLBACK(connection->ssb, scheduled.callback);
|
|
||||||
scheduled.callback(connection, false, scheduled.user_data);
|
scheduled.callback(connection, false, scheduled.user_data);
|
||||||
POST_CALLBACK(connection->ssb, scheduled.callback);
|
|
||||||
tf_trace_end(connection->ssb->trace);
|
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. */
|
/* Skip the new request. */
|
||||||
tf_trace_begin(connection->ssb->trace, "scheduled callback (skip)");
|
tf_trace_begin(connection->ssb->trace, "scheduled callback (skip)");
|
||||||
PRE_CALLBACK(connection->ssb, callback);
|
|
||||||
callback(connection, true, user_data);
|
callback(connection, true, user_data);
|
||||||
POST_CALLBACK(connection->ssb, callback);
|
|
||||||
tf_trace_end(connection->ssb->trace);
|
tf_trace_end(connection->ssb->trace);
|
||||||
}
|
}
|
||||||
else
|
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;
|
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)
|
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;
|
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;
|
next = node->next;
|
||||||
tf_trace_begin(ssb->trace, "connections_changed");
|
tf_trace_begin(ssb->trace, "connections_changed");
|
||||||
PRE_CALLBACK(ssb, node->callback);
|
|
||||||
node->callback(ssb, change, connection, node->user_data);
|
node->callback(ssb, change, connection, node->user_data);
|
||||||
POST_CALLBACK(ssb, node->callback);
|
|
||||||
tf_trace_end(ssb->trace);
|
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;
|
connection->state = k_tf_ssb_state_verified;
|
||||||
if (connection->connect_callback)
|
if (connection->connect_callback)
|
||||||
{
|
{
|
||||||
PRE_CALLBACK(connection->ssb, connection->connect_callback);
|
|
||||||
connection->connect_callback(connection, NULL, connection->connect_callback_user_data);
|
connection->connect_callback(connection, NULL, connection->connect_callback_user_data);
|
||||||
POST_CALLBACK(connection->ssb, connection->connect_callback);
|
|
||||||
connection->connect_callback = NULL;
|
connection->connect_callback = NULL;
|
||||||
connection->connect_callback_user_data = 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];
|
char buffer[64];
|
||||||
snprintf(buffer, sizeof(buffer), "request %s:%d", request_name, request_number);
|
snprintf(buffer, sizeof(buffer), "request %s:%d", request_name, request_number);
|
||||||
tf_trace_begin(connection->ssb->trace, buffer);
|
tf_trace_begin(connection->ssb->trace, buffer);
|
||||||
PRE_CALLBACK(connection->ssb, callback);
|
|
||||||
callback(connection, flags, request_number, val, message, size, user_data);
|
callback(connection, flags, request_number, val, message, size, user_data);
|
||||||
POST_CALLBACK(connection->ssb, callback);
|
|
||||||
tf_trace_end(connection->ssb->trace);
|
tf_trace_end(connection->ssb->trace);
|
||||||
if (!(flags & k_ssb_rpc_flag_stream))
|
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_ssb_connection_add_request(connection, -request_number, name, NULL, NULL, NULL, NULL);
|
||||||
tf_trace_begin(connection->ssb->trace, it->name);
|
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);
|
it->callback(connection, flags, request_number, val, message, size, it->user_data);
|
||||||
POST_CALLBACK(connection->ssb, it->callback);
|
|
||||||
tf_trace_end(connection->ssb->trace);
|
tf_trace_end(connection->ssb->trace);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -1841,9 +1805,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
char buffer[64];
|
char buffer[64];
|
||||||
snprintf(buffer, sizeof(buffer), "request %s:%d", request_name, request_number);
|
snprintf(buffer, sizeof(buffer), "request %s:%d", request_name, request_number);
|
||||||
tf_trace_begin(connection->ssb->trace, buffer);
|
tf_trace_begin(connection->ssb->trace, buffer);
|
||||||
PRE_CALLBACK(connection->ssb, callback);
|
|
||||||
callback(connection, flags, request_number, JS_UNDEFINED, message, size, user_data);
|
callback(connection, flags, request_number, JS_UNDEFINED, message, size, user_data);
|
||||||
POST_CALLBACK(connection->ssb, callback);
|
|
||||||
tf_trace_end(connection->ssb->trace);
|
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)
|
if (connection->connect_callback)
|
||||||
{
|
{
|
||||||
PRE_CALLBACK(connection->ssb, connection->connect_callback);
|
|
||||||
connection->connect_callback(NULL, reason, connection->connect_callback_user_data);
|
connection->connect_callback(NULL, reason, connection->connect_callback_user_data);
|
||||||
POST_CALLBACK(connection->ssb, connection->connect_callback);
|
|
||||||
connection->connect_callback = NULL;
|
connection->connect_callback = NULL;
|
||||||
connection->connect_callback_user_data = 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)
|
if (node->callback)
|
||||||
{
|
{
|
||||||
tf_trace_begin(ssb->trace, "broadcasts changed");
|
tf_trace_begin(ssb->trace, "broadcasts changed");
|
||||||
PRE_CALLBACK(ssb, node->callback);
|
|
||||||
node->callback(ssb, node->user_data);
|
node->callback(ssb, node->user_data);
|
||||||
POST_CALLBACK(ssb, node->callback);
|
|
||||||
tf_trace_end(ssb->trace);
|
tf_trace_end(ssb->trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3666,9 +3624,7 @@ void tf_ssb_visit_broadcasts(tf_ssb_t* ssb,
|
|||||||
if (node->mtime - now < 60)
|
if (node->mtime - now < 60)
|
||||||
{
|
{
|
||||||
tf_trace_begin(ssb->trace, "broadcast");
|
tf_trace_begin(ssb->trace, "broadcast");
|
||||||
PRE_CALLBACK(ssb, callback);
|
|
||||||
callback(node->host, &node->addr, node->origin, node->tunnel_connection, node->pub, user_data);
|
callback(node->host, &node->addr, node->origin, node->tunnel_connection, node->pub, user_data);
|
||||||
POST_CALLBACK(ssb, callback);
|
|
||||||
tf_trace_end(ssb->trace);
|
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;
|
next = node->next;
|
||||||
tf_trace_begin(ssb->trace, "message added callback");
|
tf_trace_begin(ssb->trace, "message added callback");
|
||||||
PRE_CALLBACK(ssb, node->callback);
|
|
||||||
node->callback(ssb, author, sequence, id, node->user_data);
|
node->callback(ssb, author, sequence, id, node->user_data);
|
||||||
POST_CALLBACK(ssb, node->callback);
|
|
||||||
tf_trace_end(ssb->trace);
|
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;
|
next = node->next;
|
||||||
tf_trace_begin(ssb->trace, "blob want added callback");
|
tf_trace_begin(ssb->trace, "blob want added callback");
|
||||||
PRE_CALLBACK(ssb, node->callback);
|
|
||||||
node->callback(ssb, id, node->user_data);
|
node->callback(ssb, id, node->user_data);
|
||||||
POST_CALLBACK(ssb, node->callback);
|
|
||||||
tf_trace_end(ssb->trace);
|
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;
|
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)
|
tf_ssb_store_queue_t* tf_ssb_get_store_queue(tf_ssb_t* ssb)
|
||||||
{
|
{
|
||||||
return &ssb->store_queue;
|
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)
|
if (data->after_work_callback)
|
||||||
{
|
{
|
||||||
tf_trace_begin(data->connection->ssb->trace, data->after_name);
|
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);
|
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);
|
tf_trace_end(data->connection->ssb->trace);
|
||||||
}
|
}
|
||||||
data->connection->ref_count--;
|
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)
|
if (data->after_work_callback)
|
||||||
{
|
{
|
||||||
tf_trace_begin(data->ssb->trace, data->after_name);
|
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);
|
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_trace_end(data->ssb->trace);
|
||||||
}
|
}
|
||||||
tf_ssb_unref(data->ssb);
|
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)
|
static void _tf_ssb_scheduled_timer(uv_timer_t* handle)
|
||||||
{
|
{
|
||||||
tf_ssb_timer_t* timer = handle->data;
|
tf_ssb_timer_t* timer = handle->data;
|
||||||
PRE_CALLBACK(timer->ssb, timer->callback);
|
|
||||||
timer->callback(timer->ssb, timer->user_data);
|
timer->callback(timer->ssb, timer->user_data);
|
||||||
POST_CALLBACK(timer->ssb, timer->callback);
|
|
||||||
uv_close((uv_handle_t*)handle, _tf_ssb_on_timer_close);
|
uv_close((uv_handle_t*)handle, _tf_ssb_on_timer_close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,15 +1006,6 @@ void tf_ssb_record_thread_busy(tf_ssb_t* ssb, bool busy);
|
|||||||
*/
|
*/
|
||||||
float tf_ssb_get_average_thread_percent(tf_ssb_t* ssb);
|
float tf_ssb_get_average_thread_percent(tf_ssb_t* ssb);
|
||||||
|
|
||||||
/**
|
|
||||||
** Register a callback to be called when the main thread blocks for an
|
|
||||||
** unreasonable amount of time.
|
|
||||||
** @param ssb The SSB instance.
|
|
||||||
** @param callback The callback to call.
|
|
||||||
** @param user_data User data to pass to the callback.
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Get the queue of messages in the progress of being stored.
|
** Get the queue of messages in the progress of being stored.
|
||||||
** @param ssb The SSB instance.
|
** @param ssb The SSB instance.
|
||||||
|
49
src/task.c
49
src/task.c
@ -88,12 +88,6 @@ typedef struct _promise_stack_t
|
|||||||
int cstack_count;
|
int cstack_count;
|
||||||
} promise_stack_t;
|
} promise_stack_t;
|
||||||
|
|
||||||
typedef struct _hitch_t
|
|
||||||
{
|
|
||||||
char name[256];
|
|
||||||
uint64_t duration_ns;
|
|
||||||
} hitch_t;
|
|
||||||
|
|
||||||
typedef struct _timeout_t timeout_t;
|
typedef struct _timeout_t timeout_t;
|
||||||
|
|
||||||
typedef struct _timeout_t
|
typedef struct _timeout_t
|
||||||
@ -170,8 +164,6 @@ typedef struct _tf_task_t
|
|||||||
|
|
||||||
timeout_t* timeouts;
|
timeout_t* timeouts;
|
||||||
|
|
||||||
hitch_t hitches[32];
|
|
||||||
|
|
||||||
uint64_t last_gc_ns;
|
uint64_t last_gc_ns;
|
||||||
int64_t last_gc_duration_ns;
|
int64_t last_gc_duration_ns;
|
||||||
} tf_task_t;
|
} tf_task_t;
|
||||||
@ -930,28 +922,6 @@ char* tf_task_get_debug(tf_task_t* task)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tf_task_get_hitches(tf_task_t* task)
|
|
||||||
{
|
|
||||||
JSContext* context = task->_context;
|
|
||||||
tf_trace_begin(task->_trace, __func__);
|
|
||||||
JSValue object = JS_NewObject(context);
|
|
||||||
for (int i = 0; i < tf_countof(task->hitches); i++)
|
|
||||||
{
|
|
||||||
if (*task->hitches[i].name)
|
|
||||||
{
|
|
||||||
JS_SetPropertyStr(context, object, task->hitches[i].name, JS_NewFloat64(context, task->hitches[i].duration_ns / 1e9));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
JSValue json = JS_JSONStringify(context, object, JS_NULL, JS_NewInt32(context, 2));
|
|
||||||
const char* string = JS_ToCString(context, json);
|
|
||||||
char* result = tf_strdup(string);
|
|
||||||
JS_FreeCString(context, string);
|
|
||||||
JS_FreeValue(context, json);
|
|
||||||
JS_FreeValue(context, object);
|
|
||||||
tf_trace_end(task->_trace);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static JSValue _tf_task_getFile(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
static JSValue _tf_task_getFile(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||||
{
|
{
|
||||||
tf_task_t* task = JS_GetContextOpaque(context);
|
tf_task_t* task = JS_GetContextOpaque(context);
|
||||||
@ -1666,24 +1636,6 @@ static void _tf_task_trace_to_parent(tf_trace_t* trace, const char* buffer, size
|
|||||||
tf_packetstream_send(tf_taskstub_get_stream(task->_parent), kTaskTrace, buffer, size);
|
tf_packetstream_send(tf_taskstub_get_stream(task->_parent), kTaskTrace, buffer, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _tf_task_record_hitch(const char* name, uint64_t duration_ns, void* user_data)
|
|
||||||
{
|
|
||||||
tf_task_t* task = user_data;
|
|
||||||
for (int i = 0; i < tf_countof(task->hitches); i++)
|
|
||||||
{
|
|
||||||
if (duration_ns > task->hitches[i].duration_ns)
|
|
||||||
{
|
|
||||||
if (i + 1 < tf_countof(task->hitches))
|
|
||||||
{
|
|
||||||
memmove(task->hitches + i + 1, task->hitches + i, sizeof(hitch_t) * (tf_countof(task->hitches) - i - 1));
|
|
||||||
}
|
|
||||||
snprintf(task->hitches[i].name, sizeof(task->hitches[i].name), "%s", name);
|
|
||||||
task->hitches[i].duration_ns = duration_ns;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tf_task_activate(tf_task_t* task)
|
void tf_task_activate(tf_task_t* task)
|
||||||
{
|
{
|
||||||
assert(!task->_activated);
|
assert(!task->_activated);
|
||||||
@ -1717,7 +1669,6 @@ void tf_task_activate(tf_task_t* task)
|
|||||||
tf_ssb_set_trace(task->_ssb, task->_trace);
|
tf_ssb_set_trace(task->_ssb, task->_trace);
|
||||||
tf_ssb_register(context, task->_ssb);
|
tf_ssb_register(context, task->_ssb);
|
||||||
tf_api_register(context);
|
tf_api_register(context);
|
||||||
tf_ssb_set_hitch_callback(task->_ssb, _tf_task_record_hitch, task);
|
|
||||||
|
|
||||||
if (task->_args)
|
if (task->_args)
|
||||||
{
|
{
|
||||||
|
@ -319,13 +319,6 @@ bool tf_task_send_error_to_parent(tf_task_t* task, JSValue error);
|
|||||||
*/
|
*/
|
||||||
char* tf_task_get_debug(tf_task_t* task);
|
char* tf_task_get_debug(tf_task_t* task);
|
||||||
|
|
||||||
/**
|
|
||||||
** Get a report of hitches that occurred.
|
|
||||||
** @param task The task.
|
|
||||||
** @return A JSON report of recent hitches that must be freed with tf_free().
|
|
||||||
*/
|
|
||||||
char* tf_task_get_hitches(tf_task_t* task);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** A callback used to start an Android service.
|
** A callback used to start an Android service.
|
||||||
** @param pipe_fd A file descriptor with which to communicate with the invoking
|
** @param pipe_fd A file descriptor with which to communicate with the invoking
|
||||||
|
Reference in New Issue
Block a user