mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 02:47:13 +02:00
🐛 Fix vthread pining on get-file-data-for-thumbnail rpc method
This commit is contained in:
parent
9173c73eca
commit
938890c04c
1 changed files with 18 additions and 0 deletions
|
@ -670,12 +670,30 @@
|
||||||
|
|
||||||
;; --- COMMAND QUERY: get-file-data-for-thumbnail
|
;; --- COMMAND QUERY: get-file-data-for-thumbnail
|
||||||
|
|
||||||
|
;; FIXME: performance issue
|
||||||
|
;;
|
||||||
|
;; We need to improve how we set frame for thumbnail in order to avoid
|
||||||
|
;; loading all pages into memory for find the frame set for thumbnail.
|
||||||
|
|
||||||
(defn get-file-data-for-thumbnail
|
(defn get-file-data-for-thumbnail
|
||||||
[conn {:keys [data id] :as file}]
|
[conn {:keys [data id] :as file}]
|
||||||
(letfn [;; function responsible on finding the frame marked to be
|
(letfn [;; function responsible on finding the frame marked to be
|
||||||
;; used as thumbnail; the returned frame always have
|
;; used as thumbnail; the returned frame always have
|
||||||
;; the :page-id set to the page that it belongs.
|
;; the :page-id set to the page that it belongs.
|
||||||
|
|
||||||
(get-thumbnail-frame [data]
|
(get-thumbnail-frame [data]
|
||||||
|
;; NOTE: this is a hack for avoid perform blocking
|
||||||
|
;; operation inside the for loop, clojure lazy-seq uses
|
||||||
|
;; synchronized blocks that does not plays well with
|
||||||
|
;; virtual threads, so we need to perform the load
|
||||||
|
;; operation first. This operation forces all pointer maps
|
||||||
|
;; load into the memory.
|
||||||
|
(->> (-> data :pages-index vals)
|
||||||
|
(filter pmap/pointer-map?)
|
||||||
|
(run! pmap/load!))
|
||||||
|
|
||||||
|
;; Then proceed to find the frame set for thumbnail
|
||||||
|
|
||||||
(d/seek :use-for-thumbnail?
|
(d/seek :use-for-thumbnail?
|
||||||
(for [page (-> data :pages-index vals)
|
(for [page (-> data :pages-index vals)
|
||||||
frame (-> page :objects ctt/get-frames)]
|
frame (-> page :objects ctt/get-frames)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue