Add Fase 0 telemetry for the server-client migration baseline
Adds dev-only counters, with no behavior change, to answer the open
questions from the migration plan before touching the transport:
- frontend.state/get-invoke-stats: per-thread-api-method count/total-ms/
max-ms for every <invoke-db-worker call, to census how many invokes a
typical navigation generates and their latency distribution.
- db-worker-node: per-repo in-flight /v1/invoke counter that logs a new
concurrency high-water mark, to check whether concurrent client writes
actually overlap before deciding on a write queue.
- subs-loader/get-stats: dedup-hit vs new-entry counts for load!, and
batch-size distribution per slot kind at flush, to check whether
in-flight snapshot requests are already deduplicated and whether the
{:children 25 :resources 25} limits are worth raising for network RTT.
Verified with clojure -M:cljs compile app and compile db-worker-node
(0 warnings on both).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,25 @@
|
||||
(defonce ^:private *sse-clients (atom #{}))
|
||||
(defonce ^:private *lock-info (atom nil))
|
||||
(defonce ^:private *server-list-file (atom nil))
|
||||
(defonce ^:private *inflight-by-repo (atom {}))
|
||||
(defonce ^:private *max-inflight-by-repo (atom {}))
|
||||
|
||||
(defn- invoke-started!
|
||||
"Increments the /v1/invoke in-flight counter for repo and logs a new
|
||||
concurrency high-water mark when observed. Dev-only instrumentation for the
|
||||
server-client migration multi-client baseline (see docs/agent-guide); has no
|
||||
effect on request handling."
|
||||
[repo]
|
||||
(let [n (get (swap! *inflight-by-repo update repo (fnil inc 0)) repo)
|
||||
prev-max (get @*max-inflight-by-repo repo 0)]
|
||||
(when (> n prev-max)
|
||||
(swap! *max-inflight-by-repo assoc repo n)
|
||||
(log/info :db-worker-node-invoke-concurrency-high-water-mark
|
||||
{:repo repo :concurrent n}))))
|
||||
|
||||
(defn- invoke-finished!
|
||||
[repo]
|
||||
(swap! *inflight-by-repo update repo (fnil dec 0)))
|
||||
|
||||
(defn- server-list-file-path
|
||||
[root-dir]
|
||||
@@ -376,7 +395,9 @@
|
||||
(p/let [_ (when-not (contains? non-repo-methods method-kw)
|
||||
(let [{:keys [path lock]} @*lock-info]
|
||||
(db-lock/assert-lock-owner! path lock)))
|
||||
result (<invoke! proxy method-str method-kw args')]
|
||||
_ (invoke-started! bound-repo)
|
||||
result (-> (<invoke! proxy method-str method-kw args')
|
||||
(p/finally (fn [] (invoke-finished! bound-repo))))]
|
||||
(send-json! res 200 {:ok true :resultTransit result}))))
|
||||
(p/catch (fn [error]
|
||||
(log-invoke-error! res error method-kw)))))
|
||||
|
||||
Reference in New Issue
Block a user