Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
    npro  
 Modern all-safe Rust Network Protocol library supporting h1, h2, h3, ws, wt sans-IO and with socket IO + tls
git clone https://npro.rs/repo/npro
 
root / READMEs / README-builder-env.md
Author[]Andy Green <andy@warmcat.com> 2025-08-16 11:04 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-08-16 11:05 UTC
Treeb1150dcb4ef78096fa45b364bd0e5e2051703929   Raw Patch
 
logs: add indexes
logs: add indexes

Co-developed-by: Gemini 2.5 Pro
diff --git a/src/web/w-comms.c b/src/web/w-comms.c index 1997a49..d21ad1b 100644 --- a/src/web/w-comms.c +++ b/src/web/w-comms.c @@ -221,6 +221,10 @@ sais_event_db_ensure_open(struct vhd *vhd, const char *event_uuid, return 1; } + sai_sqlite3_statement(*ppdb, + "CREATE INDEX IF NOT EXISTS logs_index ON logs (task_uuid, timestamp);", + "create logs index"); + if (lws_struct_sq3_create_table(*ppdb, lsm_schema_sq3_map_artifact)) { lwsl_err("%s: unable to create artifact table for %s\n", __func__, filepath); @@ -1184,7 +1188,8 @@ clean_spa: lwsl_info("%s: ESTABLISHED: browser\n", __func__); saiw_browser_state_changed(pss, 1); pss->wsi = wsi; - break; + + return 0; } lwsl_err("%s: unknown URL '%s'\n", __func__, start); diff --git a/src/web/w-ws-browser.c b/src/web/w-ws-browser.c index 96bb119..3a48566 100644 --- a/src/web/w-ws-browser.c +++ b/src/web/w-ws-browser.c @@ -675,11 +675,6 @@ again: sch = NULL; - lws_snprintf(esc, sizeof(esc), - "and task_uuid='%s' and timestamp > %llu", - pss->sub_task_uuid, - (unsigned long long)pss->sub_timestamp); - /* * For efficiency, let's try to grab the next 100 at * once from sqlite and work our way through sending @@ -687,6 +682,7 @@ again: */ if (pss->log_cache_index == pss->log_cache_size) { + lws_usec_t tim; int sr; sai_task_uuid_to_event_uuid(event_uuid, @@ -695,6 +691,11 @@ again: lws_dll2_owner_clear(&task_owner); lwsac_free(&pss->logs_ac); + lws_snprintf(esc, sizeof(esc), + "and task_uuid='%s' and timestamp > %llu", + pss->sub_task_uuid, + (unsigned long long)pss->sub_timestamp); + lwsl_info("%s: collecting logs %s\n", __func__, esc); @@ -706,6 +707,8 @@ again: return 0; } + tim = lws_now_usecs(); + sr = lws_struct_sq3_deserialize(pdb, esc, "uid,timestamp ", lsm_schema_sq3_map_log, @@ -723,6 +726,9 @@ again: pss->log_cache_index = 0; pss->log_cache_size = (int)pss->logs_owner.count; + + lwsl_wsi_notice(pss->wsi, "fetched %d logs in %dus", pss->log_cache_size, (int)(lws_now_usecs() - tim)); + } if (pss->log_cache_index < pss->log_cache_size) {
Page fetched 0s ago, creation time: 2ms (vhost etag hits: 0%, cache hits: 0%)