Commitebcb622aRecorded18 Apr 2026Repositorysigil-lsp
sigil-lsp: warm the docs index at `initialized`
Message
The first textDocument/hover after server start used to lazily build the (sigil docs search) index by scanning ~130 JSON files on demand, which the timing log showed clocking in at ~7500ms per first hover. Moving the build to the initialized notification shifts that cost off the user's interactive path — the server responds to initialize immediately, then warms the index before the first real request arrives. Logged at info with its own elapsed-ms so we can still see the cost in the trace log.
(Also removes leftover [E]/[S] render markers from an earlier diagnostic round.)
Changed
src/sigil/lsp/server.sgl | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)Diff
src/sigil/lsp/server.sglmodified
@@ -14,6 +14,7 @@
14
(sigil log) 15
(sigil time) 16
(sigil math)+17
(sigil docs search) 18
(sigil lsp protocol) 19
(sigil lsp documents) 20
(sigil lsp diagnostics)@@ -90,6 +91,18 @@
91
;; Dispatch 92
;; ============================================================ 93
+94
;; Force the (sigil docs search) index cache to populate by running+95
;; one search. Logged at info so it shows up in normal run logs.+96
(define (warm-docs-index!)+97
(let ((t0 (current-jiffy)))+98
(guard (e (else+99
(log-warn "lsp index warmup failed"+100
error: (if (error-object? e)+101
(error-object-message e) e))))+102
(search-docs "_sigil_lsp_warmup_")+103
(log-info "lsp index warm"+104
elapsed-ms: (elapsed-ms t0 (current-jiffy))))))+105
106
;; Elapsed time in milliseconds between two (current-jiffy) samples. 107
(define (elapsed-ms t0 t1) 108
(let ((jps (jiffies-per-second)))@@ -172,7 +185,10 @@
185
(define (handle-notification server method params) 186
(log-debug "lsp notification" method: method) 187
(cond−175
((string=? method "initialized") #f)+188
((string=? method "initialized")+189
;; Eagerly warm the docs index so the first hover / completion+190
;; doesn't pay the ~7s cost of scanning all module JSON files.+191
(warm-docs-index!)) 192
((string=? method "exit") 193
(log-info "lsp exit")) 194
((not (lsp-server-initialized server)) #f)