mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 00:40:30 -05:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
d6a5913086
4 changed files with 46 additions and 31 deletions
|
@ -40,13 +40,14 @@
|
|||
{:parallelism (cf/get :worker-executor-parallelism 10)
|
||||
:prefix :worker}
|
||||
|
||||
:app.worker/executors-monitor
|
||||
{:executors
|
||||
{:default (ig/ref [::default :app.worker/executor])
|
||||
:blocking (ig/ref [::blocking :app.worker/executor])
|
||||
:worker (ig/ref [::worker :app.worker/executor])}
|
||||
:app.worker/executors
|
||||
{:default (ig/ref [::default :app.worker/executor])
|
||||
:worker (ig/ref [::worker :app.worker/executor])
|
||||
:blocking (ig/ref [::blocking :app.worker/executor])}
|
||||
|
||||
:metrics (ig/ref :app.metrics/metrics)}
|
||||
:app.worker/executors-monitor
|
||||
{:metrics (ig/ref :app.metrics/metrics)
|
||||
:executors (ig/ref :app.worker/executors)}
|
||||
|
||||
:app.migrations/migrations
|
||||
{}
|
||||
|
@ -155,9 +156,7 @@
|
|||
:msgbus (ig/ref :app.msgbus/msgbus)
|
||||
:public-uri (cf/get :public-uri)
|
||||
:audit (ig/ref :app.loggers.audit/collector)
|
||||
:executors
|
||||
{:default (ig/ref [::default :app.worker/executor])
|
||||
:blocking (ig/ref [::blocking :app.worker/executor])}}
|
||||
:executors (ig/ref :app.worker/executors)}
|
||||
|
||||
:app.worker/worker
|
||||
{:executor (ig/ref [::worker :app.worker/executor])
|
||||
|
|
|
@ -111,6 +111,12 @@
|
|||
:labels ["name"]
|
||||
:type :gauge}
|
||||
|
||||
:executors-completed-tasks
|
||||
{:name "penpot_executors_completed_tasks_total"
|
||||
:help "Aproximate number of completed tasks by the executor."
|
||||
:labels ["name"]
|
||||
:type :counter}
|
||||
|
||||
:executors-running-threads
|
||||
{:name "penpot_executors_running_threads"
|
||||
:help "Current number of threads with state RUNNING."
|
||||
|
|
|
@ -75,30 +75,40 @@
|
|||
(s/keys :req-un [::executors ::mtx/metrics]))
|
||||
|
||||
(defmethod ig/init-key ::executors-monitor
|
||||
[_ {:keys [executors metrics interval] :or {interval 2500}}]
|
||||
(letfn [(log-stats [scheduler]
|
||||
[_ {:keys [executors metrics interval] :or {interval 3000}}]
|
||||
(letfn [(log-stats [scheduler state]
|
||||
(doseq [[key ^ForkJoinPool executor] executors]
|
||||
(let [labels (into-array String [(name key)])]
|
||||
(mtx/run! metrics {:id :executors-active-threads
|
||||
:labels labels
|
||||
:val (.getPoolSize executor)})
|
||||
(mtx/run! metrics {:id :executors-running-threads
|
||||
:labels labels
|
||||
:val (.getRunningThreadCount executor)})
|
||||
(mtx/run! metrics {:id :executors-queued-submissions
|
||||
:labels labels
|
||||
:val (.getQueuedSubmissionCount executor)})))
|
||||
(let [labels (into-array String [(name key)])
|
||||
active (.getActiveThreadCount executor)
|
||||
running (.getRunningThreadCount executor)
|
||||
queued (.getQueuedSubmissionCount executor)
|
||||
steals (.getStealCount executor)
|
||||
steals-increment (- steals (or (get-in @state [key :steals]) 9))
|
||||
steals-increment (if (neg? steals-increment) 0 steals-increment)]
|
||||
|
||||
(mtx/run! metrics {:id :executors-active-threads :labels labels :val active})
|
||||
(mtx/run! metrics {:id :executors-running-threads :labels labels :val running})
|
||||
(mtx/run! metrics {:id :executors-queued-submissions :labels labels :val queued})
|
||||
(mtx/run! metrics {:id :executors-completed-tasks :labels labels :inc steals-increment})
|
||||
|
||||
(swap! state update key assoc
|
||||
:running running
|
||||
:active active
|
||||
:queued queued
|
||||
:steals steals)))
|
||||
|
||||
(when-not (.isShutdown scheduler)
|
||||
(px/schedule! scheduler interval (partial log-stats scheduler))))]
|
||||
(px/schedule! scheduler interval (partial log-stats scheduler state))))]
|
||||
|
||||
(let [scheduler (px/scheduled-pool 1)]
|
||||
(px/schedule! scheduler interval (partial log-stats scheduler))
|
||||
scheduler)))
|
||||
(let [scheduler (px/scheduled-pool 1)
|
||||
state (atom {})]
|
||||
(px/schedule! scheduler interval (partial log-stats scheduler state))
|
||||
{::scheduler scheduler
|
||||
::state state})))
|
||||
|
||||
(defmethod ig/halt-key! ::executors-monitor
|
||||
[_ instance]
|
||||
(.shutdown ^ExecutorService instance))
|
||||
[_ {:keys [::scheduler]}]
|
||||
(.shutdown ^ExecutorService scheduler))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Worker
|
||||
|
|
|
@ -63,14 +63,14 @@
|
|||
:pt %)))
|
||||
|
||||
grid-x-data (->> (gg/grid-snap-points frame :x)
|
||||
(mapv #(array-map :type :grid-x
|
||||
(mapv #(array-map :type :layout
|
||||
:id frame-id
|
||||
:pt %)))
|
||||
|
||||
grid-y-data (->> (gg/grid-snap-points frame :y)
|
||||
(mapv #(array-map :type :grid-y
|
||||
:id frame-id
|
||||
:pt %)))]
|
||||
(mapv #(array-map :type :layout
|
||||
:id frame-id
|
||||
:pt %)))]
|
||||
|
||||
(-> page-data
|
||||
;; Update root frame information
|
||||
|
|
Loading…
Reference in a new issue